swagger-js icon indicating copy to clipboard operation
swagger-js copied to clipboard

OpenAPI 3.1.0: error when resolving schemas with allOf and circular references

Open glowcloud opened this issue 7 months ago • 0 comments

NOTE: this will also be affecting ApiDOM OpenAPI 3.0.x dereferencing. Another issues needs to be create for ApiDOM repo.

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.1.0
components:
  schemas:
    First:
      allOf:
        - $ref: '#/components/schemas/Second'
    Second:
      allOf:
        - $ref: '#/components/schemas/Third'
    Third:
      allOf:
        - $ref: '#/components/schemas/Second'

Describe the bug you're encountering

Resolving a subtree or the entire definition will cause an error TypeError: Elements in allOf must be objects.

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor-next.swagger.io/
  2. Paste the definition
  3. Open any of the schemas
  4. See the error

Screenshots

The result of opening Second and then Third schema:

Image

glowcloud avatar Mar 27 '25 08:03 glowcloud