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.0
title: Swagger Petstore
license:
name: MIT
components:
schemas:
MyObject:
type: object
properties:
myEnum:
type: number
enum:
- 1
- 2
- 3
- 4
x-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?

Copyright © 2025 Victor Bury. All Rights Reserved.