@@ -131,7 +131,7 @@ export const internalServerError = getCorrectJsonSchema({
131131 } ,
132132 } ,
133133 } ,
134- description : "The server encountered an error." ,
134+ description : "The server encountered an error processing the request ." ,
135135 example : {
136136 name : "InternalServerError" ,
137137 id : 100 ,
@@ -148,18 +148,36 @@ export const rateLimitExceededError = getCorrectJsonSchema({
148148 message : z . literal ( "Rate limit exceeded." ) ,
149149 } )
150150 . meta ( {
151- id : "RateLimitExceededError" ,
152- description :
153- "You have sent too many requests. Check the response headers and try again." ,
151+ id : "rateLimitExceededError" ,
152+ description : "The caller has sent too many requests. Try again later." ,
154153 } ) ,
155- description : "The request exceeeds the rate limit ." ,
154+ description : "The caller has sent too many requests. Try again later ." ,
156155 example : {
157156 name : "RateLimitExceededError" ,
158157 id : 409 ,
159158 message : "Rate limit exceeded." ,
160159 } ,
161160} ) ;
162161
162+ export const validationError = getCorrectJsonSchema ( {
163+ schema : z
164+ . object ( {
165+ name : z . literal ( "RateLimitExceededError" ) ,
166+ id : z . literal ( 104 ) ,
167+ message : z . literal ( "Rate limit exceeded." ) ,
168+ } )
169+ . meta ( {
170+ id : "validationError" ,
171+ description : "The request is invalid." ,
172+ } ) ,
173+ description : "The request is invalid." ,
174+ example : {
175+ name : "ValidationError" ,
176+ id : 104 ,
177+ message : "Request is invalid." ,
178+ } ,
179+ } ) ;
180+
163181export function withRoles < T extends FastifyZodOpenApiSchema > (
164182 roles : AppRoles [ ] ,
165183 schema : T ,
@@ -194,6 +212,7 @@ export function withTags<T extends FastifyZodOpenApiSchema>(
194212 const responses = {
195213 500 : internalServerError ,
196214 429 : rateLimitExceededError ,
215+ 400 : validationError ,
197216 ...schema . response ,
198217 } ;
199218 return {
0 commit comments