-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
OpenAPI: Browser support without polyfills #49
Comments
Yeah, I think that's a good idea. I am wondering if we could leverage a package like @stoplight/http-spec. They also have a fork of @apidevtools/json-schema-ref-parser which appears to work in the browser but I am not sure if they use poly fills for it (probably?). I think we might able to use this |
Thanks for opening this, @tjosepo. I would love to see Source working in the browser for OpenAPI. Our best approach here is to find packages that can provide us with parsing while not relying on Node.js native modules. @weyert, |
@kettanaito @tjosepo @weyert I believe a better solution would be to provide an initialization command that generates the JSON string for the |
@VobileLiuZhiwu OpenAPI specifications can have circular references, but JSON strings do not support circular references. Because of this, I don't think this approach is suitable. :/ |
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. |
Description
The function
fromOpenApi
currently doesn't work on the browser without a lot of Node.js polyfills.node:http
.path
,fs
,http
andhttps
modules. It also referencesprocess.cwd
.Solution
For open-api-utils.ts, inlining the
STATUS_CODE
variable is easy enough.For @apidevtools/json-schema-ref-parser, since it is the ubiquitous library used for JSON Schema dereferencing in Node, it may not make sense to replace it in Node. We could create a separate package entrypoint for the browser that prebundles the Node.js modules or replaces the library with web-compatible alternative (that may not support all features of JSON Schema dereferencing, but works for the web.)
Alternatives
@apidevtools
folks. Make the change there.The text was updated successfully, but these errors were encountered: