-
Notifications
You must be signed in to change notification settings - Fork 764
Closed
Milestone
Description
From @shockey on April 25, 2018 5:27
- patch the
requestContentTypelogic to always apply, regardless of the presence of a body/form value... because we should trust that the user knows what they want. - add an
attachContentTypeForEmptyPayloadoption (that can be leveraged through the constructor, buildRequest/execute, and the tags interface), which sets the Content-Type whenever a body/formData parameter/request body is defined, regardless of the provided content or lack thereof.
Demonstration
const spec = {
"swagger": "2.0",
"info": {},
"host": "petstore.swagger.io",
"basePath": "/v2",
"schemes": ["http"],
"consumes": ["application/json"],
"paths": {
"/": {
"post": {
"operationId": "myOp",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"type": "object"
}
}
]
}
}
}
}
const req1 = SwaggerClient.buildRequest({
spec,
pathName: "/",
method: "post",
operationId: "myOp",
requestContentType: "application/x-custom",
parameters: {
body: null
}
})
const req2 = SwaggerClient.buildRequest({
spec,
pathName: "/",
method: "post",
operationId: "myOp",
attachContentTypeForEmptyPayload: true,
parameters: {
body: null
}
})Expected behavior
req1.headers === { "Content-Type": "application/x-custom" }
req2.headers === { "Content-Type": "application/json" }Current behavior
req1.headers === {}
req2.headers === {}Originally reported by @fehguy over email
Copied from original issue: swagger-api/swagger-ui#4475
fehguy
Metadata
Metadata
Assignees
Labels
No labels