Skip to content

Commit 2243a27

Browse files
committed
更新 NestJS 示例应用的启动脚本,并添加 OpenAPI 元数据端点
1 parent 79ee63d commit 2243a27

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

examples/apps/nestjs/nest-cli.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://json.schemastore.org/nest-cli",
3+
"collection": "@nestjs/schematics",
4+
"sourceRoot": "src",
5+
"compilerOptions": {
6+
"deleteOutDir": true
7+
}
8+
}

examples/apps/nestjs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"private": true,
55
"scripts": {
66
"build": "tsc -b",
7-
"start": "ts-node src/main.ts",
7+
"start": "nest start",
8+
"start:dev": "nest start --watch",
89
"test": "echo \"No tests specified\" && exit 0"
910
},
1011
"dependencies": {

packages/api/src/swagger/generator.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@ export function generateOpenApiSpec(objectql: IObjectQL) {
66
const paths: any = {};
77
const schemas: any = {};
88

9+
// 0. Metadata Endpoint
10+
paths['/api/_schema'] = {
11+
get: {
12+
summary: "Get Full Schema Metadata",
13+
tags: ["System"],
14+
responses: {
15+
200: {
16+
description: "Full configuration of all objects",
17+
content: {
18+
'application/json': {
19+
schema: {
20+
type: 'object',
21+
additionalProperties: {
22+
type: 'object',
23+
description: 'Object Configuration'
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
}
31+
};
32+
933
Object.values(configs).forEach((config) => {
1034
const objectName = config.name;
1135
const schemaName = objectName;

0 commit comments

Comments
 (0)