example value in documentation

This commit is contained in:
Flam3rboy
2021-09-21 23:29:17 +02:00
parent 22c744398c
commit e9c3f7ee1c
3 changed files with 15 additions and 6 deletions
@@ -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
}
}
}