OpenAPITools / OpenAPITools/openapi-generator
[BUG] Delegate Pattern not fully supported with spring-cloud library
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
In a project I can configure delegatePattern=true (with interfaceOnly=false) to get delegate interfaces and controllers generated.
If however I set library=spring-cloud no controller is generated.
openapi-generator version
5.4.0, maven plugin.
OpenAPI declaration file content or url
This behaviour is obvious from the code in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java from line 480:
if (SPRING_CLOUD_LIBRARY.equals(library)) {
supportingFiles.add(new SupportingFile("apiKeyRequestInterceptor.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator),
"ApiKeyRequestInterceptor.java"));
supportingFiles.add(new SupportingFile("clientConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator),
"ClientConfiguration.java"));
apiTemplateFiles.put("apiClient.mustache", "Client.java");
if (!additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) {
additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
this.setSingleContentTypes(true);
}
} else {
apiTemplateFiles.put("apiController.mustache", "Controller.java");
supportingFiles.add(new SupportingFile("application.mustache",
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
supportingFiles.add(new SupportingFile("homeController.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator),
"HomeController.java"));
supportingFiles.add(new SupportingFile("openapi.mustache",
("src/main/resources").replace("/", java.io.File.separator), "openapi.yaml"));
if (!reactive && !apiFirst){
if (DocumentationProvider.SPRINGDOC.equals(getDocumentationProvider())){
supportingFiles.add(new SupportingFile("springdocDocumentationConfig.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator),
"SpringDocConfiguration.java"));
} else if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
supportingFiles.add(new SupportingFile("openapiDocumentationConfig.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator),
"SpringFoxConfiguration.java"));
}
}
}
There may be good reasons why both options are not compatible or actually should lead to different behaviour. However this is not clear from the documentation. Why noone should be able to use the delegate pattern together with Feign client generation seems not plausible to me.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java around line 480, and compare the spring-cloud branch with the controller-generating branch. Trace the apiClient.mustache and apiController.mustache selections, then determine and document the expected result when delegatePattern=true and library=spring-cloud. Done means the compatibility behavior is explicit and the generated output matches that decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100