OpenAPITools / OpenAPITools/openapi-generator
[BUG] Description
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When generating code for an openapi yaml with a path containing the following:
...
responses:
200:
description: A
content:
application/json:
schema:
$ref: '#/components/schemas/SomeDto
404:
description: B
The plugin generates the following annotation:
@ApiResponses(value = {
@ApiResponse(code = 200, message = "A", response = SomeDto.class)
@ApiResponse(code = 404, message = "B") })
This does not compile: it requires a comma at the end of the second line.
openapi-generator version
5.0.0 and 5.1.0
OpenAPI declaration file content or url
/bug:
get:
tags:
- bugs
summary: Bug.
description: Bug bug.
operationId: getBug
responses:
200:
description: A
content:
application/json:
schema:
$ref: '#/components/schemas/SomeDto'
404:
description: B
Generation Details
Maven config
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.1.0</version>
<executions>
<execution>
<id>produce-bug</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<templateDirectory>${project.basedir}/src/main/resources/templates</templateDirectory>
<apiPackage>nl.our.api</apiPackage>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<modelPackage>nl.our.api.model</modelPackage>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<inputSpec>bugi.yaml</inputSpec>
<ignoreFileOverride>${project.basedir}/.openapi-generator-ignore</ignoreFileOverride>
<invokerPackage>nl.our.api</invokerPackage>
<packageName>nl.our.api</packageName>
<generatorName>spring</generatorName>
<configOptions>
<configPackage>nl.ourlib.configuration</configPackage>
<dateLibrary>java8</dateLibrary>
<useOptional>true</useOptional>
<legacyDiscriminatorBehavior>false</legacyDiscriminatorBehavior>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>nl.something</groupId>
<artifactId>bug-api</artifactId>
<version>1.0.0</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
Steps to reproduce
mvn clean package -U will indicate the syntax error
Suggest a fix
Add a comma.
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 templates that emit the @ApiResponses annotation, using the provided bugu.yaml specification as the reproduction case. Run mvn clean package with the shown configuration, then verify that generated Java contains the required comma and compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100