Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't set the content-type when there is no payload #325

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/openapi-to-graphql/src/resolver_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,18 @@ export function getResolver({
*
* NOTE: This may cause the user to encounter unexpected changes
*/
headers['content-type'] =
typeof operation.payloadContentType !== 'undefined'
? operation.payloadContentType
: 'application/json'
if (operation.method !== 'get')
{
/**
* the check is done on the 'get' operation to determine if there is a payload because
* operation.payloadRequired is not always correctly initialized (at least during the unit test)
*/
headers['content-type'] =
typeof operation.payloadContentType !== 'undefined'
? operation.payloadContentType
: 'application/json'
}

headers['accept'] =
typeof operation.responseContentType !== 'undefined'
? operation.responseContentType
Expand Down