The Wayback Machine - https://web.archive.org/web/20201126100550/https://github.com/swagger-api/swagger-ui/issues/6585
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try request not initiated without selecting any of the available option(s) from enum #6585

Open
debargharoy opened this issue Nov 5, 2020 · 2 comments
Labels

Comments

@debargharoy
Copy link

@debargharoy debargharoy commented Nov 5, 2020

Q&A

  • OS: Windows 10
  • Browser: Edge, Chrome, Firefox
  • Version: 86.x (Chrome), 82.x (Firefox)
  • Method of installation: dist assets
  • Swagger-UI version: 3.32.5, and Swagger Editor - Online
  • Swagger/OpenAPI version: OpenAPI 3.0

Consider the below OpenAPI definition:

openapi: 3.0.1
info:
  title: Test Documentation
  version: 0.0.1-SNAPSHOT
servers:
- url: http://localhost:8080
paths:
  /endpoint:
    get:
      tags:
      - My Tag
      summary: Some GET request
      operationId: myoperation
      parameters:
      - name: parameter1
        in: query
        description: Dummy parameter
        content:
          application/json:
            schema:
              type: array
              items:
                type: string
                default: Active
                enum:
                - Active
                - Suspended
                - Deleted
              enum:
              - Active
              - Suspended
              - Deleted
      responses:
        "204":
          description: No content
          content:
            application/json: {}

Describe the bug you're encountering

The output is expected as shown below

The bug occurs when the below process is followed

  1. Load the Swagger UI
  2. Click on the Try it out
  3. Click on Execute

Now, if your Network's tab is open in the browser developer tools, it's observed that there's no request initiated yet the Loading keeps running infinitely.

But if any one of the option is selected as shown below (and optionally immediately de-selected such that the screen looks like the previous one, as if the option was never selected)

and then the Execute button is hit, the request is actually made and also shows up in the Network monitor tab with a response being generated.

Expected behavior

The request should be initiated irrespective of the fact that an option is selected or not (provided it's not a required field).

Suggested Enhancement

It'll be a good idea to consider the default value from the OpenAPI spec and have the target value automatically selected.

@hkosova
Copy link
Collaborator

@hkosova hkosova commented Nov 16, 2020

The parameter definition does not look correct, try this instead:

      parameters:
      - name: parameter1
        in: query
        description: Dummy parameter
        schema:
          type: array
          items:
            type: string
            default: Active
            enum:
            - Active
            - Suspended
            - Deleted
@debargharoy
Copy link
Author

@debargharoy debargharoy commented Nov 17, 2020

That seems to work on Swagger Editor but I have class-level @Consumes set to application/json and application/xml.

I have the following piece of code at class-level

@javax.ws.rs.Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })

and I've tried using @Consumes at the method level which sets the content type to */* which again gives the invalid schema.

Any suggestions on how to unset it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.