OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][GRADLE] Generator produces uncompilable code unless run incrementally
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
- When generating several classes used in 'MessageToSend' are missing causing the code to not compile afterwards
When placing the properties in comments and generating the code in multiple steps, taking out 1 comment each time, causes the code to be compilable. - After the code is generated and compilable, there is 1 missing entry in the creation of the GsonBuilder in JSON.java
gsonBuilder.registerTypeAdapterFactory(new PaperDeliveryData.CustomTypeAdapterFactory());
openapi-generator version
6.6.0
OpenAPI declaration file content or url
https://gist.github.com/SnakeSVx/d6e1b7c96a7d4dd85aa0d4d705d74afd
Generation Details
openApiGenerate {
generatorName = "java"
inputSpec = "$rootDir/api/magda/documentendienst.yaml".toString()
outputDir = "$buildDir/generated".toString()
generateApiTests = false
generateModelTests = false
skipOverwrite = false
modelPackage = "be.vaph.sparta.api.client.magda.documenten.controller"
configOptions = [
dateLibrary: "java8"
]
globalProperties = [
verbose: "true"
]
}
Steps to reproduce
- Generate with supplies yaml
- Try to build code: build fails
- In model MessageToSend: comment eboxDeliveryData, paperDeliveryData, emailDeliveryData, signingWorkflowData, businessData
- Try to build code: build succeeds, but is incomplete
- Remove comment from eboxDeliveryData
- Try to build code: build succeeds, but is incomplete (eboxDeliveryData is added)
- Remove comment from paperDeliveryData
- Try to build code: build succeeds, but is incomplete (paperDeliveryData is added)
- Remove comment from emailDeliveryData
- Try to build code: build succeeds, but is incomplete (emailDeliveryData is added)
- Remove comment from emailDeliveryData, businessData
- Try to build code: build succeeds, but is incomplete (emailDeliveryData, businessData are added)
- In JSON.java, near GsonBuilder gsonBuilder = createGson();, all adapters get registered apart from gsonBuilder.registerTypeAdapterFactory(new PaperDeliveryData.CustomTypeAdapterFactory());
Related issues/PRs
Suggest a fix
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 generation using the linked OpenAPI declaration and the Gradle openApiGenerate configuration. Inspect the generated MessageToSend model and JSON.java, especially the GsonBuilder registrations, and compare the initial output with the incremental workaround. Done means the generated Java code compiles and includes all required model classes and type-adapter registrations on the first run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100