-
-
Notifications
You must be signed in to change notification settings - Fork 68
typegen Invalid URL error #145
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
Comments
Hi @chrber04 these commands all work fine for me with the latest version of typegen.
Are you on Windows? Can you try with
Or with specific version
|
Hello, same here. Tested on node v18 & v16.
Also, I'm on Windows :) |
Fixed the problem on a fork. adrien-powder/json-schema-ref-parser@494bb14 |
The problem still persists for me. |
I've replaced SwaggerParser with a much simpler implementation of
|
I am facing the same problem, was it fixed? |
Hey @anttiviljami! This problem seems to still be occurring, or perhaps it is simply operator error on my part 🤔 Either way it looks like a few folks would appreciate some solution around this still! Details
TestRunning the following two commands results in an error (shown below):
PS F:\Cloud Storage\SourceControl\sync-bot-ts> typegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
DeprecationWarning: 'createInterfaceDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createTypeAliasDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createModuleDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
node:internal/errors:490
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:399:5)
at URL.onParseError (node:internal/url:566:9)
at new URL (node:internal/url:646:5)
at Object.resolve (C:\ProgramData\nvm\v18.15.0\node_modules\openapi-client-axios-typegen\node_modules\@anttiviljami\json-schema-ref-parser\lib\util\url.js:36:21)
at $RefParser.parse (C:\ProgramData\nvm\v18.15.0\node_modules\openapi-client-axios-typegen\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:103:19)
at $RefParser.resolve (C:\ProgramData\nvm\v18.15.0\node_modules\openapi-client-axios-typegen\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:184:16)
at $RefParser.dereference (C:\ProgramData\nvm\v18.15.0\node_modules\openapi-client-axios-typegen\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:268:16)
at Function.dereference (C:\ProgramData\nvm\v18.15.0\node_modules\openapi-client-axios-typegen\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:250:31)
at OpenAPIClientAxios.<anonymous> (C:\ProgramData\nvm\v18.15.0\node_modules\openapi-client-axios-typegen\node_modules\openapi-client-axios\client.js:163:79)
at step (C:\ProgramData\nvm\v18.15.0\node_modules\openapi-client-axios-typegen\node_modules\openapi-client-axios\client.js:44:23) {
input: '',
code: 'ERR_INVALID_URL'
}
Node.js v18.15.0 |
Ah. this actually seems to be a problem with the underlying For example, simply running the following snippet on Windows fails: const to = "./openapi.yaml";
const fromPath = "C:\\";
let resolvedUrl = new URL(to, new URL(fromPath, "resolve://"));
console.log(resolvedUrl) |
Wrapping the following block of code (which I believe is from this library) "fixed" the problem: This Issue could be related: APIDevTools/json-schema-ref-parser#311 |
problem still exists. any updates? adrien-powder/json-schema-ref-parser@494bb14 |
Hi, I've been trying to get typegen to work for a while now but I constantly get this error:
I installed typegen by running npm
install -g openapi-client-axios-typegen
And I've tried multiple variations of running typegen, with a local file and the remote URL in the README.md documentation. So:
typegen ./openapi.yml
typegen ./openapi.yml > client.d.ts
typegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
typegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml > client.d.ts
They all give me the same exact "[ERR_INVALID_URL]" error. Am I doing something wrong?
Thanks!
The text was updated successfully, but these errors were encountered: