swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.42k stars 8.93k forks source link

Schemas' content from `discriminator.mapping` are not displayed #9832

Open AlexElin opened 5 months ago

AlexElin commented 5 months ago

Q&A (please complete the following information)

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:
  /address-part:
    get:
      tags:
      - demo-controller
      operationId: addressPart
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/AddressPart'
components:
  schemas:
    AddressPart:
      description: address
      discriminator:
        propertyName: type
        mapping:
          BUILDING: '#/components/schemas/Building'
          STREET: '#/components/schemas/Street'
      oneOf:
      - $ref: '#/components/schemas/Building'
      - $ref: '#/components/schemas/Street'
    Building:
      description: Building
      properties:
        number:
          type: integer
          format: int32
        type:
          type: string
    Street:
      description: Street
      properties:
        name:
          type: string
        type:
          type: string

Swagger-UI configuration options:

SwaggerUI({
    "configUrl": "/v3/api-docs/swagger-config",
    "oauth2RedirectUrl": "http://localhost:8080/swagger-ui/oauth2-redirect.html",
    "url": "/v3/api-docs",
    "validatorUrl": ""
})
?yourQueryStringConfig

Describe the bug you're encountering

Schemas' content from discriminator.mapping are not displayed.

To reproduce...

Steps to reproduce the behavior:

  1. Open the provided spec in the Swagger UI
  2. Click on 'Schemas' -> 'AddressPart' -> 'Discriminator'

Expected behavior

Schemas' content for mappings are displayed. E.g. the same way as it's done for oneOf (see the below screenshot) image

Current behavior

Schemas are shown just as regular text (not hyperlinks) image

tchaflich commented 5 months ago

I have the same issue, and have noticed that the Example Values look fine, it's just the Schema that doesn't show correctly.