The parser option customizes how your OpenAPI specification is parsed and transformed before plugins process it.
Overview
import { defineConfig } from '@hey-api/openapi-ts' ;
export default defineConfig ({
input: 'https://api.example.com/openapi.json' ,
output: './src/client' ,
parser: {
filters: {
tags: {
include: [ 'users' , 'posts' ],
},
},
transforms: {
enums: 'root' ,
},
} ,
}) ;
Filters
Filters select a subset of your OpenAPI specification before it’s passed to plugins.
parser.filters.operations
Filter operations (endpoints) to include or exclude. Process only operations matching these patterns. filters : {
operations : {
include : [ 'GET /api/v1/users' , 'POST /api/v1/users' ],
},
}
Exclude operations matching these patterns. In case of conflicts, exclude takes precedence over include. filters : {
operations : {
exclude : [ 'DELETE /api/v1/admin/*' ],
},
}
Filter by OpenAPI tags. Process only resources with these tags. filters : {
tags : {
include : [ 'users' , 'posts' ],
},
}
Exclude resources with these tags. filters : {
tags : {
exclude : [ 'internal' , 'deprecated' ],
},
}
Filter schema definitions to include or exclude. Process only these schema definitions.
Exclude these schema definitions.
parser.filters.parameters
Filter parameter definitions. Process only these parameters.
Exclude these parameters.
parser.filters.requestBodies
Filter request body definitions. Show Request Bodies Filter
Process only these request bodies.
Exclude these request bodies.
Filter response definitions. Process only these responses.
parser.filters.deprecated
Include deprecated resources in the output. Set to false to exclude all resources marked as deprecated in your OpenAPI specification. parser : {
filters : {
deprecated : false ,
},
}
Keep reusable components without any references from operations in the output. By default, unreferenced schemas are excluded.
parser.filters.preserveOrder
Preserve key order when processing your input. Disabled by default for performance.
Transforms modify or normalize the OpenAPI specification in standardized ways.
parser.transforms.enums
boolean | string | object
default: false
Control how enums are handled in your specification. Your input might contain two types of enums:
Root enums : Defined as reusable components
Inline enums : Nested within other schemas
Only root enums are typically exported by plugins. Use this transform to promote inline enums to root level. Show Enums Transform Configuration
Whether this transform is enabled.
Controls enum handling:
'root' — Promote inline enums to reusable root components
'inline' — Keep all enums inline within schemas
enums.case
string
default: "PascalCase"
Casing convention for generated enum names. Options: 'camelCase', 'PascalCase', 'snake_case', 'SCREAMING_SNAKE_CASE', 'preserve'
enums.name
string | function
default: "{{name}}Enum"
Customize the generated enum name. Use {{name}} placeholder or provide a function.
parser : {
transforms : {
enums : true , // Enable with defaults (mode: 'root')
},
}
parser.transforms.readWrite
boolean | object
default: true
Separate schemas for read (response) and write (request) operations. Schemas might contain read-only or write-only fields. This transform creates separate schemas to avoid asking users to provide read-only fields in requests or expecting write-only fields in responses. Show Read/Write Transform Configuration
Whether this transform is enabled.
readWrite.requests
string | object
default: "{{name}}Writable"
Configuration for request-specific schemas (containing write-only fields). Casing convention for generated names.
requests.name
string | function
default: "{{name}}Writable"
Naming pattern for request schemas.
readWrite.responses
string | object
default: "{{name}}"
Configuration for response-specific schemas (containing read-only fields). Casing convention for generated names.
responses.name
string | function
default: "{{name}}"
Naming pattern for response schemas.
parser : {
transforms : {
readWrite : {
enabled : true ,
requests : '{{name}}Input' ,
responses : '{{name}}Output' ,
},
},
}
parser.transforms.propertiesRequiredByDefault
Treat all object properties as required by default unless explicitly marked as optional. By default (per OpenAPI spec), missing required keyword means no properties are required. Some specifications expect the opposite behavior. parser : {
transforms : {
propertiesRequiredByDefault : true ,
},
}
parser.transforms.schemaName
Rename schema component keys throughout the specification, automatically updating all $ref pointers. Useful when schema names are auto-generated or follow awkward naming conventions. parser : {
transforms : {
schemaName : ( name ) => name . replace ( /_v \d + _ \d + _ \d + _/ , '_' ),
},
}
Array of keywords to identify pagination fields in schemas and parameters. These keywords help plugins detect paginated operations and generate appropriate code. parser : {
pagination : {
keywords : [ 'page' , 'pageSize' , 'cursor' , 'limit' ],
},
}
Validation
parser.validate_EXPERIMENTAL
boolean | string
default: false
Experimental: Validate the input OpenAPI specification before generating output.This is a lightweight, experimental feature with support added on an ad hoc basis. Options:
false — No validation
true or 'warn' — Validate and warn about issues
'strict' — Validate and fail on any issues
parser : {
validate_EXPERIMENTAL : 'warn' ,
}
Examples
import { defineConfig } from '@hey-api/openapi-ts' ;
export default defineConfig ({
input: 'https://api.example.com/openapi.json' ,
output: './src/client' ,
parser: {
filters: {
tags: {
include: [ 'users' , 'posts' ],
},
},
} ,
}) ;
Exclude Deprecated Operations
import { defineConfig } from '@hey-api/openapi-ts' ;
export default defineConfig ({
input: 'https://api.example.com/openapi.json' ,
output: './src/client' ,
parser: {
filters: {
deprecated: false ,
},
} ,
}) ;
import { defineConfig } from '@hey-api/openapi-ts' ;
export default defineConfig ({
input: 'https://api.example.com/openapi.json' ,
output: './src/client' ,
parser: {
transforms: {
enums: {
enabled: true ,
mode: 'root' ,
case: 'SCREAMING_SNAKE_CASE' ,
name: '{{name}}Enum' ,
},
},
} ,
}) ;
Custom Schema Naming
import { defineConfig } from '@hey-api/openapi-ts' ;
export default defineConfig ({
input: 'https://api.example.com/openapi.json' ,
output: './src/client' ,
parser: {
transforms: {
// Remove version suffixes from schema names
schemaName : ( name ) => name . replace ( /_v \d + $ / , '' ),
},
} ,
}) ;