mswjs / source

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

feat(fromOpenApi): add browser support #51

Closed tjosepo closed 3 weeks ago

tjosepo commented 2 months ago

Closes #49

Changes

[!CAUTION] The custom dereferencing function doesn't support remote references.

Only local references are currently supported. I think it's best this way, since figuring out how to support remote references in a way that works on both Node.js and the browser will require more time. Restricting the input while we figure it out seems best.

tjosepo commented 1 month ago

I think it's a great start to get it working in the browser. Only it doesn't appear to work when using @vitest/browser for me but appears to be related to mswjs itself. Need to play around a bit with that.

I tested my changes on Chrome using a small OpenAPI spec. It worked. Didn't try it with @vitest/browser.

weyert commented 1 month ago

I think it's a great start to get it working in the browser. Only it doesn't appear to work when using @vitest/browser for me but appears to be related to mswjs itself. Need to play around a bit with that.

I tested my changes on Chrome using a small OpenAPI spec. It worked. Didn't try it with @vitest/browser.

I think this because in Vitest you typically try to use the Node version instead of the browser version needed for @vitest/browser. At least for me it's try to look for mswjs/node

kettanaito commented 3 weeks ago

I've added a simple browser test using @vitest/browser. It passes locally 🎉

weyert commented 3 weeks ago

Awesome great work! 🚀

kettanaito commented 3 weeks ago

Released: v0.3.0 🎉

This has been released in v0.3.0!

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.