openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Generated type for an enum in a schema with single quote does not escape properly

Open esfox opened this issue 1 year ago • 0 comments

Description

Single quotes in an enum in a schema do not escape properly so it breaks the generated type.

Expected

export type SomeRequest = {
  category: 'Category A' | 'Category B' | 'Category C';
  withSingleQuote: 'Yes' | 'No' | "Don't Know";
}

Actual

export type SomeRequest = {
  category: 'Category A' | 'Category B' | 'Category C';
  withSingleQuote: 'Yes' | 'No' | 'Don't Know';
}

Reproducible example or configuration

No response

OpenAPI specification (optional)

components:
  schemas:
    ...
      SomeRequest:
        type: object
        properties:
          category:
            type: string
            enum:
              - Category A
              - Category B
              - Category C
          withSingleQuote:
            type: string
            enum:
              - Yes
              - No
              - Don't Know

System information (optional)

No response

esfox avatar Oct 09 '24 01:10 esfox