Forum Discussion

deian40's avatar
deian40
New Member
5 years ago

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.