-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Can't disable optional query parameter when using allowEmptyValue: true #4122
Description
| Q | A |
|---|---|
| Bug or feature request? | Bug |
| Which Swagger/OpenAPI version? | OpenAPI 3.0.0 |
| Which Swagger-UI version? | 3.X, 3.5.0, 3.6.0 |
| How did you install Swagger-UI? | tried online editor and locally with webserver |
| Which browser & version? | Chrome |
| Which operating system? | Windows |
Demonstration API definition
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
- name: active
in: query
description: filter
required: false
allowEmptyValue: true
schema:
type: string
responses:
204:
description: OKExpected Behavior
I'd like to be able to choose if the optional query parameter active is sent or not.
I want to use the query parameter as filter without a value.
If enabled , the URL should look like this:
"http://petstore.swagger.io/v1/pets/{id}?active"
or
"http://petstore.swagger.io/v1/pets/{id}?active="
(Would be nicer without without the "=")
If disabled, the URL should look like this:
"http://petstore.swagger.io/v1/pets/{id}"
Current Behavior
Currently when I set 'allowEmptyValue: true', I can't choose whether I want to send the query parameter.
The URL always looks like this:
"http://petstore.swagger.io/v1/pets/{id}?active="
Possible Solution
A checkbox or another solution to choose whether to send the optional query parameter or not to send the query parameter