【问题标题】:OpenAPI Maven Generator generates inexistent '@OptionsMapping' annotation for Spring BootOpenAPI Maven Generator 为 Spring Boot 生成不存在的“@OptionsMapping”注释
【发布时间】:2021-08-15 01:58:00
【问题描述】:

当使用 'openapi-generator-maven-plugin' 基于 jar 生成客户端时。

这是我重要的 pom.xml 部分:

 <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-engine-rest-openapi</artifactId>
            <version>${camunda.version}</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.openapitools</groupId>
            <artifactId>jackson-databind-nullable</artifactId>
            <version>0.2.1</version>
        </dependency>

<repositories>
        <repository>
            <id>camunda-bpm-nexus</id>
            <name>camunda-bpm-nexus</name>
            <url>https://app.camunda.com/nexus/content/groups/public</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.camunda.bpm</groupId>
                                    <artifactId>camunda-engine-rest-openapi</artifactId>
                                    <version>${camunda.version}</version>
                                    <outputDirectory>${basedir}/target/openapi</outputDirectory>
                                    <includes>openapi.json</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>5.1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/target/openapi/openapi.json</inputSpec>
                            <skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
                            <generatorName>spring</generatorName>
                            <configOptions>
                                <dateLibrary>java8</dateLibrary>
                                <java8>true</java8>
                                <library>spring-boot</library>
                                <interfaceOnly>true</interfaceOnly>
                            </configOptions>
                            <output>${project.build.directory}/camunda-openapi-client</output>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

由于某种原因,生成器创建了一个在任何地方都不存在的“@OptionsMapping”注释。例如:

@ApiOperation(value = "Tenant Resource Options", nickname = "availableTenantResourceOperations", notes = "The `/tenant` resource supports two custom OPTIONS requests, this one for the resource as such and one for individual tenant instances. The OPTIONS request allows checking for the set of available operations that the currently authenticated user can perform on the `/tenant` resource. If the user can perform an operation or not may depend on various things, including the users authorizations to interact with this resource and the internal configuration of the process engine.", response = ResourceOptionsDto.class, tags={ "Tenant", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Request successful.", response = ResourceOptionsDto.class) })
@OptionsMapping(
    value = "/tenant",
    produces = { "application/json" }
)
default ResponseEntity<ResourceOptionsDto> availableTenantResourceOperations() {

【问题讨论】:

    标签: java spring-boot springfox openapi-generator


    【解决方案1】:

    此错误已在较新版本的库中得到修复。

    请升级或关注该库的 Github 问题。

    【讨论】:

      猜你喜欢
      • 2022-07-23
      • 1970-01-01
      • 2022-08-05
      • 2019-12-07
      • 2021-08-08
      • 1970-01-01
      • 2021-11-04
      • 2020-10-26
      • 2021-11-09
      相关资源
      最近更新 更多