1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 20:52:42 +01:00

example value in documentation

This commit is contained in:
Flam3rboy 2021-09-21 23:29:17 +02:00
parent b3f8df560a
commit 5df60344fd
3 changed files with 15 additions and 6 deletions

View File

@ -15,9 +15,8 @@
"dev": "tsnd --respawn src/start.ts",
"patch": "npx patch-package",
"postinstall": "npm run patch",
"generate:docs": "ts-node scripts/generate_openapi_schema.ts",
"generate:test": "ts-node scripts/generate_test_schema.ts",
"generate:schema": "ts-node scripts/generate_body_schema.ts"
"generate:docs": "node scripts/generate_openapi.ts",
"generate:schema": "node scripts/generate_schema.ts"
},
"repository": {
"type": "git",

View File

@ -81,6 +81,18 @@ function apiRoutes() {
}
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
@ -88,9 +100,7 @@ function apiRoutes() {
description: obj.responses[status].description || "",
content: {
"application/json": {
schema: {
$ref: `#/components/schemas/${route.test.response.body}`
}
schema: schema
}
}
}