readmeio / oas

Comprehensive tooling for working with OpenAPI definitions.
MIT License
278 stars 27 forks source link

Support for edge runtimes like cloudflare workers, vercel edge, deno etc #825

Open cosbgn opened 1 year ago

cosbgn commented 1 year ago

As a feature request, it would be amazing if this library could work on cloudflare workers, deno, vercel-edge, netlify-edge and other edge runtimes.

These runtimes are gaining a lot of popularity lately, but unfortunately can't be used with this library. I guess this is also due to dependancies like ajv, but there are some edge ready alternatives like @cfworker/json-schema.

Thanks for considering it.

erunion commented 1 year ago

I would love to support Edge runtimes! Do you have a solid way of detecting a package that doesn't support it?

cosbgn commented 1 year ago

Not really, I think the easiest is just to use wrangler dev locally and see if an error comes up.

So far I've learned that:

erunion commented 1 year ago

Do you have an example code snippet for oas that's not working with wrangler dev? Would be helpful to see and debug. I know we only use ajv in oas/reducer, which isn't exported from any main export, and only really exists in this repository because it's used in https://github.com/readmeio/rdme

cosbgn commented 1 year ago

This is the started wrangler which fails on npm run start: https://github.com/cosbgn/oas-edge

erunion commented 1 year ago

Ah gotcha, so its failing on oas-normalize likely then. Moving that off ajv is going to be a lot of work because we'll have to move @readme/openapi-parser and then rewrite @readme/better-ajv-errors as well. 😓

cosbgn commented 1 year ago

oas-normalize would be great as well, but it's failing also without it, only with oas check the new commit without normalize: https://github.com/cosbgn/oas-edge/blob/main/src/index.js

erunion commented 1 year ago

Woof, ok I see now.

Screen Shot 2023-10-24 at 1 27 22 PM