OpenAPITools / OpenAPITools/openapi-generator
[REQ] Make sure enums are unique
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
I got a json with spec version 2 from the third party vendor. It contains enums in some places and some of them have duplications. Of course this is a bug in json and should be fixed by the vendor, but would be nice if the generator checked it and removed duplications before generating java enums
Describe the solution you'd like
Check and remove duplicates from enums before generating java enums. Print a warning about duplications found
Describe alternatives you've considered
Well, so far I wrote a gradle script which parses json and removes duplicates before running generator. It makes my gradle script big and ugly
gradle plugin configuration
openApiGenerate {
generatorName = "java"
inputSpec = "$buildDir/generated/json/my.json".toString()
validateSpec = false
outputDir = "$buildDir/generated/myclasses".toString()
apiPackage = "foo"
invokerPackage = "bar"
modelPackage = "foobarbar"
configOptions = [
dateLibrary : 'java8',
java8 : 'true',
library : 'native',
serializationLibrary: 'jackson',
useRuntimeException : 'true',
asyncNative : 'true'
]
globalProperties = [
apiDocs : 'false',
modelDocs: 'false',
apiTests: 'false',
modelTests: 'false'
]
sourceSets.main.java.srcDirs += "$buildDir/generated/myclasses/src/main/java"
}
gradle plugin version - id "org.openapi.generator" version "5.0.1"
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 from the Java generator entry point selected by generatorName and trace how enums from the inputSpec are processed before Java code is emitted. Inspect existing warning and generator-test patterns, then verify that duplicate enum values are removed and a warning is printed for each affected enum.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100