swagger-api / swagger-api/swagger-codegen
[Bug]: Fix Generating Object class attribute when having embedded allOf schema
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
We want to have the same behavior as open-api-generator,
Fix Generating Object class attribute when having embedded allOf schema
Swagger Codegen Version
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.73</version>
<executions>
<execution>
<id>generationSwaggerInfoModule</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<modelPackage>--------</modelPackage>
<invokerPackage>---------</invokerPackage>
<apiPackage>---------</apiPackage>
<inputSpec>-----------------</inputSpec>
<generateModelDocumentation>false</generateModelDocumentation>
<language>java</language>
<library>jersey3</library>
<generateApiTests>-----------</generateApiTests>
<configOptions>
<dateLibrary>java8-localdatetime</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Language / Generator
java
OpenAPI/Swagger Spec
... "responses": { "200": { "description": "descriptionnn", "content": { "application/json": { "schema": { "allOf": [ { "$ref": "#/components/schemas/Classe1" }, { "type": "object", "properties": { "resultat": { "allOf": [ { "$ref": "#/components/schemas/Classe2" }, { "type": "object", "properties": { "content": { "type": "array", "items": { "$ref": "#/components/schemas/Classe3" } } } } ] } } } ] } } } }, ....
Steps to Reproduce
java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i api/file.json -l java
Expected Behavior
same behavior with openApi generator, we want to generate well structered usable Objects like described in the json input
Actual Behavior
Related Issues / Repos
The fix should be done in these repo:
https://github.com/swagger-api/swagger-codegen-generators
PR: https://github.com/swagger-api/swagger-codegen-generators/pull/1385
and
https://github.com/swagger-api/swagger-codegen
PR: https://github.com/swagger-api/swagger-codegen/pull/12639
Environment
- OS: Ubuntu 22.04
- Java Version: OpenJDK 17
- Build Tool: CLI, Maven
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 CLI generation command and the nested allOf schema in the issue, then inspect swagger-codegen-generators PR 1385 and swagger-codegen PR 12639, which describe the proposed fix. Compare the generated Java model output with the OpenAPI Generator behavior and verify the result using the Maven CLI reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100