- Make a
POST request which includes body data, but does not include a content-type header.
api2swagger -X POST -e https://api.github.com -o ./testSwagger.json -d '{\"test\":\"test\"}'
- Note that the outputted Swagger file has an invalid schema in the parameters section:
"parameters": [
{
"in": "body",
"name": "body",
"description": "Request Payload Body",
"required": true,
"schema": "'{\"test\":\"test\"}'"
}
]
Several errors are also displayed in the Swagger Editor when pasting in the schema.
When the content-type header is included in the request, the section looks like:
{
"name": "body",
"in": "body",
"schema": {
"description": "",
"type": "object",
"properties": {
"test": {
"type": "string",
"minLength": 1
}
},
"required": [
"test"
]
},
"description": "",
"required": true
}
Api2Swagger should handle the case when a content-type header is not provided along with a request body by either:
- Ignoring the request body
- Displaying an error message
- Assuming a content-type of
application/json and trying to parse the request body. This follows Swagger's behavior of assuming application/json when no media type is provided in the produces or consumes section.
POSTrequest which includes body data, but does not include acontent-typeheader.api2swagger -X POST -e https://api.github.com -o ./testSwagger.json -d '{\"test\":\"test\"}'Several errors are also displayed in the Swagger Editor when pasting in the schema.
When the
content-typeheader is included in the request, the section looks like:Api2Swagger should handle the case when a content-type header is not provided along with a request body by either:
application/jsonand trying to parse the request body. This follows Swagger's behavior of assumingapplication/jsonwhen no media type is provided in the produces or consumes section.