Skip to content

Selecting "--" choice in dropdown throws error #5452

@dalbani

Description

@dalbani

Q&A (please complete the following information)

  • OS: Ubuntu 18.04
  • Browser: Chrome
  • Version: 75
  • Method of installation: Docker
  • Swagger-UI version: 3.23.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

OpenAPI definition:

openapi: "3.0.0"
info:
  title: Testcase API
  version: 2.0.0
paths:
  '/endpoint':
    get:
      parameters:
        - name: type
          in: query
          example: fruit
          schema:
            type: string
            enum:
              - fruit
              - vegetable
              - drink
      responses:
        '200':
          description: 200 response

Describe the bug you're encountering

Selecting the -- choice in a dropdown menu throws an error about not being able to render the component.

To reproduce...

Steps to reproduce the behavior:

  1. Go to the Swagger Editor
  2. Copy/paste the YAML definition
  3. Select the -- choice in the dropdown for the type parameter.
  4. See following error:
    😱 Could not render this component, see the console.

Expected behavior

No error should be reported to the user, the dropdown should support being set to --.

Screenshots

image

Additional context or thoughts

The issue has apparently to do with code at https://github.com/swagger-api/swagger-ui/blob/master/src/core/components/layout-utils.jsx#L187.

image

The value of this.state.value is null for the -- select option, thus failing when trying to access the .toJS property.

Or am I simply missing something obvious in my OpenAPI definition?!?

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