使用'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() {