Skip to content

Commit fc894ab

Browse files
committed
Update API docs
1 parent bbe27c9 commit fc894ab

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/api/components/index.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
163181
export 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 {

src/api/routes/events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async (
327327
}),
328328
response: {
329329
201: {
330-
description: "Event modified.",
330+
description: "The event has been modified.",
331331
content: {
332332
"application/json": {
333333
schema: z.null(),
@@ -617,7 +617,7 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async (
617617
}),
618618
response: {
619619
204: {
620-
description: "Event deleted.",
620+
description: "The event has been deleted.",
621621
content: {
622622
"application/json": {
623623
schema: z.null(),

0 commit comments

Comments
 (0)