Skip to content

Unable to resolve references in schema #10336

@whoareyoukid

Description

@whoareyoukid

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome, safari
  • Version: 133, 18.3
  • Method of installation: npm
  • Swagger-UI version: 5.20.0
  • Swagger/OpenAPI version: OpenAPI 3.1

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: Cat/ Dog Pet Store API
  description: An example API for a pet store
  version: 1.0.0
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      responses:
        '200':
          description: A list of pets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PetList'
components:
  schemas:
    PetList:
      type: array
      items:
        $ref: '#/components/schemas/Pet'
    Pet:
      type: object
      required:
        - petType
      properties:
        petType:
          type: string
      discriminator:
        propertyName: petType
        mapping:
          dog: '#/components/schemas/Dog'
          cat: '#/components/schemas/Cat'
        x-custom-extension: This is a custom extension for the discriminator
    Dog:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            breed:
              type: string
            barkVolume:
              type: integer
              description: Volume of the bark
    Cat:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            color:
              type: string
            purrLoudness:
              type: integer
              description: Loudness of the purr

Swagger-UI configuration options:

SwaggerUI({
        spec: apiSpec,
        dom_id: '#api-ui-container',
        defaultModelRendering: 'model',
        showExtensions: true,
        deepLinking: true,
        plugins: [DisableTryItOutPlugin],
        onComplete(): void {
          setTimeout(() => that.swaggerUiOnComplete(that), 1000);
        },
      })

Describe the bug you're encountering

  1. On clicking 'Expand All' button, nothing happens.
Image
  1. The refs are not correctly resolved
Image

Expected behavior

The refs should be resolved properly

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions