openapi-generator: Springboot codegen : Compilation error in generated controllers if the skipDefaultInterface tag is set to true
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What’s the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What’s the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Springboot codegen : Compilation error in generated controllers if the skipDefaultInterface tag is set to true
openapi-generator version
3.0.2
OpenAPI declaration file content or url
petstore.yaml
Command line used for generation
spring boot
maven plugin config
<configOptions> <java8>true</java8> <library>spring-boot</library> <dateLibrary>java8</dateLibrary> <sourceFolder>src/main/java</sourceFolder> <useBeanValidation>true</useBeanValidation> <configPackage>com.sample.config</configPackage> <swaggerDocketConfig>true</swaggerDocketConfig> <skipDefaultInterface>true</skipDefaultInterface> </configOptions>
Steps to reproduce
Set skipdefaultInterface flag as true
Error message
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project openapi-spring: Compilation failure: Compilation failure: [ERROR] Downloads/Codebase/openapipoc/src/main/java/com/sample/api/UserApiController.java:[11,8] com.sample.api.UserApiController is not abstract and does not override abstract me thod updateUser(java.lang.String,@javax.validation.Valid com.sample.model.User) in com.sample.api.UserApi [ERROR] /Downloads/Codebase/openapipoc/src/main/java/com/sample/api/UserApiController.java:[20,5] method does not override or implement a method from a supertype [ERROR] /Downloads/Codebase/openapipoc/src/main/java/com/sample/api/PetApiController.java:[11,8] com..sample.api.PetApiController is not abstract and does not override abstract meth od uploadFile(java.lang.Long,java.lang.String,@javax.validation.Valid org.springframework.web.multipart.MultipartFile) in com.sample.api.PetApi [ERROR] /Downloads/Codebase/openapipoc/src/main/java/com/sample/api/PetApiController.java:[20,5] method does not override or implement a method from a supertype [ERROR] /Downloads/Codebase/openapipoc/src/main/java/com/sample/api/StoreApiController.java:[11,8] com.sample.api.StoreApiController is not abstract and does not override abstract method placeOrder(@javax.validation.Valid com.sample.model.Order) in com.sample.api.StoreApi [ERROR] /Downloads/Codebase/openapipoc/src/main/java/com/sample/api/StoreApiController.java:[20,5] method does not override or implement a method from a supertype
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 15 (7 by maintainers)
@developer79433 I just wanted to point out the
interfaceOnlythat prevents a controller class from being generated. would that help your project?Can we re-add the label ‘bug’, please?
In the scenario described in this issue, the code that OpenAPI Generator generates does not compile. I’m assuming that OpenAPI Codegen is intended to generate Java code that compiles - there’s not much use of Java code that doesn’t compile.
So this is unintended unfortunate behaviour, ie a bug.
Here is what I usually do: I generate interfaces, and in a separate location I write the controllers that implement those interfaces. You have to write the controllers anyway as you need to implement the endpoint