Closed chrber04 closed 1 year ago
Hi @chrber04 these commands all work fine for me with the latest version of typegen.
$ typegen --version
6.1.4
$ typegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
# ...
export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
Are you on Windows?
Can you try with npx
:
npx openapi-client-axios-typegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
Or with specific version
npx openapi-client-axios-typegen@6.1.4 https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
Hello, same here. Tested on node v18 & v16.
$ npx openapi-client-axios-typegen@6.1.4 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:478
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:387:5)
at URL.onParseError (node:internal/url:565:9)
at new URL (node:internal/url:641:5)
at Object.resolve (<private>\node_modules\@anttiviljami\json-schema-ref-parser\lib\util\url.js:36:21)
at $RefParser.parse (<private>\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:103:19)
at $RefParser.resolve (<private>\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:184:16)
at $RefParser.dereference (<private>\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:268:16)
at Function.dereference (<private>\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:250:31)
at OpenAPIClientAxios.<anonymous> (<private>\node_modules\openapi-client-axios-typegen\node_modules\openapi-client-axios\client.js:163:79)
at step (<private>\node_modules\openapi-client-axios-typegen\node_modules\openapi-client-axios\client.js:44:23) {
input: '',
code: 'ERR_INVALID_URL'
}
Also, I'm on Windows :)
Fixed the problem on a fork. https://github.com/adrien-powder/json-schema-ref-parser/commit/494bb14d47873b3245e4379777de29fa522aa81c
The problem still persists for me.
I've replaced SwaggerParser with a much simpler implementation of dereference-json-schema
openapi-client-axios@>=7.0.0
should be much simpler to build for React Native and browser without the need for polyfills. 🙌
@BoldizsarP @chrber04 @adrien-powder
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!
Property | Value |
---|---|
Operating System | Windows 11 |
Node Version | 18.15.0 |
openapi-client-axios-typegen version | 7.1.3 |
Running the following two commands results in an error (shown below):
npm install openapi-client-axios-typegen@7.1.3 -g -y
typegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
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 URL
class from Node itself... Perhaps not an issue, but rather a misuse of it (I'm still digging into this myself)?
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: https://github.com/APIDevTools/json-schema-ref-parser/issues/311
problem still exists. any updates?
https://github.com/adrien-powder/json-schema-ref-parser/commit/494bb14d47873b3245e4379777de29fa522aa81c -> worked for me
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!