我想避免 maven 插件 swagger codegen 生成的接口中的“默认”实现。例如,使用宠物商店招摇:http://petstore.swagger.io/v2/swagger.json
我使用 Maven 插件生成界面:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>./src/main/resources/swagger/api.yml</inputSpec>
<language>spring</language>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<java8>true</java8>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
我使用默认的方法实现生成像 PetApi.java 这样的接口:
default ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
我想避免它喜欢
ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
有可能吗?
2020 年 3 月更新:
根据新的 OpenAPI Tool
openapi-generator
有一个选项spring
(language
已弃用,使用generatorName
)
skipDefaultInterface
https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/spring.md