✨ example value in documentation
This commit is contained in:
parent
22c744398c
commit
e9c3f7ee1c
@ -15,9 +15,8 @@
|
|||||||
"dev": "tsnd --respawn src/start.ts",
|
"dev": "tsnd --respawn src/start.ts",
|
||||||
"patch": "npx patch-package",
|
"patch": "npx patch-package",
|
||||||
"postinstall": "npm run patch",
|
"postinstall": "npm run patch",
|
||||||
"generate:docs": "ts-node scripts/generate_openapi_schema.ts",
|
"generate:docs": "node scripts/generate_openapi.ts",
|
||||||
"generate:test": "ts-node scripts/generate_test_schema.ts",
|
"generate:schema": "node scripts/generate_schema.ts"
|
||||||
"generate:schema": "ts-node scripts/generate_body_schema.ts"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -81,6 +81,18 @@ function apiRoutes() {
|
|||||||
}
|
}
|
||||||
if (route.test?.response) {
|
if (route.test?.response) {
|
||||||
const status = route.test.response.status || 200;
|
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 = {
|
obj.responses = {
|
||||||
[status]: {
|
[status]: {
|
||||||
...(route.test.response.body
|
...(route.test.response.body
|
||||||
@ -88,9 +100,7 @@ function apiRoutes() {
|
|||||||
description: obj.responses[status].description || "",
|
description: obj.responses[status].description || "",
|
||||||
content: {
|
content: {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
schema: {
|
schema: schema
|
||||||
$ref: `#/components/schemas/${route.test.response.body}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user