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

Codegen OpenAPI: negative numbers cause error #4455

Closed
Innders opened this issue Jun 13, 2024 · 4 comments
Closed

Codegen OpenAPI: negative numbers cause error #4455

Innders opened this issue Jun 13, 2024 · 4 comments

Comments

@Innders
Copy link

Innders commented Jun 13, 2024

When I try to run npx @rtk-query/codegen-openapi openapi-config.ts I get the error:

Error: Debug Failure. False expression: Negative numbers should be created in combination with createPrefixUnaryExpression
    at Object.createNumericLiteral (/path/to/project/node_modules/typescript/lib/typescript.js:21094:13)
    at createLiteral (/path/to/project/node_modules/oazapfts/src/codegen/tscodegen.ts:42:22)
    at /path/to/project/node_modules/oazapfts/src/codegen/tscodegen.ts:50:39
    at Array.map (<anonymous>)
    at Object.createEnumTypeNode (/path/to/project/node_modules/oazapfts/src/codegen/tscodegen.ts:47:24)
    at ApiGenerator.getBaseTypeFromSchema (/path/to/project/node_modules/oazapfts/src/codegen/generate.ts:689:14)
    at ApiGenerator.getTypeFromSchema (/path/to/project/node_modules/oazapfts/src/codegen/generate.ts:563:23)
    at ApiGenerator.getRefAlias (/path/to/project/node_modules/oazapfts/src/codegen/generate.ts:432:25)
    at ApiGenerator.getBaseTypeFromSchema (/path/to/project/node_modules/oazapfts/src/codegen/generate.ts:580:19)
    at ApiGenerator.getTypeFromSchema (/path/to/project/node_modules/oazapfts/src/codegen/generate.ts:563:23)

openapi-config.ts

const config: ConfigFile = {
  schemaFile: 'https://ayon.dev/openapi.json',
  apiFile: './src/services/ayon.ts',
  apiImport: 'RestAPI',
  outputFile: './src/services/ayonRestTypes.ts',
  exportName: 'ayonRestApi',
}

If I exclude a specific endpoint filterEndpoints: [/^(?!.*sitesync).*$/i] then I don't get this error and everything is great.

The endpoint has a negative enum value (-1) and I believe this is the cause of the error.
image

I found a similar issue report for this negative number error here (not sure how related it is): hey-api/openapi-ts#466 (comment)

It doesn't look like openapi-ts is being used but maybe this is still helpful.

@yamilelias
Copy link

This is related to an issue from oazapfts dependency.

They already solved it, and it is available on v6.0.6. However, the dependency is on version v4.8.0. So, there's a need to update the dependency.

There's already a PR to update it, but it seems that no one is taking care of it.

@Innders
Copy link
Author

Innders commented Jun 14, 2024

Oh sorry I missed the PR, thanks! At least this issue might come up in a google search now for someone like me....

@Innders Innders closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2024
@markerikson
Copy link
Collaborator

Should be live in /~https://github.com/reduxjs/redux-toolkit/releases/tag/%40rtk-query%2Fcodegen-openapi%402.0.0-alpha.0 ! Please try it out and let us know if it works.

@Innders
Copy link
Author

Innders commented Aug 31, 2024

Please try it out and let us know if it works.

I can confirm that this fixes the issue! Thanks 💯

image

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

3 participants