acacode / swagger-typescript-api

Generate the API Client for Fetch or Axios from an OpenAPI Specification
MIT License
3.38k stars 361 forks source link

[Bug] 12.0.4 Parser option --extract-enums fails to generate with prettier linting error to generate #907

Open MiracleUFO opened 2 months ago

MiracleUFO commented 2 months ago

Command: npx swagger-typescript-api@12.0.4 -p .dev-helper/openapi.yml -o $target_folder -n index.ts --union-enums --extract-enums

Generating types with options --union-enums --extract-enums throws this error and TS file is not generated for a specific openapi.yml file. I cannot remove--extract-enums as it's part of our configuration for the whole app.

I believe a terminating semicolon is not added by swagger-typescript-api@12.0.4 causing this error to be thrown it attempts when format with prettier:

SyntaxError: ';' expected. (1604:10)
  1602 |  * @example "payout_interest"
  1603 |  */
> 1604 |   export type DepositInterestTreatment = "capitalize_interest" | "payout_interest"
       |          ^
  1605 |
  1606 |   /**
  1607 |  * Current state of the deposit.
    at Ve (~/.npm/_npx/40e7642a532d5314/node_modules/prettier/parser-typescript.js:1:15607)
    at vz (~/.npm/_npx/40e7642a532d5314/node_modules/prettier/parser-typescript.js:280:5919)
    at Object.yz [as parse] ~/.npm/_npx/40e7642a532d5314/node_modules/prettier/parser-typescript.js:280:6242)
MiracleUFO commented 2 months ago

Related to Issue

I do not want to upgrade to ^13.0.0 because when I used it last I got a circular dependency error and had to downgrade.