Skip to content

oneOf containing only a single enum (or ref to one) does not display as drop-down #7912

@hauntingEcho

Description

@hauntingEcho

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: Firefox
  • Version: 98.0.1 (64-bit)
  • Method of installation: dist assets
  • Swagger-UI version: 4.5.0
  • Swagger/OpenAPI version: OpenAPI 3.0.0

Content & configuration

Dist assets with the below YAML, running on an S3 bucket with website config enabled.

Example Swagger/OpenAPI definition:

openapi: 3.0.0
paths:
  /1:
    get:
      parameters:
      - name: order
        in: query
        description: Optional parameter for the method to sort results by.
        schema:
          default: Ascending
          oneOf:
          - $ref: '#/components/schemas/SortOrder'
  /2:
    get:
      parameters:
      - name: order
        in: query
        description: Optional parameter for the method to sort results by.
        schema:
          $ref: '#/components/schemas/SortOrder'
  /3:
    get:
      parameters:
      - name: order
        in: query
        description: Optional parameter for the method to sort results by.
        schema:
          type: string
          enum:
          - ascending
          - descending
  /4:
    get:
      parameters:
      - name: order
        in: query
        description: Optional parameter for the method to sort results by.
        schema:
          $ref: '#/components/schemas/SortOrder'
  /5:
    get:
      parameters:
      - name: order
        in: query
        description: Optional parameter for the method to sort results by.
        schema:
          type: string
          nullable: true
          enum:
          - ascending
          - descending
  /6:
    get:
      parameters:
      - name: order
        in: query
        description: Optional parameter for the method to sort results by.
        schema:
          oneOf:
          - type: string
            enum:
            - ascending
            - descending
components:
  schemas:
    SortOrder:
      type: string
      enum:
      - ascending
      - descending
    NullableSortOrder:
      type: string
      nullable: true
      enum:
      - ascending
      - descending

Swagger-UI configuration options:

I'm using the plain HTML/JS distribution, only changing the URL to be relative:

      const ui = SwaggerUIBundle({
        url: "openapi.yaml",
        dom_id: '#swagger-ui',
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout"
      });

Describe the bug you're encountering

All six endpoints above should display with dropdowns for their enumeration values. /1 and /6 display with text boxes instead.

To reproduce...

Steps to reproduce the behavior:

  1. Host the static dist files with the above YAML
  2. scroll to each endpoint and see their prompt for order.

Expected behavior

All six endpoints displayed identically

Screenshots

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions