@nestia/migrate 0.9.7 → 0.10.0
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/lib/MigrateApplication.js +194 -100
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateMethodAnalyzer.js +31 -18
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -1
- package/lib/programmers/MigrateSchemaProgrammer.js +1 -1
- package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -1
- package/lib/structures/ISwaggerComponents.d.ts +5 -1
- package/lib/structures/ISwaggerRoute.d.ts +4 -33
- package/lib/structures/ISwaggerRouteBodyContent.d.ts +14 -0
- package/lib/structures/ISwaggerRouteBodyContent.js +3 -0
- package/lib/structures/ISwaggerRouteBodyContent.js.map +1 -0
- package/lib/structures/ISwaggerRouteHeader.js +2 -0
- package/lib/structures/ISwaggerRouteHeader.js.map +1 -0
- package/lib/structures/ISwaggerRouteRequestBody.d.ts +11 -0
- package/lib/structures/ISwaggerRouteRequestBody.js +3 -0
- package/lib/structures/ISwaggerRouteRequestBody.js.map +1 -0
- package/lib/structures/ISwaggerRouteResponse.d.ts +10 -0
- package/lib/structures/ISwaggerRouteResponse.js +3 -0
- package/lib/structures/ISwaggerRouteResponse.js.map +1 -0
- package/lib/utils/SwaggerComponentsExplorer.d.ts +9 -0
- package/lib/utils/SwaggerComponentsExplorer.js +29 -0
- package/lib/utils/SwaggerComponentsExplorer.js.map +1 -0
- package/lib/utils/SwaggerExplorer.d.ts +0 -0
- package/lib/utils/SwaggerExplorer.js +2 -0
- package/lib/utils/SwaggerExplorer.js.map +1 -0
- package/lib/utils/SwaggerTypeChecker.d.ts +0 -2
- package/lib/utils/SwaggerTypeChecker.js +0 -6
- package/lib/utils/SwaggerTypeChecker.js.map +1 -1
- package/package.json +1 -1
- package/src/analyzers/MigrateMethodAnalyzer.ts +59 -19
- package/src/bundles/NEST_TEMPLATE.ts +1 -1
- package/src/programmers/MigrateSchemaProgrammer.ts +4 -1
- package/src/structures/ISwaggerComponents.ts +5 -1
- package/src/structures/ISwaggerRoute.ts +7 -36
- package/src/structures/ISwaggerRouteBodyContent.ts +15 -0
- package/src/structures/ISwaggerRouteHeader.ts +0 -0
- package/src/structures/ISwaggerRouteRequestBody.ts +12 -0
- package/src/structures/ISwaggerRouteResponse.ts +11 -0
- package/src/utils/SwaggerComponentsExplorer.ts +43 -0
- package/src/utils/SwaggerTypeChecker.ts +0 -12
- /package/{src/structures/ISwaggerRouteHeaders.ts → lib/structures/ISwaggerRouteHeader.d.ts} +0 -0
@@ -5,9 +5,12 @@ import { IMigrateProgram } from "../structures/IMigrateProgram";
|
|
5
5
|
import { IMigrateRoute } from "../structures/IMigrateRoute";
|
6
6
|
import { ISwagger } from "../structures/ISwagger";
|
7
7
|
import { ISwaggerRoute } from "../structures/ISwaggerRoute";
|
8
|
+
import { ISwaggerRouteBodyContent } from "../structures/ISwaggerRouteBodyContent";
|
8
9
|
import { ISwaggerRouteParameter } from "../structures/ISwaggerRouteParameter";
|
10
|
+
import { ISwaggerRouteResponse } from "../structures/ISwaggerRouteResponse";
|
9
11
|
import { ISwaggerSchema } from "../structures/ISwaggerSchema";
|
10
12
|
import { StringUtil } from "../utils/StringUtil";
|
13
|
+
import { SwaggerComponentsExplorer } from "../utils/SwaggerComponentsExplorer";
|
11
14
|
import { SwaggerTypeChecker } from "../utils/SwaggerTypeChecker";
|
12
15
|
|
13
16
|
export namespace MigrateMethodAnalzyer {
|
@@ -21,19 +24,46 @@ export namespace MigrateMethodAnalzyer {
|
|
21
24
|
const success = emplaceBodySchema("response")(
|
22
25
|
emplaceReference(props.swagger)("response"),
|
23
26
|
)(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
(() => {
|
28
|
+
const response =
|
29
|
+
route.responses?.["201"] ??
|
30
|
+
route.responses?.["200"] ??
|
31
|
+
route.responses?.default;
|
32
|
+
if (response === undefined) return undefined;
|
33
|
+
SwaggerComponentsExplorer.getResponse(props.swagger.components)(
|
34
|
+
response,
|
35
|
+
) ?? undefined;
|
36
|
+
})(),
|
27
37
|
);
|
28
38
|
|
29
39
|
const failures: string[] = [];
|
30
40
|
for (const p of route.parameters ?? [])
|
31
41
|
if (
|
32
|
-
|
42
|
+
SwaggerComponentsExplorer.getParameter(props.swagger.components)(
|
43
|
+
p,
|
44
|
+
) === null
|
33
45
|
)
|
34
46
|
failures.push(
|
35
47
|
`parameter "${(p as ISwaggerRouteParameter.IReference).$ref}" is not defined in "components.parameters".`,
|
36
48
|
);
|
49
|
+
for (const value of Object.values(route.responses ?? {}))
|
50
|
+
if (
|
51
|
+
SwaggerComponentsExplorer.getResponse(props.swagger.components)(
|
52
|
+
value,
|
53
|
+
) === null
|
54
|
+
)
|
55
|
+
failures.push(
|
56
|
+
`response "${(value as ISwaggerRouteResponse.IReference).$ref}" is not defined in "components.responses".`,
|
57
|
+
);
|
58
|
+
if (
|
59
|
+
route.requestBody &&
|
60
|
+
SwaggerComponentsExplorer.getRequestBody(props.swagger.components)(
|
61
|
+
route.requestBody,
|
62
|
+
) === null
|
63
|
+
)
|
64
|
+
failures.push(
|
65
|
+
`requestBody "${(route.requestBody as ISwaggerRouteParameter.IReference).$ref}" is not defined in "components.requestBodies".`,
|
66
|
+
);
|
37
67
|
if (body === false)
|
38
68
|
failures.push(
|
39
69
|
`supports only "application/json", "application/x-www-form-urlencoded", "multipart/form-data" and "text/plain" content type in the request body.`,
|
@@ -51,12 +81,15 @@ export namespace MigrateMethodAnalzyer {
|
|
51
81
|
const parameters: ISwaggerRouteParameter[] = (route.parameters ?? [])
|
52
82
|
.filter(
|
53
83
|
(p) =>
|
54
|
-
|
55
|
-
|
84
|
+
SwaggerComponentsExplorer.getParameter(props.swagger.components)(
|
85
|
+
p,
|
86
|
+
)?.in === type,
|
56
87
|
)
|
57
88
|
.map(
|
58
89
|
(p) =>
|
59
|
-
|
90
|
+
SwaggerComponentsExplorer.getParameter(props.swagger.components)(
|
91
|
+
p,
|
92
|
+
)!,
|
60
93
|
);
|
61
94
|
if (parameters.length === 0) return null;
|
62
95
|
|
@@ -170,8 +203,8 @@ export namespace MigrateMethodAnalzyer {
|
|
170
203
|
parameterNames.length !==
|
171
204
|
(route.parameters ?? []).filter(
|
172
205
|
(p) =>
|
173
|
-
|
174
|
-
|
206
|
+
SwaggerComponentsExplorer.getParameter(props.swagger.components)(p)
|
207
|
+
?.in === "path",
|
175
208
|
).length
|
176
209
|
)
|
177
210
|
failures.push(
|
@@ -200,7 +233,7 @@ export namespace MigrateMethodAnalzyer {
|
|
200
233
|
: null,
|
201
234
|
parameters: (route.parameters ?? [])
|
202
235
|
.map((p) =>
|
203
|
-
|
236
|
+
SwaggerComponentsExplorer.getParameter(props.swagger.components)(p),
|
204
237
|
)
|
205
238
|
.filter((p) => p !== null && p.in === "path")
|
206
239
|
.map((p, i) => ({
|
@@ -234,15 +267,22 @@ export namespace MigrateMethodAnalzyer {
|
|
234
267
|
key !== "200" &&
|
235
268
|
key !== "201" &&
|
236
269
|
key !== "default" &&
|
237
|
-
!!
|
270
|
+
!!SwaggerComponentsExplorer.getResponse(
|
271
|
+
props.swagger.components,
|
272
|
+
)(value)?.content?.["application/json"],
|
238
273
|
)
|
239
|
-
.map(([key, value]) =>
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
274
|
+
.map(([key, value]) => {
|
275
|
+
const r = SwaggerComponentsExplorer.getResponse(
|
276
|
+
props.swagger.components,
|
277
|
+
)(value)!;
|
278
|
+
return [
|
279
|
+
key,
|
280
|
+
{
|
281
|
+
description: r.description,
|
282
|
+
schema: r.content?.["application/json"]?.schema ?? {},
|
283
|
+
},
|
284
|
+
];
|
285
|
+
}),
|
246
286
|
),
|
247
287
|
deprecated: route.deprecated ?? false,
|
248
288
|
comment: () => describe(props.swagger)(route),
|
@@ -314,7 +354,7 @@ export namespace MigrateMethodAnalzyer {
|
|
314
354
|
(emplacer: (schema: ISwaggerSchema) => ISwaggerSchema.IReference) =>
|
315
355
|
(meta?: {
|
316
356
|
description?: string;
|
317
|
-
content?:
|
357
|
+
content?: ISwaggerRouteBodyContent;
|
318
358
|
"x-nestia-encrypted"?: boolean;
|
319
359
|
}): false | null | IMigrateRoute.IBody => {
|
320
360
|
if (!meta?.content) return null;
|
@@ -47,7 +47,7 @@ export const NEST_TEMPLATE = [
|
|
47
47
|
{
|
48
48
|
"location": "",
|
49
49
|
"file": "package.json",
|
50
|
-
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.2\",\r\n \"@nestia/sdk\": \"^2.5.16\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^6.19.1\",\r\n \"@typescript-eslint/parser\": \"^6.19.1\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^2.0.0\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.3.0\",\r\n \"prettier\": \"^3.2.4\",\r\n \"prettier-plugin-prisma\": \"^5.0.0\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.3.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.5.16\",\r\n \"@nestia/fetcher\": \"^2.5.16\",\r\n \"@nestjs/common\": \"^10.3.
|
50
|
+
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.2\",\r\n \"@nestia/sdk\": \"^2.5.16\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^6.19.1\",\r\n \"@typescript-eslint/parser\": \"^6.19.1\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^2.0.0\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.3.0\",\r\n \"prettier\": \"^3.2.4\",\r\n \"prettier-plugin-prisma\": \"^5.0.0\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.3.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.5.16\",\r\n \"@nestia/fetcher\": \"^2.5.16\",\r\n \"@nestjs/common\": \"^10.3.5\",\r\n \"@nestjs/core\": \"^10.3.5\",\r\n \"@nestjs/platform-express\": \"^10.3.5\",\r\n \"commander\": \"10.0.0\",\r\n \"dotenv\": \"^16.3.1\",\r\n \"dotenv-expand\": \"^10.0.0\",\r\n \"inquirer\": \"8.2.5\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^5.5.7\",\r\n \"uuid\": \"^9.0.0\"\r\n },\r\n \"stackblitz\": {\r\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\r\n }\r\n}"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"location": "packages/api",
|
@@ -239,7 +239,10 @@ export namespace MigrateSchemaProgrammer {
|
|
239
239
|
const name: string = schema.$ref.split("/").at(-1)!;
|
240
240
|
return name === ""
|
241
241
|
? TypeFactory.keyword("any")
|
242
|
-
: importer.dto(
|
242
|
+
: importer.dto(
|
243
|
+
schema.$ref.split("/").at(-1)!,
|
244
|
+
components["x-nestia-namespace"],
|
245
|
+
);
|
243
246
|
};
|
244
247
|
|
245
248
|
/* -----------------------------------------------------------
|
@@ -1,10 +1,14 @@
|
|
1
1
|
import { ISwaggerRouteParameter } from "./ISwaggerRouteParameter";
|
2
|
+
import { ISwaggerRouteRequestBody } from "./ISwaggerRouteRequestBody";
|
3
|
+
import { ISwaggerRouteResponse } from "./ISwaggerRouteResponse";
|
2
4
|
import { ISwaggerSchema } from "./ISwaggerSchema";
|
3
5
|
import { ISwaggerSecurityScheme } from "./ISwaggerSecurityScheme";
|
4
6
|
|
5
7
|
export interface ISwaggerComponents {
|
6
8
|
parameters?: Record<string, ISwaggerRouteParameter>;
|
9
|
+
requestBodies?: Record<string, ISwaggerRouteRequestBody>;
|
10
|
+
responses?: Record<string, ISwaggerRouteResponse>;
|
7
11
|
schemas?: Record<string, ISwaggerSchema>;
|
8
12
|
securitySchemes?: Record<string, ISwaggerSecurityScheme>;
|
9
|
-
namespace?: string;
|
13
|
+
"x-nestia-namespace"?: string;
|
10
14
|
}
|
@@ -1,12 +1,16 @@
|
|
1
1
|
import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
|
2
2
|
|
3
3
|
import { ISwaggerRouteParameter } from "./ISwaggerRouteParameter";
|
4
|
-
import {
|
4
|
+
import { ISwaggerRouteRequestBody } from "./ISwaggerRouteRequestBody";
|
5
|
+
import { ISwaggerRouteResponse } from "./ISwaggerRouteResponse";
|
5
6
|
|
6
7
|
export interface ISwaggerRoute {
|
7
8
|
parameters?: (ISwaggerRouteParameter | ISwaggerRouteParameter.IReference)[];
|
8
|
-
requestBody?:
|
9
|
-
responses?:
|
9
|
+
requestBody?: ISwaggerRouteRequestBody;
|
10
|
+
responses?: Record<
|
11
|
+
string,
|
12
|
+
ISwaggerRouteResponse | ISwaggerRouteResponse.IReference
|
13
|
+
>;
|
10
14
|
summary?: string;
|
11
15
|
description?: string;
|
12
16
|
deprecated?: boolean;
|
@@ -14,36 +18,3 @@ export interface ISwaggerRoute {
|
|
14
18
|
tags?: string[];
|
15
19
|
"x-nestia-jsDocTags"?: IJsDocTagInfo[];
|
16
20
|
}
|
17
|
-
export namespace ISwaggerRoute {
|
18
|
-
export interface IRequestBody {
|
19
|
-
description?: string;
|
20
|
-
content: IContent;
|
21
|
-
required?: boolean;
|
22
|
-
"x-nestia-encrypted"?: boolean;
|
23
|
-
}
|
24
|
-
export type IResponseBody = Record<
|
25
|
-
string,
|
26
|
-
{
|
27
|
-
description?: string;
|
28
|
-
content?: IContent;
|
29
|
-
"x-nestia-encrypted"?: boolean;
|
30
|
-
}
|
31
|
-
>;
|
32
|
-
export interface IContent {
|
33
|
-
"text/plain"?: {
|
34
|
-
schema: ISwaggerSchema;
|
35
|
-
};
|
36
|
-
"application/json"?: {
|
37
|
-
schema: ISwaggerSchema;
|
38
|
-
};
|
39
|
-
"application/x-www-form-urlencoded"?: {
|
40
|
-
schema: ISwaggerSchema;
|
41
|
-
};
|
42
|
-
"multipart/form-data"?: {
|
43
|
-
schema: ISwaggerSchema;
|
44
|
-
};
|
45
|
-
"*/*"?: {
|
46
|
-
schema: ISwaggerSchema;
|
47
|
-
};
|
48
|
-
}
|
49
|
-
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { ISwaggerSchema } from "./ISwaggerSchema";
|
2
|
+
|
3
|
+
export interface ISwaggerRouteBodyContent {
|
4
|
+
"text/plain"?: ISwaggerRouteBodyContent.IMediaType;
|
5
|
+
"application/json"?: ISwaggerRouteBodyContent.IMediaType;
|
6
|
+
"application/x-www-form-urlencoded"?: ISwaggerRouteBodyContent.IMediaType;
|
7
|
+
"multipart/form-data"?: ISwaggerRouteBodyContent.IMediaType;
|
8
|
+
"*/*"?: ISwaggerRouteBodyContent.IMediaType;
|
9
|
+
}
|
10
|
+
export namespace ISwaggerRouteBodyContent {
|
11
|
+
export interface IMediaType {
|
12
|
+
schema?: ISwaggerSchema;
|
13
|
+
"x-nestia-encrypted"?: boolean;
|
14
|
+
}
|
15
|
+
}
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ISwaggerRouteBodyContent } from "./ISwaggerRouteBodyContent";
|
2
|
+
|
3
|
+
export interface ISwaggerRouteRequestBody {
|
4
|
+
description?: string;
|
5
|
+
required?: boolean;
|
6
|
+
content?: ISwaggerRouteBodyContent;
|
7
|
+
}
|
8
|
+
export namespace ISwaggerRouteRequestBody {
|
9
|
+
export interface IReference {
|
10
|
+
$ref: `#/components/requestBodies/${string}`;
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ISwaggerRouteBodyContent } from "./ISwaggerRouteBodyContent";
|
2
|
+
|
3
|
+
export interface ISwaggerRouteResponse {
|
4
|
+
description?: string;
|
5
|
+
content?: ISwaggerRouteBodyContent;
|
6
|
+
}
|
7
|
+
export namespace ISwaggerRouteResponse {
|
8
|
+
export interface IReference {
|
9
|
+
$ref: `#/components/responses/${string}`;
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { ISwaggerComponents } from "../module";
|
2
|
+
import { ISwaggerRouteParameter } from "../structures/ISwaggerRouteParameter";
|
3
|
+
import { ISwaggerRouteRequestBody } from "../structures/ISwaggerRouteRequestBody";
|
4
|
+
import { ISwaggerRouteResponse } from "../structures/ISwaggerRouteResponse";
|
5
|
+
import { SwaggerTypeChecker } from "./SwaggerTypeChecker";
|
6
|
+
|
7
|
+
export namespace SwaggerComponentsExplorer {
|
8
|
+
export const getParameter =
|
9
|
+
(components: ISwaggerComponents) =>
|
10
|
+
(
|
11
|
+
schema: ISwaggerRouteParameter | ISwaggerRouteParameter.IReference,
|
12
|
+
): ISwaggerRouteParameter | null =>
|
13
|
+
SwaggerTypeChecker.isReference(schema) &&
|
14
|
+
schema.$ref.startsWith("#/components/parameters/")
|
15
|
+
? components.parameters?.[
|
16
|
+
schema.$ref.replace("#/components/parameters/", "")
|
17
|
+
] ?? null
|
18
|
+
: (schema as ISwaggerRouteParameter);
|
19
|
+
|
20
|
+
export const getRequestBody =
|
21
|
+
(components: ISwaggerComponents) =>
|
22
|
+
(
|
23
|
+
schema: ISwaggerRouteRequestBody | ISwaggerRouteRequestBody.IReference,
|
24
|
+
): ISwaggerRouteRequestBody | null =>
|
25
|
+
SwaggerTypeChecker.isReference(schema) &&
|
26
|
+
schema.$ref.startsWith("#/components/requestBodies/")
|
27
|
+
? components.requestBodies?.[
|
28
|
+
schema.$ref.replace("#/components/requestBodies/", "")
|
29
|
+
] ?? null
|
30
|
+
: (schema as ISwaggerRouteRequestBody);
|
31
|
+
|
32
|
+
export const getResponse =
|
33
|
+
(components: ISwaggerComponents) =>
|
34
|
+
(
|
35
|
+
schema: ISwaggerRouteResponse | ISwaggerRouteResponse.IReference,
|
36
|
+
): ISwaggerRouteResponse | null =>
|
37
|
+
SwaggerTypeChecker.isReference(schema) &&
|
38
|
+
schema.$ref.startsWith("#/components/responses/")
|
39
|
+
? components.responses?.[
|
40
|
+
schema.$ref.replace("#/components/responses/", "")
|
41
|
+
] ?? null
|
42
|
+
: (schema as ISwaggerRouteResponse);
|
43
|
+
}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
2
|
-
import { ISwaggerRouteParameter } from "../structures/ISwaggerRouteParameter";
|
3
2
|
import { ISwaggerSchema } from "../structures/ISwaggerSchema";
|
4
3
|
|
5
4
|
export namespace SwaggerTypeChecker {
|
@@ -65,15 +64,4 @@ export namespace SwaggerTypeChecker {
|
|
65
64
|
}
|
66
65
|
return (schema as ISwaggerSchema.IString).nullable === true;
|
67
66
|
};
|
68
|
-
|
69
|
-
export const getParameter =
|
70
|
-
(components: ISwaggerComponents) =>
|
71
|
-
(
|
72
|
-
schema: ISwaggerRouteParameter | ISwaggerRouteParameter.IReference,
|
73
|
-
): ISwaggerRouteParameter | null =>
|
74
|
-
isReference(schema) && schema.$ref.startsWith("#/components/parameters/")
|
75
|
-
? components.parameters?.[
|
76
|
-
schema.$ref.replace("#/components/parameters/", "")
|
77
|
-
] ?? null
|
78
|
-
: (schema as ISwaggerRouteParameter);
|
79
67
|
}
|
File without changes
|