Skip to content

Options

Configuration Options

OptionTypeDefaultDescription
specSource{ type: "object"; spec: OpenAPISpec } | { type: "url"; spec: string } | { type: "file"; spec: string }Provide your OpenAPI 3.x spec as an object, or point to it via URL or file path.
requestValidationRequestValidationOptionssee belowControls validation of incoming requests.
responseValidationResponseValidationOptionssee belowControls validation of outgoing responses.
ajvAjv | { options?: AjvOptions; configure?: (ajv: Ajv) => void }see belowOverride the default ajv instance or configure it
precompileSchemasbooleanfalsePrecompile all route schemas during application bootstrap. This removes the first-request latency at the cost of longer start-up time.
debugbooleanfalseVerbose logs for troubleshooting.

specSource

TypeTypeTypical use
"object"OpenAPISpecStatic spec object.
"url"stringLink to a centralized or externally hosted spec.
"file"stringLocal file path to a json file.

requestValidation

OptionTypeDefaultDescription
enablebooleantrueEnable request validation globally.
transformbooleanfalseCoerce/transform inputs where schema allows (e.g., "42"42).
onValidationFailed(ctx: ExecutionContext, errors: ValidationError[]) => void | neverthrows BadRequestException with validation errorsCustom handler. Transform, throw your own exception, or log/ignore.

responseValidation

OptionTypeDefaultDescription
enablebooleanfalseEnable response validation globally.
skipErrorResponsesbooleantrueSkip validation for error responses (4xx/5xx status codes). Cant validate thrown errors, see here.
onValidationFailed(ctx: ExecutionContext, errors: ValidationError[]) => void | neverwarns and throws InternalServer ErrorException without validation errorsCustom handler. Transform, throw your own exception, or log/ignore.

ajv

OptionTypeDefaultDescription
(itself)Ajva v8 instanceSupply a fully configured AJV instance.
optionsAjvOptionsInitialize the internal AJV with these options (e.g., strict: false).
configure(ajv: Ajv) => voidHook to extend the instance (e.g., addFormats(ajv)).

Released under the MIT License.