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

Empty selection (`--') of query parameter with array of enum #9266

Closed
zorba128 opened this issue Sep 29, 2023 · 3 comments
Closed

Empty selection (`--') of query parameter with array of enum #9266

zorba128 opened this issue Sep 29, 2023 · 3 comments

Comments

@zorba128
Copy link

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
paths:
  /getdata
    get:
      parameters:
      - name: user_id
        in: query
        required: false
        schema:
          type: integer
          format: int64
      - name: state
        in: query
        required: false
        schema:
          type: array
          items:
            $ref: '#/components/schemas/State'
        example:
        - STARTED

components:
  schemas:
    State:
      type: string
      enum:
      - STARTED
      - SUBMITTED
      - RESUBMISSION
      - APPROVED
      - DECLINED
      - EXPIRED

Describe the bug you're encountering

Endpoint as uses optional state query string parameter to pick only matching values. Its optional, as I want to allow unfiltered result also. Rendered UI looks like
image

Everything works fine, except -- option - which causes problems.
With -- selected I get request like:
https://localhost/api/v1/getdata?state=

Valid requests are:
https://localhost/api/v1/getdata?state=STARTED&state=SUBMITTED
https://localhost/api/v1/getdata

It is possible to generate valid request by unselecting all the entries, but then the -- option is misleading.
I see two options to fix that:

  • get rid of -- from the selection box; user can generate request with no filter - by manually unselecting all the list items
  • keep --, but give it special handling:
    • do not render it as query parameter
    • and have simple behavior that 'selecting -- should deselect all other entries'
@zorba128
Copy link
Author

Also with

        in: query
        required: false
        explode: false

its even worse - I'm unable to send request with no value listed.

@char0n
Copy link
Member

char0n commented Feb 15, 2024

Hi @zorba128,

You need to use allowEmptyValue Parameter Object field.

        in: query
        required: false
        explode: false
        allowEmptyValue: true

@char0n
Copy link
Member

char0n commented Feb 15, 2024

Closing as duplicated of #5176

@char0n char0n closed this as completed Feb 15, 2024
glowcloud added a commit that referenced this issue Feb 15, 2024
Refs #9266 
Refs #5176 

Co-authored-by: Julien Bourges <julien.bourges@actility.com>
Co-authored-by: Oliwia Rogala <oliwia.rogala@smartbear.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants