Skip to content

Should properties be valid at the same level as allOf? #4444

@victorsc

Description

@victorsc

I noticed that the following schema is considered valid by the Swagger Editor and other OpenAPI tools:

Dog:
  allOf: 
  - $ref: "#/components/schemas/Pet"
  properties:
    bark:
      type: boolean
    breed:
      type: string
      enum: [Dingo, Husky, Retriever, Shepherd]

However, according to my understanding of OpenAPI specifications:

  • The properties keyword should not be valid at the same level as allOf.

allOf takes an array of object definitions that are used for independent validation but together compose a single object.

  • The correct way to structure this should be:
Dog: # "Dog" is a value for the pet_type property (the discriminator value)
  allOf:
    - $ref: "#/components/schemas/Pet"
    - type: object
      properties:
        bark:
          type: boolean
        breed:
          type: string
          enum: [Dingo, Husky, Retriever, Shepherd]

Questions for OpenAPI maintainers:

  1. Is this behavior intentional? Should properties be allowed at the same level as allOf, or is this a parsing mistake in tools like Swagger Editor?
  2. If this is valid, could you point to the relevant section in the OpenAPI 3.0/3.1 specification that explicitly allows properties at the same level as allOf?
  3. If it is a mistake, should Swagger Editor and other OpenAPI tools enforce stricter validation to prevent incorrect schema definitions?

I would appreciate any clarification on this matter. Thanks for your help! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions