rametta / rapini

:leafy_green: OpenAPI to React Query (or SWR) & Axios
Apache License 2.0
152 stars 18 forks source link

Export union types as objects #16

Closed ghandic closed 3 weeks ago

ghandic commented 2 years ago

When generating enums, it would be good to centralise the options for use in select menus etc

When enums are produced at the moment it creates:

export type Payment = 'Debit' | 'Credit';

Preferentially it could be

export enum Payment {
    Debit = 'Debit',
    Credit = 'Credit'
}

Now you can access array of options:

Object.values(Payment)
ghandic commented 1 year ago

Alternatively define the array of enumerated values and then define the type from that, then it will avoid the typescript enum issues