mswjs / source

Generate MSW request handlers from various sources (HAR files, OpenAPI documents, etc).
https://source.mswjs.io
134 stars 5 forks source link

fix(fromOpenApi): remove extra whitespace from content type #62

Closed Kiskae closed 2 weeks ago

Kiskae commented 3 weeks ago

Fixes #61

weyert commented 3 weeks ago

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

Kiskae commented 3 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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.