cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
403 stars 134 forks source link

Allow generating an array with all enum model items #303

Closed luisfpg closed 1 year ago

luisfpg commented 1 year ago

This is specially useful when using enumStyle is alias. In this case it is not possible to iterate over all enum items, as they only exist at compilation time. However, in some particular cases this is useful. So, the idea is to add a new boolean option enumArray (default false) to generate a ts file next to the enum file, suffixed with -array.ts, which exports a const with all enum items in an array. This file isn't even included in the model index (models.ts). This way the overhead on generated code is minimal, and will only include arrays of actually used enums.