Openapi生成器春季:如何替换@RequestMapping(“ $ {openapi.someproject.base-path:/ v1}”)

时间:2018-11-21 13:52:38

标签: openapi-generator

我正在导入一个包含用openapi-codegen生成的RestResources的jar文件。

@Controller
@RequestMapping({"${openapi.someproject.base-path:/v1}"}) // <-- ${openapi.someproject.base-path:/v1} should be replaced by /v1
public class ApiApiController implements ApiApi {
private final ApiApiDelegate delegate;

public ApiApiController(@Autowired(required = false) ApiApiDelegate delegate) {
    this.delegate = (ApiApiDelegate)Optional.ofNullable(delegate).orElse(new ApiApiDelegate() {
    });
}

public ApiApiDelegate getDelegate() {
    return this.delegate;
}
}

部署我的应用程序时,看到一个名为“ $ {openapi.someproject.base-path:/ v1}”的端点。如何将其配置为“ / v1”。

我试图将以下使用项目的application.yml放进去:

openapi:
  someproject:
    base-path: ""

导入的jar是使用openapi-generator-maven-plugin生成的,如下所示:

                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>back-end-swagger</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/swagger/api.yml</inputSpec>
                            <generatorName>spring</generatorName>
                            <apiPackage>com.test.api</apiPackage>
                            <modelPackage>com.test.api.model</modelPackage>                                <supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
                            <validateSpec>true</validateSpec>
                            <configOptions>
                                <delegatePattern>true</delegatePattern>
                            </configOptions>
                        </configuration>
                    </execution>

api.yml文件如下所示:

swagger: "2.0"
info:
  version: "1.0.0"
  title: "someproject"
host: "somehost.io"
basePath: "/v1"
tags:
- name: "endpoint"
schemes:
- "https"
- "http"
paths:
  /api/test:
    get:
      produces:
      - "application/json"
      responses:
        200:
          description: OK

0 个答案:

没有答案