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

OpenAPI, invalid @Override annotation in base class, in inheritance case. #1881

Closed
matadini opened this issue Nov 19, 2024 · 0 comments · Fixed by #1883
Closed

OpenAPI, invalid @Override annotation in base class, in inheritance case. #1881

matadini opened this issue Nov 19, 2024 · 0 comments · Fixed by #1883

Comments

@matadini
Copy link

matadini commented Nov 19, 2024

Expected Behavior

Having several hierarchies of component inheritance described in the OpenAPI yml file, I want all classes to be generated correctly

Actual Behaviour

OpenApi generator adds the @Override annotation in the base class, which is the foundation for the inheritance hierarchy. The problem occurs when there is more than one inheritance hierarchy in the OpenAPI's yml file. It looks like the issue arises for the first found inheritance hierarchy.

Steps To Reproduce

  1. Create simple app
  2. Define example CRUD endpoints in OpenAPI yml file to generate API classes to implement
  3. Define more than one, component inheritance hierarchy in yml file:
components:
  schemas:
    AnimalRequest:
      type: object
      properties:
        name:
          type: string
        valueType:
          type: string
      discriminator:
        propertyName: valueType
        mapping:
          catRq: '#/components/schemas/DogRequest'
          dogRq: '#/components/schemas/CatRequest'
    DogRequest:
      allOf:
        - $ref: '#/components/schemas/AnimalRequest'
        - type: object
      properties:
        dogProperty:
          type: string
    CatRequest:
      allOf:
        - $ref: '#/components/schemas/AnimalRequest'
        - type: object
      properties:
        catProperty:
          type: string

    AnimalResponse:
      type: object
      properties:
        name:
          type: string
        valueType:
          type: string
      discriminator:
        propertyName: valueType
        mapping:
          catRs: '#/components/schemas/DogResponse'
          dogRs: '#/components/schemas/CatResponse'
    DogResponse:
      allOf:
        - $ref: '#/components/schemas/AnimalResponse'
        - type: object
      properties:
        dogProperty:
          type: string
    CatResponse:
      allOf:
        - $ref: '#/components/schemas/AnimalResponse'
        - type: object
      properties:
        catProperty:
          type: string

4, gradle compileJava result: Generated AnimalResponse will contain @Override annotation:

    @Override
    public String getValueType() {
        return valueType;
    }
  1. Problem occurse since 4.4.4

Environment Information

  • opensuse tumbleweed
  • jdk21
  • micronaut 4.7.0
  • io.micronaut.openapi 4.4.4

Example Application

https://github.com/matadini/openapi-micronaut-inheritance-bug

Version

4.7.0

@matadini matadini changed the title OpenAPI, invalid @Override annotation in base class, in inherance case. OpenAPI, invalid @Override annotation in base class, in inheritance case. Nov 19, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Nov 19, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Nov 20, 2024
sdelamo pushed a commit that referenced this issue Nov 20, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Nov 20, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Nov 21, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Nov 21, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Nov 21, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Dec 3, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant