diff options
author | Puyodead1 <puyodead@proton.me> | 2023-03-23 10:40:37 -0400 |
---|---|---|
committer | Puyodead1 <puyodead@proton.me> | 2023-04-13 14:58:53 -0400 |
commit | a567ca3f514b7671da5d523325751a8383885d2c (patch) | |
tree | b9d6cb1ef0799007dbaa8a88a317486de9dd59c3 /scripts | |
parent | fix style action (diff) | |
download | server-a567ca3f514b7671da5d523325751a8383885d2c.tar.xz |
auth routes
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/openapi.js | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/scripts/openapi.js b/scripts/openapi.js index 49d5dfde..86527ada 100644 --- a/scripts/openapi.js +++ b/scripts/openapi.js @@ -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]; - - obj.responses = { - [status]: { - ...(route.test.response.body - ? { - description: - obj?.responses?.[status]?.description || "", - content: { - "application/json": { - schema: schema, + 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 = { + [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) => ({ |