@@ -83,10 +83,7 @@ export const validationMessagesFormatters: Record<string, ValidationFormatter> =
8383 return max === 0 ? 'must be a empty array' : `must be an array with at most ${ max } items`
8484 } ,
8585 enum : values =>
86- `must be one of the following values: ${ niceJoin (
87- values . map ( ( f : string ) => `"${ f } "` ) ,
88- ' or '
89- ) } `,
86+ `must be one of the following values: ${ niceJoin ( values . map ( ( f : string ) => `"${ f } "` ) as string [ ] , ' or ' ) } ` ,
9087 pattern : pattern => `must match pattern "${ pattern . replaceAll ( '(?:' , '(' ) } "` ,
9188 invalidResponseCode : code => `This endpoint cannot respond with HTTP status ${ code } .` ,
9289 invalidResponse : code =>
@@ -113,7 +110,7 @@ export function convertValidationErrors(
113110 let reason : string
114111
115112 // Normalize the key
116- let key = e . dataPath ?? e . instancePath /* c8 ignore next */ ?? ''
113+ let key : string = e . dataPath ?? e . instancePath /* c8 ignore next */ ?? ''
117114
118115 if ( / ^ [ . / ] / . test ( key ) ) {
119116 key = key . slice ( 1 )
@@ -260,7 +257,11 @@ export function addResponseValidation(this: FastifyInstance, route: RouteOptions
260257 if ( ! valid ) {
261258 done (
262259 new InternalServerError ( validationMessagesFormatters . invalidResponse ( statusCode ) , {
263- failedValidations : convertValidationErrors ( 'response' , payload , validator . errors as ValidationResult [ ] )
260+ failedValidations : convertValidationErrors (
261+ 'response' ,
262+ payload as Record < string , unknown > ,
263+ validator . errors as ValidationResult [ ]
264+ )
264265 } )
265266 )
266267 return
@@ -283,7 +284,7 @@ export function compileResponseValidationSchema(this: FastifyInstance, configura
283284
284285 for ( const [ instance , validators , schemas ] of this [ kHttpErrorsEnhancedResponseValidations ] ) {
285286 // @ts -expect-error Fix types
286- const compiler = new AjvConstructor ( {
287+ const compiler : Ajv = new AjvConstructor ( {
287288 // The fastify defaults, with the exception of removeAdditional and coerceTypes, which have been reversed
288289 removeAdditional : false ,
289290 useDefaults : true ,
0 commit comments