swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Unnecessary -d '' in CURL when no request body

Open vbulash opened this issue 10 months ago • 0 comments

My OpenApi 3.0 yml opened on HTML page with swagger-ui-dist 5.11.0. In one endpoint where request body absent, Execute run request and produces the following output:

curl -X 'POST' \
  'http://localhost:84/query?org=influx&pretty=true&db=influx&q=select%20%2A%20from%20connection' \
  -H 'accept: application/json' \
  -H 'Authorization: Token my_token' \
  -d ''

Execute ends with errors. The only valid form here without -d:

curl -X 'POST' \
  'http://localhost:84/query?org=influx&pretty=true&db=influx&q=select%20%2A%20from%20connection' \
  -H 'accept: application/json' \
  -H 'Authorization: Token my_token'

Here in sources I found that swagger-api adds -d '' for POST requests with no request body. Seems has no sense. 99.9% servers just ignore such case (empty but present data in CURL when no request body). But I faced with 0.01% where it has sense. Is it possible to drop -d '' at all when no request body in POST-request?

vbulash avatar Apr 06 '24 06:04 vbulash