OpenApiValidatorConfig
Global configuration for OpenAPI validation. This can be set at server startup to control validation behavior.
Properties
coerceTypes?
optionalcoerceTypes?:boolean
Whether to coerce types (e.g., string "123" to number 123). Default: true
logValidationErrors?
optionallogValidationErrors?:boolean
Log validation errors for debugging. Default: true
onAdditionalPropertiesRemoved?
optionalonAdditionalPropertiesRemoved?: (removedProperties,req) =>void
Callback fired when additional properties are removed from a request body.
Only fires when removeAdditional: true and extra properties are present.
Receives the list of removed property names and the request.
Parameters
removedProperties
string[]
req
Request
Returns
void
onValidationError?
optionalonValidationError?: (errors,req) =>void
Custom error handler for validation failures. If not provided, throws an APIError with status 400.
Parameters
errors
ErrorObject<string, Record<string, any>, unknown>[]
req
Request
Returns
void
removeAdditional?
optionalremoveAdditional?:boolean
Whether to remove additional properties not in the schema. Default: true
validateRequests?
optionalvalidateRequests?:boolean
Enable or disable request body validation. Default: true (when configureOpenApiValidator is called)
validateResponses?
optionalvalidateResponses?:boolean
Enable or disable response validation. Default: false (response validation has performance overhead)