Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [JAVA] allOf object are not correctly generated with properties REF_AS_PARENT_IN_ALLOF=true and REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true #20005

Open
4 tasks done
JelmerBouma1985 opened this issue Oct 31, 2024 · 1 comment

Comments

@JelmerBouma1985
Copy link

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?
Description

Since release of 7.9.0 allOf objects don´t extend the parent anymore when normalizer REF_AS_PARENT_IN_ALLOF=true and REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true are used.

I expect the child object extends the parent object which works as expected until 7.9.0. Below generated code from 7.8.0:

public class Child1 extends Parent {
...
}

below code is generated code from 7.9.0

public class Child1 {
...
}
openapi-generator version

7.9.0

OpenAPI declaration file content or url

test.yaml

openapi: 3.0.0
info:
  title: 'AllOf does not work'
  description: 'Minimal yaml to showcase allOf does not work anymore'
  version: info
paths:
  /allOf:
    get:
      operationId: allOf
      responses:
        "200":
          description: oke
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Parent'
components:
  schemas:
    Parent:
      type: object
      properties:
        p1:
          type: integer
    Child1:
      properties:
        p2:
          type: string
      allOf:
        - $ref: '#/components/schemas/Parent'
Generation Details

I'm using the openapi-generator-maven-plugin

<plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>7.9.0</version>
                <configuration>
                    <openapiNormalizer>REF_AS_PARENT_IN_ALLOF=true,REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true</openapiNormalizer>
                    <generatorName>spring</generatorName>
                    <configOptions>
                        <useSpringBoot3>true</useSpringBoot3>
                        <interfaceOnly>true</interfaceOnly>
                    </configOptions>
                </configuration>
                <executions>
                    <execution>
                        <id>allOf</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${basedir}/src/main/resources/openapi/Showcase.yaml</inputSpec>
                            <generatorName>spring</generatorName>
                            <generateSupportingFiles>true</generateSupportingFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Steps to reproduce

java -jar openapi-generator-cli.jar generate -g spring -i test.yaml -o output/ --openapi-normalizer REF_AS_PARENT_IN_ALLOF=true,REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true

@wing328
Copy link
Member

wing328 commented Nov 1, 2024

thanks for reporting the issue. i will try to take a look over the weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants