swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Typescript enum generation fails with special characters

Open lew opened this issue 2 years ago • 3 comments

The following schema:

{
  "enum": ["&&", "||"],
  "type": "string"
}

is compiled to

export enum RuleChainingOperator {
  Type = '&&',
  Type = '||',
}

lew avatar Mar 18 '22 23:03 lew

Use the x-enumNames property.

{
  "enum": ["&&", "||"],
  "x-enumNames": ["AND", "OR"],
  "type": "string"
}

compiles to

export enum RuleChainingOperator {
  AND = '&&',
  OR = '||',
}

NimmLor avatar Jun 14 '22 08:06 NimmLor