1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-24 11:34:10 +02:00
This commit is contained in:
tamaina
2023-05-22 04:50:18 +00:00
parent e689dcdd73
commit 86f4e206f4
10 changed files with 135 additions and 88 deletions

View File

@@ -446,3 +446,17 @@ export const endpoints = {
}],
},
} as const satisfies { [x: string]: IEndpointMeta; };
export function getEndpointSchema(reqres: 'req' | 'res', key: keyof typeof endpoints) {
const endpoint = endpoints[key];
const schemas = endpoint.defines.map(d => d[reqres]).filter(d => d !== undefined);
if (schemas.length === 0) {
return null;
}
if (schemas.length === 1) {
return schemas[0];
}
return {
oneOf: schemas,
};
}