OpenAPITools / OpenAPITools/openapi-generator
[BUG] [sprind-cloud] Multiple response bodies generates invalid code
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If multiple response bodies are specified, the producer annotation is filled incorrectly and a spring boot application cannot be started.
openapi-generator version
4.3.1 and 5.0.1
OpenAPI declaration file content or url
/foo:
post:
operationId: createFoo
...
responses:
'200':
description: "Return"
content:
text/plain:
schema:
type: string
text/html:
schema:
type: string
Generated java code
@RequestMapping(produces = "text/plain,text/html")
public ResponseEntity<Void> createFoo(...) {...}
Generation Details
Maven plugin
<configuration>
<generatorName>spring</generatorName>
<configOptions>
<sortParamsByRequiredFlag>true</sortParamsByRequiredFlag>
<library>spring-cloud</library>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<useOptional>true</useOptional>
<skipDefaultInterface>true</skipDefaultInterface>
<useBeanValidation>true</useBeanValidation>
</configOptions>
Steps to reproduce
Use multiple response bodies:
Expected code is not a comma separated String. Spring needs a proper list of producers
@RequestMapping(produces = {"text/plain","text/html"})
public ResponseEntity<Void> createFoo(...) {...}
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 with the Spring generator's handling of response media types and reproduce the issue using the provided OpenAPI YAML and Maven spring-cloud configuration. Done means generated Java uses valid array syntax for multiple produces values and the resulting Spring Boot application starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100