mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 16:05:41 +00:00
auth routes
This commit is contained in:
@@ -147,36 +147,37 @@ function apiRoutes() {
|
||||
}.merge(obj.requestBody);
|
||||
}
|
||||
|
||||
if (route.test?.response) {
|
||||
const status = route.test.response.status || 200;
|
||||
let schema = {
|
||||
allOf: [
|
||||
{
|
||||
$ref: `#/components/schemas/${route.test.response.body}`,
|
||||
},
|
||||
{
|
||||
example: route.test.body,
|
||||
},
|
||||
],
|
||||
};
|
||||
if (!route.test.body) schema = schema.allOf[0];
|
||||
if (route.responses) {
|
||||
for (const [k, v] of Object.entries(route.responses)) {
|
||||
let schema = {
|
||||
allOf: [
|
||||
{
|
||||
$ref: `#/components/schemas/${v.body}`,
|
||||
},
|
||||
{
|
||||
example: v.body,
|
||||
},
|
||||
],
|
||||
};
|
||||
if (!v.body) schema = schema.allOf[0];
|
||||
|
||||
obj.responses = {
|
||||
[status]: {
|
||||
...(route.test.response.body
|
||||
? {
|
||||
description:
|
||||
obj?.responses?.[status]?.description || "",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: schema,
|
||||
obj.responses = {
|
||||
[k]: {
|
||||
...(v.body
|
||||
? {
|
||||
description:
|
||||
obj?.responses?.[k]?.description || "",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: schema,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
}.merge(obj.responses);
|
||||
delete obj.responses.default;
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
}.merge(obj.responses);
|
||||
delete obj.responses.default;
|
||||
}
|
||||
}
|
||||
if (p.includes(":")) {
|
||||
obj.parameters = p.match(/:\w+/g)?.map((x) => ({
|
||||
|
||||
Reference in New Issue
Block a user