swagger-api / swagger-api/swagger-ui

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

Open
#9,832 3 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Windows 10
  • Browser: Google Chrome
  • Version: 123.0.6312.107
  • Method of installation: -
  • Swagger-UI version: 5.13.0
  • Swagger/OpenAPI version: OpenAPI 3.1.0
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the problem with the OpenAPI 3.1.0 example in the issue: open Schemas, then AddressPart, then Discriminator. Trace the Swagger UI schema-rendering entry point for discriminator.mapping and compare it with oneOf rendering. Done means mapped schemas are displayed as navigable schema content rather than plain text, with a regression test if the project provides a suitable location.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
documentation, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.