OpenAPITools / OpenAPITools/openapi-generator
[BUG] Enumeration in path generates wrong java
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When an enumeration is used as a parameter in a path the generated springboot server has both wrong annotations (quotes where there shouldn't be quotes) and wrong actual accepted values (capital letters instead of lower case) for the enumerated values.
openapi-generator version
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.3.1</version>
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Feature Branching Service
description: Feature Branching Service
version: 1.0.0
paths:
/job/{job}:
summary: Current status of a specific job
parameters:
- $ref: '#/components/parameters/jobParameter'
get:
summary: Retrieve the current status of the feature branching service's jobs
operationId: getJob
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/job'
components:
parameters:
jobParameter:
name: job
in: path
description: "A job that is running or can be run"
required: true
schema:
$ref: '#/components/schemas/jobName'
schemas:
job:
type: object
properties:
running:
type: string
enum:
- IDLE
- SCHEDULED
- RUNNING
- PAUSED
paused:
type: boolean
jobName:
type: string
enum:
- nightly
- continuous
- pull
- deploy
- test
- push
Generation Details
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
<generatorName>spring</generatorName>
<configOptions>
<library>spring-boot</library>
<dateLibrary>java8</dateLibrary>
<delegatePattern>true</delegatePattern>
</configOptions>
</configuration>
Steps to reproduce
- Generate java server as above
- Expected result:
** Java server accepts string in path with allowed values of nightly, continuous, pull, deploy, test, or push - Actual result:
** Generated code has annotation @ApiParam(value = "A job that is running or can be run",required=true, allowableValues = ""nightly", "continuous", "pull", "deploy", "test", "push"") <- Note quotes that should not be there
** Actual accepted values are NIGHTLY, CONTINUOUS, PULL, DEPLOY, TEST, and PUSH <- Note captialisation
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
Reproduce the issue with the Maven plugin using the supplied api.yaml, generatorName spring, and spring-boot library configuration. Compare the generated path parameter annotations and accepted enum values with the expected lowercase nightly, continuous, pull, deploy, test, and push values; done means the extra annotation quotes and uppercase values are gone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, 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