Skip to content

Codegen OpenAPI: negative numbers cause error #4455

Closed

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions