swagger-api / swagger-api/swagger-core
defaultValue attribute at enum object generate arbitrary json file
Open
Nobody has claimed this yet.
backlog
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
I have an enum object mapped in @Schema, that change arbitrary in each build
Sample
@Schema(defaultValue = "DELIVERY", name = "type",
description = "Type of the shipping", example = "DELIVERY",
enumAsRef = true)
"ShippingType" : {
"type" : "string",
"description" : "Type of the shipping",
"example" : "DELIVERY",
"default" : "DELIVERY",
"enum" : [ "DELIVERY", "REVERSE", "TRANSFERENCE" ]
},
"ShippingType" : {
"type" : "string",
"description" : "Type of the shipping",
"example" : "DELIVERY",
"enum" : [ "DELIVERY", "REVERSE", "TRANSFERENCE" ],
"default" : "DELIVERY"
},
Property default arbitrary order in object ShippingType in openapi json file
If i remove defaultValue, the json always the same
@Schema(name = "type",
description = "Type of the shipping", example = "DELIVERY",
enumAsRef = true)
plugin at pom.xml
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin-jakarta</artifactId>
<version>${swagger-maven-plugin.version}</version>
<configuration>
<outputFileName>openapi</outputFileName>
<resourcePackages>
<resourcePackage>com.x.test.adapter.input.web</resourcePackage>
</resourcePackages>
<outputPath>${basedir}/target/resources/com/x/test/adapter/input/web</outputPath>
<outputFormat>JSONANDYAML</outputFormat>
<prettyPrint>true</prettyPrint>
</configuration>
<executions>
<execution>
<id>generate-doc</id>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
Is that a way to fix this issue?
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 @Schema annotation and the swagger-maven-plugin-jakarta configuration shown in the report, then reproduce generation with prettyPrint enabled. Compare repeated OpenAPI JSON outputs for the ShippingType schema; done means the output is deterministic when defaultValue is present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100