Enum Names
You can extend your OpenAPI schema to include enum names for your enum values. This will let Orval generate your enums with the correct names.
Example of OpenAPI schema
openapi: '3.1.0'info:version: 1.0.0title: Swagger Petstorelicense:name: MITcomponents:schemas:MyObject:type: objectproperties:myEnum:type: numberenum:- 1- 2- 3- 4x-enumNames:- One- Two- Three- Four
The enum generated by Orval will be
export const MyEnum {One: 1,Two: 2,Three: 3,Four: 4} as const;
Valid enum name extensions
Orval recognizes the following extensions:
- x-enumNames
- x-enumnames
- x-enum-varnames
Was this page helpful?