I'm trying to POST form data using Swagger UI, but the request is sent with Content-Type: undefined:

How can I configure it so it works? JSON POST works just fine.
Here is my API definition:
{
"swagger": "2.0",
"info": {
"version": "V1",
"title": "Title"
},
"paths": {
"/api/getcalculation": {
"post": {
"tags": [
"ArrearsOfPay"
],
"operationId": "ApiArrearsOfPayPost",
"consumes": [],
"produces": [
"application/json"
],
"parameters": [
{
"name": "InsolvencyDate",
"in": "formData",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "DismissalDate",
"in": "formData",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "UnpaidPeriodFrom",
"in": "formData",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "UnpaidPeriodTo",
"in": "formData",
"required": false,
"type": "string",
"format": "date-time"
},
{
"name": "ApClaimAmount",
"in": "formData",
"required": false,
"type": "number",
"format": "double"
},
{
"name": "PayDay",
"in": "formData",
"required": false,
"type": "integer",
"format": "int32"
},
{
"name": "ShifPattern",
"in": "formData",
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
},
{
"name": "WeeklyWage",
"in": "formData",
"required": false,
"type": "number",
"format": "double"
},
{
"name": "StatutaryMax",
"in": "formData",
"required": false,
"type": "number",
"format": "double"
},
{
"name": "NumberOfDaysWorkedInWeek",
"in": "formData",
"required": false,
"type": "integer",
"format": "int32"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/ArrearsOfPayCalculationResponseModel"
}
}
}
}
}
},
"definitions": {
"ArrearsOfPayCalculationResponseModel": {
"type": "object",
"properties": {
"startOfPayWeek": {
"format": "date-time",
"type": "string"
},
"maximumLiability": {
"format": "double",
"type": "number"
},
"employerLiability": {
"format": "double",
"type": "number"
},
"minimumLiability": {
"format": "double",
"type": "number"
}
}
}
}
}
The problem is here:
"consumes": []
The consumes keyword specifies the Content-Type header in requests. Since you are POSTing form data, it should be:
"consumes": ["application/x-www-form-urlencoded"]
Tip: You can paste your spec into http://editor.swagger.io to check for syntax errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With