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

fix #5976: set content-type on openapi3 imports #5982

Merged

Conversation

filfreire
Copy link
Member

@filfreire filfreire commented May 19, 2023

Closes #5976

Related to similar past change - #5812

If mime type is set for bodies in the OpenAPI imported spec, we now set the content-type on the generated requests as well.

changelog(Fixes): Added a fix to help set Content-Type header when importing requests from OpenAPI 3 specs of which the mime-type was already specified

Comment on lines 293 to 307
header => header.name === 'Content-Type',
);

// @ts-expect-error -- ??
if (body && body.mimeType && noContentTypeHeader) {
paramHeaders = [
{
name: 'Content-Type',
disabled: false,
// @ts-expect-error -- ??
value: body.mimeType,
},
...paramHeaders,
];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it doesn't appear to mutate the body, would it make sense for this logic to belong inside prepareHeaders()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me - moved it inside to prepareHeaders 👍

@filfreire filfreire force-pushed the fix/issue-5976-set-contenttype-oa3-import branch from 3e55ee8 to c6a40c3 Compare May 22, 2023 14:50
@filfreire filfreire added this pull request to the merge queue May 23, 2023
Merged via the queue into Kong:develop with commit 7b74188 May 23, 2023
9 checks passed
@filfreire filfreire deleted the fix/issue-5976-set-contenttype-oa3-import branch May 23, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing an OpenAPI v3 spec does not set Content-Type for json requests
2 participants