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:
parent
b3f8df560a
commit
5df60344fd
@ -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",
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user