Open kleinph opened 4 years ago
Does serviceInterface
config options solve this?
@cberry-chwy I am not sure, I am not working anymore on this project.
Hello,
I agree that the behavior of having a default controller interface implementation is not really practical. I would expect the existing code to stop compiling when we add new API methods.
Looking at https://github.com/borsch/openapi-generator/blob/d6bbd51b5078dde410e811f9964bc72259dfe96d/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache and https://github.com/borsch/openapi-generator/blob/d6bbd51b5078dde410e811f9964bc72259dfe96d/modules/openapi-generator/src/main/resources/kotlin-spring/returnValue.mustache, I suggest to only add a body to the method in case there is a service interface.
WDYT?
Totally agree, I want to get compilation error, where I add new methods in API
Looks like the skipDefaultInterface
option is implemented in the meantime: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/kotlin-spring.md
Bug Report Checklist
Description
There should be an option the deactivate the generation of code which makes use of supporting files.
openapi-generator version
Version 4.3.0
OpenAPI declaration file content or url
api.yml:
build.gradle:
Command line used for generation
The gradle plugin was used (
id 'org.openapi.generator' version '4.3.0'
).Steps to reproduce
Use the api.yml and the gradle config to generate the API. There will be default implementations in the *Delegate interfaces which use ApiUtil.kt.
Related issues/PRs
Issue #5476
Suggest a fix
Provide an option to disable code generation for the delegate classes. Like the Java Spring generator has with
skipDefaultInterface
.Note that
interfaceOnly
is no solution because it will prevent generation of the REST controller classes.Also note that
supportingFiles: "ApiUtil,kt"
fixes the missing class reference, but requires to deactivate stricter null checks (prevenst use of-Xjsr305=strict
compiler args). See #5476.My workaround so far is to provide my own (null-safe) implementation of ApiUtil.