Skip to content

Commit c20bca6

Browse files
author
Lionel Schiepers
committed
Don't set the content-type when there is no payload
The HTTP Get operation actually set a content-type of 'application/json' when there is no payload. The request adds a content-length of 0 because there is no payload. Web server like https://github.com/stoplightio/prism (mock of openapi) reject the calls because the content-type has nothing to do with GET operations. Exemple: GET http://127.0.0.1:4010/RESTMethod HTTP/1.1 content-type: application/json accept: application/json host: 127.0.0.1:4010 content-length: 0 Connection: close
1 parent 0c12ebf commit c20bca6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/openapi-to-graphql/src/resolver_builder.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,14 @@ export function getResolver({
446446
*
447447
* NOTE: This may cause the user to encounter unexpected changes
448448
*/
449-
headers['content-type'] =
450-
typeof operation.payloadContentType !== 'undefined'
451-
? operation.payloadContentType
452-
: 'application/json'
449+
if (operation.payloadRequired)
450+
{
451+
headers['content-type'] =
452+
typeof operation.payloadContentType !== 'undefined'
453+
? operation.payloadContentType
454+
: 'application/json'
455+
}
456+
453457
headers['accept'] =
454458
typeof operation.responseContentType !== 'undefined'
455459
? operation.responseContentType

0 commit comments

Comments
 (0)