Skip to content

Enums being exploded everywhere when openapi version is 3.1.1 (correct in 3.0.0) #10665

@arnabkd

Description

@arnabkd

Q&A (please complete the following information)

  • OS: [e.g. macOS] mac OS
  • Browser: [e.g. chrome, safari] chrome
  • Version: unsure
  • Method of installation: unsure
  • Swagger-UI version: unsure
  • Swagger/OpenAPI version: unsure

Content & configuration

Example Swagger/OpenAPI definition:

{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Generated server url"
    }
  ],
  "paths": {
    "/hello": {
      "get": {
        "tags": [
          "my-controller"
        ],
        "operationId": "hello",
        "parameters": [
          {
            "name": "request",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/RequestWrapper"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/Wrapper"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "MyEnum": {
        "type": "string",
        "enum": [
          "FOO",
          "BAR"
        ]
      },
      "RequestWrapper": {
        "type": "object",
        "properties": {
          "enumValue": {
            "$ref": "#/components/schemas/MyEnum"
          }
        }
      },
      "Wrapper": {
        "type": "object",
        "properties": {
          "enumValue": {
            "$ref": "#/components/schemas/MyEnum"
          }
        }
      }
    }
  }
}

I am testing using only https://swagger.io/tools/swagger-editor/ but I have encountered this locally as well.

Describe the bug you're encountering

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor.swagger.io/
  2. Paste in the YAML above
  3. Notice that the enum is exploded in all types that have the enum as a field
  4. Change OAS version to 3.0.0 and the enum is no longer exploded everywhere but is rather referred to.

Expected behavior

I expected 3.1.0 to behave as well as 3.0.0 in terms of enums.

Screenshots

With 3.1.0

Image

With 3.0.0

Image

Additional context or thoughts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions