Enum Names
The OpenAPI schema can be extended to include enum names for enum values. This will let Orval generate enums with 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 as follows:
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?