Skip to content
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

Issue generating types remotely using Node v20 #62

Closed
kiikka opened this issue Sep 26, 2024 · 8 comments
Closed

Issue generating types remotely using Node v20 #62

kiikka opened this issue Sep 26, 2024 · 8 comments

Comments

@kiikka
Copy link

kiikka commented Sep 26, 2024

Hello!

I'm having an issue with generating types remotely using Node v20.

I've been running the following command.

openapi typegen http://localhost:8080/o/openapi-rest/v1.0/openapi.yaml > ./openapi.d.ts -H "Authorization: Basic xxxx"

This used to work still with Node v16, but after upgrading to v20 I get the following error.

ResolverError: Error downloading xxx socket hang up at /node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/http.js:127:16

Is there a need to modify my command or is it possible that the above mentioned library is deprecated for Node v20?

  • Aleksi
@anttiviljami
Copy link
Member

Very possible. Try upgrading it and see if it fixes the issue

@kiikka
Copy link
Author

kiikka commented Sep 26, 2024

I mean the library seems to be under openapicmd or the axios version should be updated

@anttiviljami
Copy link
Member

openapicmd is free and open source :) please execute ✅

@kiikka
Copy link
Author

kiikka commented Sep 27, 2024

I looked into this and it seems like the issue might be a dependencys dependency...

APIDevTools/swagger-parser#256

@anttiviljami
Copy link
Member

Nice job! 💪

@kiikka
Copy link
Author

kiikka commented Sep 30, 2024

After a bit of testing it turns out it is possibly an issue with Node v20 instead. I don't really know if its some setting that is required for it to work or should the http request in json-schema-ref-parser need to be adjusted for it to work.

Node v16 and Node v18 works still.

@kiikka
Copy link
Author

kiikka commented Sep 30, 2024

This ended up being a Node v20 / platform issue on our end.

For people interested: we are generating types from a local API and the URL to the API is along the lines of thing.local:8080/api where thing.local is mapped to 127.0.0.1.

This URL worked previously (Node v16) but after switching to Node v20 we had to change the URL for the command from
thing.local:8080/api to localhost:8080/api (127.0.0.1 worked as well).

I'm not sure if it's possible to add some host option to the command that would be set for the created connection to get the "custom" host work locally.

@kiikka kiikka closed this as completed Sep 30, 2024
@kiikka
Copy link
Author

kiikka commented Sep 30, 2024

Case closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants