From 6b3a3b750f3e29b491c51f8199efd64c05176a65 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Fri, 24 Mar 2023 18:14:47 -0400 Subject: fixing lots of openapi crap --- src/api/util/handlers/route.ts | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/api/util/handlers/route.ts') diff --git a/src/api/util/handlers/route.ts b/src/api/util/handlers/route.ts index 04910ed4..331ac0c2 100644 --- a/src/api/util/handlers/route.ts +++ b/src/api/util/handlers/route.ts @@ -52,27 +52,31 @@ export type RouteResponse = { export interface RouteOptions { permission?: PermissionResolvable; right?: RightResolvable; - body?: `${string}Schema`; // typescript interface name + requestBody?: `${string}Schema`; // typescript interface name responses?: { [status: number]: { // body?: `${string}Response`; body?: string; }; }; - test?: { - response?: RouteResponse; - body?: unknown; - path?: string; - event?: EVENT | EVENT[]; - headers?: Record; - }; + event?: EVENT | EVENT[]; + summary?: string; + description?: string; + // test?: { + // response?: RouteResponse; + // body?: unknown; + // path?: string; + // event?: EVENT | EVENT[]; + // headers?: Record; + // }; } export function route(opts: RouteOptions) { let validate: AnyValidateFunction | undefined; - if (opts.body) { - validate = ajv.getSchema(opts.body); - if (!validate) throw new Error(`Body schema ${opts.body} not found`); + if (opts.requestBody) { + validate = ajv.getSchema(opts.requestBody); + if (!validate) + throw new Error(`Body schema ${opts.requestBody} not found`); } return async (req: Request, res: Response, next: NextFunction) => { -- cgit 1.5.1