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

Not using upstream for json-schema-ref-parser #153

Closed JoshuaTheMiller closed 1 year ago

JoshuaTheMiller commented 1 year ago

If appears that typegen is using an older version of a different project of yours: https://github.com/anttiviljami/openapi-client-axios/blob/master/packages/typegen/package.json#L49

If this reference is updated and the associated issues are resolved (the major version increase contains some breaking changes), the issue should be fixed (though I am not sure what others issues may arise yet).

Further explanation

When attempting to run the following command, I get an error:

command

npx --yes -p openapi-client-axios-typegen@7.1.3 typegen ./openapi.yaml

error

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: '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:\Users\joshu\AppData\Local\npm-cache\_npx\75ab93ae90256a76\node_modules\@anttiviljami\json-schema-ref-parser\lib\util\url.js:36:21)
    at $RefParser.parse (C:\Users\joshu\AppData\Local\npm-cache\_npx\75ab93ae90256a76\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:103:19)
    at Function.parse (C:\Users\joshu\AppData\Local\npm-cache\_npx\75ab93ae90256a76\node_modules\@anttiviljami\json-schema-ref-parser\lib\index.js:63:25)
    at OpenAPIClientAxios.<anonymous> (C:\Users\joshu\AppData\Local\npm-cache\_npx\75ab93ae90256a76\node_modules\openapi-client-axios\client.js:684:79)
    at step (C:\Users\joshu\AppData\Local\npm-cache\_npx\75ab93ae90256a76\node_modules\openapi-client-axios\client.js:44:23)
    at Object.next (C:\Users\joshu\AppData\Local\npm-cache\_npx\75ab93ae90256a76\node_modules\openapi-client-axios\client.js:25:53)
    at C:\Users\joshu\AppData\Local\npm-cache\_npx\75ab93ae90256a76\node_modules\openapi-client-axios\client.js:19:71 {
  input: './openapi.yaml',
  code: 'ERR_INVALID_URL'
}

Reference: https://github.com/anttiviljami/openapi-client-axios/blob/master/packages/typegen/package-lock.json#L68-L81

Tangent

I personally prefer not to commit the package-lock file to the repo. Instead, I like to include it in the final "built" version of the package that is pushed to npmjs.org. Perhaps this strategy could be leveraged as it could mitigate such issues going forward.

JoshuaTheMiller commented 1 year ago

You're the best! Thanks @anttiviljami