OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] [openapi-yaml] [spring] wrong generated example text
Nobody has claimed this yet.
- 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
direct usage of allOf destroyes the example of a property with type object without further properties.
expected output (with v7.4.0)
yaml
example:
someMeaningfulNumber: 25009779801
java
String exampleString = "{ \"data\" : { \"someMeaningfulNumber\" : 25009779801 }, \"someProperty\" : \"someProperty\" }";
failing output (>7.4.0)
yaml
example:
data: "{\"someMeaningfulNumber\":25009779801}"
java
String exampleString = "{ \"data\" : \"{\\"someMeaningfulNumber\\":25009779801}\", \"someProperty\" : \"someProperty\" }";
the generated yaml can't be used for further generation. the generated java code doesn't compile.
openapi-generator version
7.4.0 -> OK
7.5.0 -> fail
7.6.0 -> fail
7.7.0 -> fail
OpenAPI declaration file content or url
full project:
https://github.com/kingofdisasterr/openapi-generator-example
Generation Details
mvn clean verifyof https://github.com/kingofdisasterr/openapi-generator-example/blob/main/pom.xml
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 linked someinterface.yaml and run mvn clean verify in the reproduction project, comparing generation with OpenAPI Generator 7.4.0 and later versions. Trace the generated YAML and Java example output to identify where the object example becomes a string. Done means the YAML preserves the object example and the generated Java example compiles as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100