Skip to content

Is allOf + properties valid? #7949

Description

@KevinMitchell
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions