cancel
Showing results for 
Search instead for 
Did you mean: 

parameter still generated even if empty in openapi: 3.0.1

New Member

parameter still generated even if empty in openapi: 3.0.1

Hello,

i have an issues with is with generating an empty parameter when using openapi: 3.0.1.

 

so here are 2 snipets (you can directly copy paste them in https://editor.swagger.io/)

swagger: '2.0':

swagger: '2.0'
info:
  title: t
  version: '1'
paths:
  /login:
    post:
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - name: test
          type: string
          in: formData
      responses:
        '200':
          description: OK

when you hit try it out - > execute with empty test field it generates curl:

curl -X POST "https://editor.swagger.io/login" -H "accept: application/json"

and if you pass parameter test for example:

curl -X POST "https://editor.swagger.io/login" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "test=test"

 

and for second snipets:

openapi: 3.0.1

openapi: 3.0.1
info:
  title: t
  version: "1"
servers:
- url: /
paths:
  /login:
    post:
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                test:
                  type: string
      responses:
        200:
          description: OK
          content: {}
components: {}

when you hit try it out - > execute with empty test field it generates curl:

curl -X POST "https://editor.swagger.io/login" -H "accept: */*" -H "Content-Type: application/x-www-form-urlencoded" -d "test="

and if you pass parameter test for example:

curl -X POST "https://editor.swagger.io/login" -H "accept: */*" -H "Content-Type: application/x-www-form-urlencoded" -d "test=test"

 

so my question is can the generation of '-d "test="' be skipped when the paramer is empty like for version swagger: '2.0'

 

Regards.

1 REPLY 1
Moderator

Re: parameter still generated even if empty in openapi: 3.0.1

Hi @deian40,

 

There's an existing enhancement request to omit empty form parameters in OAS3 definitions:

https://github.com/swagger-api/swagger-ui/issues/5303

 

Please follow that discussion for status updates.


Helen Kosova
SmartBear Technical Writer
________________________
Join the annual community event and share your stories to win gifts
Wintertainment2019