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

Issue with negative numbers in API spec #182

Open
dnlgrgly opened this issue Apr 29, 2024 · 0 comments
Open

Issue with negative numbers in API spec #182

dnlgrgly opened this issue Apr 29, 2024 · 0 comments

Comments

@dnlgrgly
Copy link

dnlgrgly commented Apr 29, 2024

Hello! 👋
When trying to run npx openapicmd typegen, I receive the following error:

npx openapicmd typegen <path>
Error: Debug Failure. False expression: Negative numbers should be created in combination with createPrefixUnaryExpression
    at Object.createNumericLiteral (~/.npm/_npx/fb2ea8e0e5441457/node_modules/typescript/lib/typescript.js:21094:13)
    at Object.buildNumericLiteralTypeNode (~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/astBuilder.js:56:56)
    at DtsGenerator.generateLiteralTypeNode (~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:312:28)
    at ~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:279:29
    at Array.map (<anonymous>)
    at Object.buildUnionTypeNode (~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/astBuilder.js:124:55)
    at DtsGenerator.generateLiteralTypeProperty (~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:278:24)
    at DtsGenerator.generateTypeProperty (~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:273:21)
    at DtsGenerator.generateProperties (~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:244:84)
    at DtsGenerator.generateTypeName (~/.npm/_npx/fb2ea8e0e5441457/node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:449:35)

This seems to happen because the schema I'm trying to generate the types for contains some negative numbers, eg:

Coordinates:
  title: Coordinates
  type: object
  properties:
    latitude:
      type: number
      format: double
      example: 37.751
      minimum: -90
      maximum: 90
    longitude:
      type: number
      format: double
      example: -97.822
      minimum: -180
      maximum: 180
  required:
    - latitude
    - longitude

I checked the docs of the OpenAPI specs and this doesn't seem to be a real constraint of the specs themselves.

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

1 participant