-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(fromOpenApi): add browser support #51
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
import { pointerToPath } from '@stoplight/json' | ||
|
||
/** | ||
* TODO: Support remote references. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for a first iteration. Remote reference can also easily open a can of worms, e.g. from which relative path would it load the remote files etc?
I tested my changes on Chrome using a small OpenAPI spec. It worked. Didn't try it with |
I think this because in Vitest you typically try to use the Node version instead of the browser version needed for |
I've added a simple browser test using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is absolutely incredible! Thank you for your work on this, @tjosepo 👏
500e899
to
4c12ee5
Compare
9d59e52
to
9f7b6fa
Compare
Awesome great work! 🚀 |
Released: v0.3.0 🎉This has been released in v0.3.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Closes #49
Changes
import { STATUS_CODES } from 'node:http'
withimport { STATUS_CODES } from './status-codes.js'
, this way, we don't depend on Node internals.@apidevtools/swagger-parser
with a custom JSON Schema dereferencing function that works on the browser@stoplight/json
directly was simpler. With a bit of recursion, the dereferencing algorithm really wasn't that bad.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.