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(fromOpenApi): remove extra whitespace from content type #62

Merged
merged 6 commits into from
Aug 30, 2024

Conversation

Kiskae
Copy link
Contributor

@Kiskae Kiskae commented Aug 25, 2024

Fixes #61

@kettanaito kettanaito changed the title fix(fromOpenApi): remove extraneous whitespace from content types fix(fromOpenApi): remove extra whitespace from content type Aug 25, 2024
@@ -263,6 +257,14 @@ export function toBody(
return null
}

function getAcceptedContentTypes(request: Request): string[] {
Copy link
Member

Choose a reason for hiding this comment

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

Love this!

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

Thank you for jumping on this so fast, @Kiskae! The changes look great. The only thing that's missing is an automated test for this.

Feel free to explore and add one, otherwise I will try to add it later next week. Thank you!

@weyert
Copy link
Collaborator

weyert commented Aug 25, 2024

@Kiskae Thanks for taking care of this. Never thought of the whitespaces 🤗
Personally, barely ever pass multiple content-types to Accept

Copy link
Collaborator

@weyert weyert left a comment

Choose a reason for hiding this comment

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

LGTM

@Kiskae
Copy link
Contributor Author

Kiskae commented Aug 25, 2024

Thank you for jumping on this so fast, @Kiskae! The changes look great. The only thing that's missing is an automated test for this.

Feel free to explore and add one, otherwise I will try to add it later next week. Thank you!

Added some tests. After looking at the RFC I realized that there are more complex accept headers that aren't being handled, but solving that probably involves adding dependencies. So I've just added some skipped tests as a reminder that they exist.

Also made it so the automated tests in src actually get executed :P

@Kiskae Thanks for taking care of this. Never thought of the whitespaces 🤗 Personally, barely ever pass multiple content-types to Accept

Lets just say the reason I found this involves legacy applications and auto-generated openapi specs

@kettanaito
Copy link
Member

This looks fantastic! Thank you for adding the tests, @Kiskae!

I've polished the things a bit, mostly around test names and changing the getAcceptedContentTypes to accept just the Headers instance (it never needed anything else from the request). Made it easier to test too.

@kettanaito kettanaito merged commit 02157b5 into mswjs:main Aug 30, 2024
1 check passed
@Kiskae Kiskae deleted the fix_accept_header branch August 30, 2024 16:43
@kettanaito
Copy link
Member

Released: v0.3.1 🎉

This has been released in v0.3.1!

Make sure to always update to the latest version (npm i @mswjs/source@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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.

fromOpenApi mishandling Accept header
3 participants