【问题标题】:openapi-generator with spring-boot, remove generated values带有spring-boot的openapi-generator,删除生成的值
【发布时间】:2020-03-25 12:43:41
【问题描述】:

我正在为 gradle 使用 openapi-generator。

配置:

task generateSalesOffersApi(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
    generatorName = "spring"
    inputSpec = "${projectDir}/src/main/resources/my-contract.yaml".toString()
    outputDir = "${buildDir}/generated".toString()
    additionalProperties = [
            interfaceOnly: 'true',
            reactive: 'true',
            skipDefaultInterface: "true",
            implicitHeaders: "true",
    ]

    configOptions = [
            dateLibrary: 'java8',
            swaggerDocketConfig: "true",
            useTags:  'false',
            apiPackage: 'com.data.api',
            modelPackage: 'com.data.model',
    ]

    systemProperties = [
            apis: "",
            models: "",
            hideGenerationTimestamp: "true"
    ]

模型按预期生成。 Api 部分也主要是。

但是如何摆脱 ResponseEntity 包装和 ServerWebExchange 作为生成接口中的方法参数。

实际:

Mono<ResponseEntity<MyPojo>> getMyPojo(@ApiParam(value = "Param 1",required=true) @PathVariable("param1") String param1, ServerWebExchange exchange);

预期:

Mono<MyPojo> getMyPojo(@ApiParam(value = "Param 1",required=true) @PathVariable("param1") String param1);

我尝试使用 java 生成器,您可以在其中将库设置为 webclient,但不幸的是,这对我来说缺少很多配置,并且生成了许多不必要的类。

【问题讨论】:

    标签: java spring-boot gradle openapi-generator


    【解决方案1】:

    您需要将reactive 设置为false

    https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/spring.md

    反应性

    以 Mono/Flux Reactor 类型包装响应(仅限弹簧启动)

    【讨论】:

    • 啊,对不起。我离开了实际和预期的部分。我用正确的输入更新了问题。
    猜你喜欢
    • 2021-08-15
    • 2022-07-23
    • 2022-09-30
    • 2021-12-21
    • 1970-01-01
    • 1970-01-01
    • 2022-06-27
    • 2019-09-20
    • 2020-04-02
    相关资源
    最近更新 更多