Skip to content

Is it possible to generate real enums? #71

@TomDeSmet

Description

@TomDeSmet

Hi,

Is it possible to generate real TypeScript enums from an OpenAPI spec that has:

type:
    myProperty: string
    enum:
      - A
      - B
      - C

Now it generates a union type myProperty: "A" | "B" | "C"

However, I want something like:

myProperty: MyEnum

const enum MyEnum {
    A = 'A',
    B = 'B',
    C = 'C'
}

Or possibly:

const MyEnum {
    A: 'A',
    B: 'B',
    C: 'C'
} as const;
type MyEnum = typeof MyEnum[keyof typeof MyEnum];

Metadata

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