swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[Bug]: Fix Generating Object class attribute when having embedded allOf schema

Open Chhida opened this issue 3 months ago • 1 comments

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" } } } } ] } } } ] } } } }, ....

Image

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

Image

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

Chhida avatar Oct 14 '25 08:10 Chhida

Hi @ewaostrowska, I changed the PR to https://github.com/swagger-api/swagger-codegen/pull/12639, would please help me validate it.

Chhida avatar Oct 20 '25 11:10 Chhida