fixing lots of openapi crap

This commit is contained in:
Puyodead1
2023-04-13 15:20:10 -04:00
parent 777e7208dc
commit 6b3a3b750f
60 changed files with 79183 additions and 79519 deletions
+15 -11
View File
@@ -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<string, string>;
};
event?: EVENT | EVENT[];
summary?: string;
description?: string;
// test?: {
// response?: RouteResponse;
// body?: unknown;
// path?: string;
// event?: EVENT | EVENT[];
// headers?: Record<string, string>;
// };
}
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) => {