openapistack / openapi-client-axios

JavaScript client library for consuming OpenAPI-enabled APIs with axios
https://openapistack.co
MIT License
535 stars 67 forks source link

Issue persist when trying to run with react native #146

Closed FranDepascuali closed 1 year ago

FranDepascuali commented 1 year ago

Thank you @anttiviljami for fixing the previous issue #140 I reported!

When I try, I still have errors regarding dependencies not supported in our node.js runtime due to json-schema-ref-parser.

imagen

Thank you! Depa

anttiviljami commented 1 year ago

Hi @FranDepascuali, you’ll still need to add the required polyfills in your build config. Take a look at the README for examples:

https://github.com/anttiviljami/openapi-client-axios#browser-usage

FranDepascuali commented 1 year ago

It's really difficult to add a polyfill in react-native like that as it doesn't use a webpack setup.

Been reading into https://github.com/philikon/ReactNativify and https://github.com/tradle/rn-nodeify but it sounds pretty complicated.

I will tell you if I had any luck.

Thanks!

anttiviljami commented 1 year ago

This seems like a straightforward solution for rn. https://stackoverflow.com/a/41511414

There might be other polyfills you need too like util IIRC

FranDepascuali commented 1 year ago

Tried that lib

image
FranDepascuali commented 1 year ago

Update: I tried every possible way I could, using different polyfill implementation.

I couldn't make it work, there's always strange runtime errors when polyfilling.

I tried other alternatives to generate a typescript axios client (gonna list them later). They work BUT this lib has two important aspects:

  1. Is used by our company frontend's, meaning that we have easier code reuse
  2. I really like the types paths objects. That would also allow to do type safe axios mocking via interceptors. Plus it provides better communication with the backend team. I couldn't find that typed paths property dictionary in other packages.

This lib seems awesome. I'll try other versions in the future to see if the errors change or it's available for us with react native.

Thanks you very much @anttiviljami !!

Depa

anttiviljami commented 1 year ago

Hi @FranDepascuali. The issues come from the json-schema-ref-parser dependency used by this library.

Unfortunately this lib is no longer really maintained and causes multiple issues for us, including a bloated bundle size and difficulty in non Node.js environments.

I’ve asked my team at @epilot-dev to take a look at replacing with a simpler, more compatible implementation. A lot of the features from json-schema-ref-parser are not really necessary for openapi-client-axios