@rsdk/cli.cmd.autodoc 6.0.0-next.8 → 6.0.0-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/openapi-json/schemas/config.schema.d.ts +55 -0
- package/dist/generators/openapi-json/schemas/config.schema.js +36 -0
- package/dist/generators/openapi-json/schemas/config.schema.js.map +1 -0
- package/dist/generators/openapi-json/schemas/index.d.ts +1 -0
- package/dist/generators/openapi-json/schemas/index.js +18 -0
- package/dist/generators/openapi-json/schemas/index.js.map +1 -0
- package/package.json +11 -11
- package/src/generators/openapi-json/schemas/config.schema.spec.ts +265 -0
- package/src/generators/openapi-json/schemas/config.schema.ts +37 -0
- package/src/generators/openapi-json/schemas/index.ts +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Static } from '@sinclair/typebox';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration schema for OpenAPI document generation.
|
|
4
|
+
* @example
|
|
5
|
+
* {
|
|
6
|
+
* "out": "openapi.json",
|
|
7
|
+
* "app": "./dist/app.js",
|
|
8
|
+
* "title": "My API",
|
|
9
|
+
* "version": "1.0.0",
|
|
10
|
+
* "description": "API Description",
|
|
11
|
+
* "includeZones": ["public"],
|
|
12
|
+
* "excludeZones": ["internal"],
|
|
13
|
+
* "security": {
|
|
14
|
+
* "jwt": {
|
|
15
|
+
* "type": "http",
|
|
16
|
+
* "scheme": "bearer",
|
|
17
|
+
* "bearerFormat": "JWT",
|
|
18
|
+
* "name": "JWT Auth"
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export declare const OpenApiConfigSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
|
|
24
|
+
title: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
25
|
+
version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
26
|
+
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
27
|
+
includeZones: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
28
|
+
excludeZones: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
29
|
+
security: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
30
|
+
type: import("@sinclair/typebox").TLiteral<"http">;
|
|
31
|
+
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
32
|
+
scheme: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"basic">, import("@sinclair/typebox").TLiteral<"bearer">]>;
|
|
33
|
+
bearerFormat: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
34
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
35
|
+
type: import("@sinclair/typebox").TLiteral<"apiKey">;
|
|
36
|
+
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
37
|
+
name: import("@sinclair/typebox").TString;
|
|
38
|
+
in: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"query">, import("@sinclair/typebox").TLiteral<"header">, import("@sinclair/typebox").TLiteral<"cookie">]>;
|
|
39
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
40
|
+
type: import("@sinclair/typebox").TLiteral<"oauth2">;
|
|
41
|
+
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
42
|
+
flows: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TObject<{
|
|
43
|
+
scopes: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
|
|
44
|
+
authorizationUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
45
|
+
tokenUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
46
|
+
refreshUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
47
|
+
}>>;
|
|
48
|
+
}>]>>>;
|
|
49
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
50
|
+
/** Output file path for the generated OpenAPI document */
|
|
51
|
+
out: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
52
|
+
/** Path to the application file (usually `dist/app.js`) */
|
|
53
|
+
app: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
54
|
+
}>]>;
|
|
55
|
+
export type OpenApiConfigSchema = Static<typeof OpenApiConfigSchema>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenApiConfigSchema = void 0;
|
|
4
|
+
const http_openapi_1 = require("@rsdk/http.openapi");
|
|
5
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
6
|
+
/**
|
|
7
|
+
* Configuration schema for OpenAPI document generation.
|
|
8
|
+
* @example
|
|
9
|
+
* {
|
|
10
|
+
* "out": "openapi.json",
|
|
11
|
+
* "app": "./dist/app.js",
|
|
12
|
+
* "title": "My API",
|
|
13
|
+
* "version": "1.0.0",
|
|
14
|
+
* "description": "API Description",
|
|
15
|
+
* "includeZones": ["public"],
|
|
16
|
+
* "excludeZones": ["internal"],
|
|
17
|
+
* "security": {
|
|
18
|
+
* "jwt": {
|
|
19
|
+
* "type": "http",
|
|
20
|
+
* "scheme": "bearer",
|
|
21
|
+
* "bearerFormat": "JWT",
|
|
22
|
+
* "name": "JWT Auth"
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
exports.OpenApiConfigSchema = typebox_1.Type.Intersect([
|
|
28
|
+
typebox_1.Type.Partial(http_openapi_1.OpenApiOptions),
|
|
29
|
+
typebox_1.Type.Object({
|
|
30
|
+
/** Output file path for the generated OpenAPI document */
|
|
31
|
+
out: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
32
|
+
/** Path to the application file (usually `dist/app.js`) */
|
|
33
|
+
app: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
36
|
+
//# sourceMappingURL=config.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.schema.js","sourceRoot":"","sources":["../../../../src/generators/openapi-json/schemas/config.schema.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAEpD,+CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,mBAAmB,GAAG,cAAI,CAAC,SAAS,CAAC;IAChD,cAAI,CAAC,OAAO,CAAC,6BAAc,CAAC;IAC5B,cAAI,CAAC,MAAM,CAAC;QACV,0DAA0D;QAC1D,GAAG,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,EAAE,CAAC;QAEjC,2DAA2D;QAC3D,GAAG,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,EAAE,CAAC;KAClC,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config.schema';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config.schema"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generators/openapi-json/schemas/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/cli.cmd.autodoc",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.9",
|
|
4
4
|
"description": "autodoc your app!",
|
|
5
5
|
"homepage": "https://github.com/R-Vision/rsdk",
|
|
6
6
|
"license": "Apache License 2.0",
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"@nestjs/common": "^10.0.0",
|
|
14
14
|
"@nestjs/core": "^10.0.0",
|
|
15
15
|
"@nestjs/swagger": "^7.0.0 || ^8.0.0",
|
|
16
|
-
"@rsdk/cli.common": "6.0.0-next.
|
|
17
|
-
"@rsdk/cli.core": "6.0.0-next.
|
|
18
|
-
"@rsdk/common": "6.0.0-next.
|
|
19
|
-
"@rsdk/common.node": "6.0.0-next.
|
|
20
|
-
"@rsdk/core": "6.0.0-next.
|
|
21
|
-
"@rsdk/http.openapi": "6.0.0-next.
|
|
22
|
-
"@rsdk/logging": "6.0.0-next.
|
|
23
|
-
"@rsdk/nest-tools": "6.0.0-next.
|
|
24
|
-
"@rsdk/zones": "6.0.0-next.
|
|
16
|
+
"@rsdk/cli.common": "6.0.0-next.9",
|
|
17
|
+
"@rsdk/cli.core": "6.0.0-next.9",
|
|
18
|
+
"@rsdk/common": "6.0.0-next.9",
|
|
19
|
+
"@rsdk/common.node": "6.0.0-next.9",
|
|
20
|
+
"@rsdk/core": "6.0.0-next.9",
|
|
21
|
+
"@rsdk/http.openapi": "6.0.0-next.9",
|
|
22
|
+
"@rsdk/logging": "6.0.0-next.9",
|
|
23
|
+
"@rsdk/nest-tools": "6.0.0-next.9",
|
|
24
|
+
"@rsdk/zones": "6.0.0-next.9",
|
|
25
25
|
"@sinclair/typebox": "^0.34.9",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"yaml": "^2.6.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1489dda3b612de37a2b927e8c74058a910a4ddc9"
|
|
30
30
|
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { TypeBoxValidator } from '@rsdk/common';
|
|
2
|
+
import { parse } from 'yaml';
|
|
3
|
+
|
|
4
|
+
import { OpenApiConfigSchema } from './config.schema';
|
|
5
|
+
|
|
6
|
+
describe('OpenAPI Config Schema', () => {
|
|
7
|
+
const validator = new TypeBoxValidator(OpenApiConfigSchema);
|
|
8
|
+
|
|
9
|
+
it('should validate minimal config', () => {
|
|
10
|
+
const config = parse(`
|
|
11
|
+
out: openapi.json
|
|
12
|
+
title: Test API
|
|
13
|
+
version: 1.0.0
|
|
14
|
+
description: Test API Description
|
|
15
|
+
`);
|
|
16
|
+
|
|
17
|
+
const { isValid, errors } = validator.check(config);
|
|
18
|
+
|
|
19
|
+
expect(isValid).toBe(true);
|
|
20
|
+
expect(errors).toHaveLength(0);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should validate minimal config', () => {
|
|
24
|
+
const config = parse(`
|
|
25
|
+
out: openapi.json
|
|
26
|
+
title: Test API
|
|
27
|
+
version: '1.0.0'
|
|
28
|
+
description: Test API Description
|
|
29
|
+
`);
|
|
30
|
+
|
|
31
|
+
const { isValid, errors } = validator.check(config);
|
|
32
|
+
|
|
33
|
+
expect(isValid).toBe(true);
|
|
34
|
+
expect(errors).toHaveLength(0);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should validate config with zones', () => {
|
|
38
|
+
const config = parse(`
|
|
39
|
+
out: openapi.json
|
|
40
|
+
title: Test API
|
|
41
|
+
version: '1.0.0'
|
|
42
|
+
description: Test API Description
|
|
43
|
+
includeZones:
|
|
44
|
+
- public
|
|
45
|
+
- api:web
|
|
46
|
+
excludeZones:
|
|
47
|
+
- __internal
|
|
48
|
+
`);
|
|
49
|
+
|
|
50
|
+
const { isValid, errors } = validator.check(config);
|
|
51
|
+
|
|
52
|
+
expect(isValid).toBe(true);
|
|
53
|
+
expect(errors).toHaveLength(0);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should validate config without optional fields', () => {
|
|
57
|
+
const config = parse(`
|
|
58
|
+
out: openapi.json
|
|
59
|
+
version: '1.0.0'
|
|
60
|
+
`);
|
|
61
|
+
|
|
62
|
+
const { isValid, errors } = validator.check(config);
|
|
63
|
+
|
|
64
|
+
expect(isValid).toBe(true);
|
|
65
|
+
expect(errors).toHaveLength(0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('Security Schemes', () => {
|
|
69
|
+
it('should validate API Key auth', () => {
|
|
70
|
+
const config = parse(`
|
|
71
|
+
out: openapi.json
|
|
72
|
+
title: Test API
|
|
73
|
+
version: '1.0.0'
|
|
74
|
+
description: Test API Description
|
|
75
|
+
security:
|
|
76
|
+
ApiKeyAuth:
|
|
77
|
+
type: apiKey
|
|
78
|
+
in: header
|
|
79
|
+
name: x-api-key
|
|
80
|
+
description: API Key Authentication
|
|
81
|
+
`);
|
|
82
|
+
|
|
83
|
+
const { isValid, errors } = validator.check(config);
|
|
84
|
+
|
|
85
|
+
expect(isValid).toBe(true);
|
|
86
|
+
expect(errors).toHaveLength(0);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should validate Bearer auth', () => {
|
|
90
|
+
const config = parse(`
|
|
91
|
+
out: openapi.json
|
|
92
|
+
title: Test API
|
|
93
|
+
version: '1.0.0'
|
|
94
|
+
description: Test API Description
|
|
95
|
+
security:
|
|
96
|
+
BearerAuth:
|
|
97
|
+
type: http
|
|
98
|
+
scheme: bearer
|
|
99
|
+
bearerFormat: JWT
|
|
100
|
+
description: JWT Bearer Authentication
|
|
101
|
+
`);
|
|
102
|
+
|
|
103
|
+
const { isValid, errors } = validator.check(config);
|
|
104
|
+
|
|
105
|
+
expect(isValid).toBe(true);
|
|
106
|
+
expect(errors).toHaveLength(0);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should validate Basic auth', () => {
|
|
110
|
+
const config = parse(`
|
|
111
|
+
out: openapi.json
|
|
112
|
+
title: Test API
|
|
113
|
+
version: '1.0.0'
|
|
114
|
+
description: Test API Description
|
|
115
|
+
security:
|
|
116
|
+
BasicAuth:
|
|
117
|
+
type: http
|
|
118
|
+
scheme: basic
|
|
119
|
+
description: Basic Authentication
|
|
120
|
+
`);
|
|
121
|
+
|
|
122
|
+
const { isValid, errors } = validator.check(config);
|
|
123
|
+
|
|
124
|
+
expect(isValid).toBe(true);
|
|
125
|
+
expect(errors).toHaveLength(0);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should validate OAuth2 auth', () => {
|
|
129
|
+
const config = parse(`
|
|
130
|
+
out: openapi.json
|
|
131
|
+
title: Test API
|
|
132
|
+
version: '1.0.0'
|
|
133
|
+
description: Test API Description
|
|
134
|
+
security:
|
|
135
|
+
OAuth2Auth:
|
|
136
|
+
type: oauth2
|
|
137
|
+
flows:
|
|
138
|
+
implicit:
|
|
139
|
+
authorizationUrl: https://auth.example.com/oauth/authorize
|
|
140
|
+
scopes:
|
|
141
|
+
read: Read access
|
|
142
|
+
write: Write access
|
|
143
|
+
`);
|
|
144
|
+
|
|
145
|
+
const { isValid, errors } = validator.check(config);
|
|
146
|
+
|
|
147
|
+
for (const error of errors) {
|
|
148
|
+
console.log(error);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
expect(isValid).toBe(true);
|
|
152
|
+
expect(errors).toHaveLength(0);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should validate multiple security schemes', () => {
|
|
156
|
+
const config = parse(`
|
|
157
|
+
out: openapi.json
|
|
158
|
+
title: Test API
|
|
159
|
+
version: '1.0.0'
|
|
160
|
+
description: Test API Description
|
|
161
|
+
security:
|
|
162
|
+
BearerAuth:
|
|
163
|
+
type: http
|
|
164
|
+
scheme: bearer
|
|
165
|
+
bearerFormat: JWT
|
|
166
|
+
description: JWT Bearer Authentication
|
|
167
|
+
|
|
168
|
+
ApiKeyAuth:
|
|
169
|
+
type: apiKey
|
|
170
|
+
in: header
|
|
171
|
+
name: x-api-key
|
|
172
|
+
description: API Key Authentication
|
|
173
|
+
|
|
174
|
+
OAuth2Auth:
|
|
175
|
+
type: oauth2
|
|
176
|
+
description: OAuth2 Authentication
|
|
177
|
+
flows:
|
|
178
|
+
implicit:
|
|
179
|
+
authorizationUrl: https://auth.example.com/oauth/authorize
|
|
180
|
+
scopes:
|
|
181
|
+
read: Read access
|
|
182
|
+
write: Write access
|
|
183
|
+
`);
|
|
184
|
+
|
|
185
|
+
const { isValid, errors } = validator.check(config);
|
|
186
|
+
|
|
187
|
+
expect(isValid).toBe(true);
|
|
188
|
+
expect(errors).toHaveLength(0);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should validate cookie-based auth', () => {
|
|
192
|
+
const config = parse(`
|
|
193
|
+
out: openapi/openapi.web.json
|
|
194
|
+
includeZones:
|
|
195
|
+
- api:web
|
|
196
|
+
title: Web API
|
|
197
|
+
version: '1.3'
|
|
198
|
+
description: Web API methods
|
|
199
|
+
security:
|
|
200
|
+
SessionCookie:
|
|
201
|
+
type: apiKey
|
|
202
|
+
in: cookie
|
|
203
|
+
name: sessionId
|
|
204
|
+
description: Cookie-based authentication
|
|
205
|
+
`);
|
|
206
|
+
|
|
207
|
+
const { isValid, errors } = validator.check(config);
|
|
208
|
+
|
|
209
|
+
expect(isValid).toBe(true);
|
|
210
|
+
expect(errors).toHaveLength(0);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe('Validation Errors', () => {
|
|
215
|
+
it('should fail on invalid security type', () => {
|
|
216
|
+
const config = parse(`
|
|
217
|
+
out: openapi.json
|
|
218
|
+
title: Test API
|
|
219
|
+
version: 1.0.0
|
|
220
|
+
description: Test API Description
|
|
221
|
+
security:
|
|
222
|
+
InvalidAuth:
|
|
223
|
+
type: invalid
|
|
224
|
+
`);
|
|
225
|
+
|
|
226
|
+
const { isValid, errors } = validator.check(config);
|
|
227
|
+
|
|
228
|
+
expect(isValid).toBe(false);
|
|
229
|
+
expect(errors).toHaveLength(2);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('should fail on missing required fields', () => {
|
|
233
|
+
const config = parse(`
|
|
234
|
+
out: openapi.json
|
|
235
|
+
title: Test API
|
|
236
|
+
description: Test API Description
|
|
237
|
+
`);
|
|
238
|
+
|
|
239
|
+
const { isValid, errors } = validator.check(config);
|
|
240
|
+
|
|
241
|
+
expect(isValid).toBe(true);
|
|
242
|
+
expect(errors).toHaveLength(0);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('should fail on invalid OAuth2 flow configuration', () => {
|
|
246
|
+
const config = parse(`
|
|
247
|
+
out: openapi.json
|
|
248
|
+
title: Test API
|
|
249
|
+
version: 1.0.0
|
|
250
|
+
description: Test API Description
|
|
251
|
+
security:
|
|
252
|
+
- type: oauth2
|
|
253
|
+
schemaName: OAuth2Auth
|
|
254
|
+
flows:
|
|
255
|
+
implicit:
|
|
256
|
+
scopes: invalid
|
|
257
|
+
`);
|
|
258
|
+
|
|
259
|
+
const { isValid, errors } = validator.check(config);
|
|
260
|
+
|
|
261
|
+
expect(isValid).toBe(false);
|
|
262
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { OpenApiOptions } from '@rsdk/http.openapi';
|
|
2
|
+
import type { Static } from '@sinclair/typebox';
|
|
3
|
+
import { Type } from '@sinclair/typebox';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration schema for OpenAPI document generation.
|
|
7
|
+
* @example
|
|
8
|
+
* {
|
|
9
|
+
* "out": "openapi.json",
|
|
10
|
+
* "app": "./dist/app.js",
|
|
11
|
+
* "title": "My API",
|
|
12
|
+
* "version": "1.0.0",
|
|
13
|
+
* "description": "API Description",
|
|
14
|
+
* "includeZones": ["public"],
|
|
15
|
+
* "excludeZones": ["internal"],
|
|
16
|
+
* "security": {
|
|
17
|
+
* "jwt": {
|
|
18
|
+
* "type": "http",
|
|
19
|
+
* "scheme": "bearer",
|
|
20
|
+
* "bearerFormat": "JWT",
|
|
21
|
+
* "name": "JWT Auth"
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export const OpenApiConfigSchema = Type.Intersect([
|
|
27
|
+
Type.Partial(OpenApiOptions),
|
|
28
|
+
Type.Object({
|
|
29
|
+
/** Output file path for the generated OpenAPI document */
|
|
30
|
+
out: Type.Optional(Type.String()),
|
|
31
|
+
|
|
32
|
+
/** Path to the application file (usually `dist/app.js`) */
|
|
33
|
+
app: Type.Optional(Type.String()),
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
export type OpenApiConfigSchema = Static<typeof OpenApiConfigSchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config.schema';
|