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

Switching between OpenAPI versions breaks allOf behavior

Open Mivexil opened this issue 7 months ago • 1 comments

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: Microsoft Edge
  • Version: 134
  • Method of installation: web (editor-next.swagger.io)
  • Swagger-Editor version: 5.0.0-alpha.136
  • Swagger/OpenAPI version: OpenAPI 3.0/3.1

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: Sample API
  version: '0.1'
paths:
components:
  schemas:
    BasicErrorModel:
      type: object
      required:
        - message
        - code
      properties:
        message:
          type: string
        code:
          type: integer
          minimum: 100
          maximum: 600
    ExtendedErrorModel:
      allOf: # Combines the BasicErrorModel and the inline model
        - $ref: "#/components/schemas/BasicErrorModel"
        - type: object
          required:
            - rootCause
          properties:
            rootCause:
              type: string

Describe the bug you're encountering

Switching between OpenAPI 3.0 and 3.1 versions causes the allOf element to render improperly.

To reproduce...

Steps to reproduce the behavior:

  1. Open the Swagger Next editor, and paste the provided API definition. At this point the ExtendedErrorModel renders with a wrong type:

Image

but fixes itself upon opening it, showing expected behavior.

Image

  1. Keeping the model open, change the 3.1.0 in the first line to 3.0.0.
  2. Change the 3.0.0 in the first line to 3.1.0 again.

Expected behavior

The spec renders as it did in step 1. Instead, the ref is not rendered properly:

Image

Image

The model needs to be fully collapsed and re-opened to render properly.

Additional context or thoughts

While probably inconsequential, it is confusing - initially I thought the behavior of allOf has changed for some reason.

Mivexil avatar Mar 20 '25 14:03 Mivexil