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

Is allOf + properties valid? #7949

Closed
KevinMitchell opened this issue Nov 16, 2020 · 1 comment
Closed

Is allOf + properties valid? #7949

KevinMitchell opened this issue Nov 16, 2020 · 1 comment

Comments

@KevinMitchell
Copy link

Description

If I define

  schemas:
    T:
      type: object
      properties:
        a:
          type: string
        b:
          type: string
    S:
      allOf:
      - $ref: '#/components/schemas/T'
      - type: object
        properties:
          x:
            type: string
          y:
            type: string

then the Java code generator expands out T's properties in the class generated for S. So there's no inheritance. If I rewrite the definition of S to look like this

    S:
      allOf:
        - $ref: '#/components/schemas/T'
      properties:
        x:
          type: string
        y:
          type: string

then there are no errors reported and S is defined as inheriting from T. But it's not clear to me whether this is actually a legal OA3 specification, and other OA3 tooling complains. So is there a definitive statement anywhere that says this is or isn't allowed? Most of the statements I've seen are just based on the behaviour of particular tools. And as the amount of tooling increases this isn't really a sustainable approach. If this isn't valid then it's not clear to me how to rewrite the example so it's valid, and the code generator produces the same output as the invalid example.

openapi-generator version

5.0.0, spring/spring-boot

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
@wing328
Copy link
Member

wing328 commented Dec 3, 2023

please use openapi normalizer with the rule REFACTOR_ALLOF_WITH_PROPERTIES_ONLY: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

@wing328 wing328 closed this as completed Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants