@nestia/core 11.0.2 → 11.1.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/decorators/EncryptedBody.js +2 -2
- package/lib/decorators/EncryptedBody.js.map +1 -1
- package/lib/decorators/EncryptedRoute.js +2 -2
- package/lib/decorators/EncryptedRoute.js.map +1 -1
- package/lib/decorators/SwaggerExample.d.ts +80 -0
- package/lib/decorators/SwaggerExample.js +38 -0
- package/lib/decorators/SwaggerExample.js.map +1 -1
- package/lib/decorators/internal/load_controller.js +1 -34
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/package.json +3 -3
- package/src/decorators/EncryptedBody.ts +2 -1
- package/src/decorators/EncryptedRoute.ts +2 -1
- package/src/decorators/SwaggerExample.ts +80 -0
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EncryptedBody = EncryptedBody;
|
|
13
|
-
const
|
|
13
|
+
const AesPkcs5_1 = require("@nestia/fetcher/lib/AesPkcs5");
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const Singleton_1 = require("../utils/Singleton");
|
|
16
16
|
const EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
@@ -68,7 +68,7 @@ function EncryptedBody(validator) {
|
|
|
68
68
|
/** @internal */
|
|
69
69
|
const decrypt = (body, key, iv) => {
|
|
70
70
|
try {
|
|
71
|
-
return
|
|
71
|
+
return AesPkcs5_1.AesPkcs5.decrypt(body, key, iv);
|
|
72
72
|
}
|
|
73
73
|
catch (exp) {
|
|
74
74
|
if (exp instanceof Error)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedBody.js","sourceRoot":"","sources":["../../src/decorators/EncryptedBody.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":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AM,IAAI,GAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YACvE,MAAM,KAAK,GAAiB,OAAO,CAAC,IAAI,CAAC,CAAC;YAC1C,IAAI,KAAK,KAAK,IAAI;gBAAE,MAAM,KAAK,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;KAAA,CAAC,EAAE,CAAC;AACP,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU,EAAU,EAAE;IAChE,IAAI,CAAC;QACH,OAAO,mBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,KAAK;YACtB,MAAM,IAAI,4BAAmB,CAC3B,qFAAqF,CACtF,CAAC;;YACC,MAAM,GAAG,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,GAAG,CAAC,IAAa,EAAW,EAAE,CAC7C,IAAI,KAAK,SAAS;IAClB,IAAI;SACD,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACxB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,YAAY,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.EncryptedRoute = void 0;
|
|
7
|
-
const
|
|
7
|
+
const AesPkcs5_1 = require("@nestia/fetcher/lib/AesPkcs5");
|
|
8
8
|
const common_1 = require("@nestjs/common");
|
|
9
9
|
const operators_1 = require("rxjs/operators");
|
|
10
10
|
const typia_1 = __importDefault(require("typia"));
|
|
@@ -139,7 +139,7 @@ class EncryptedRouteInterceptor {
|
|
|
139
139
|
: param;
|
|
140
140
|
if (body === undefined)
|
|
141
141
|
return body;
|
|
142
|
-
return
|
|
142
|
+
return AesPkcs5_1.AesPkcs5.encrypt(body, password.key, password.iv);
|
|
143
143
|
}), (0, operators_1.catchError)((err) => (0, route_error_1.route_error)(http.getRequest(), err)));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedRoute.js","sourceRoot":"","sources":["../../src/decorators/EncryptedRoute.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"EncryptedRoute.js","sourceRoot":"","sources":["../../src/decorators/EncryptedRoute.ts"],"names":[],"mappings":";;;;;;AACA,2DAAwD;AACxD,2CAWwB;AAGxB,8CAAiD;AACjD,kDAA0B;AAG1B,kDAA+C;AAC/C,6CAA0C;AAC1C,oEAAuE;AACvE,8EAA2E;AAC3E,oEAAiE;AACjE,wDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,IAAiB,cAAc,CAsF9B;AAtFD,WAAiB,cAAc;IAC7B;;;;;OAKG;IACU,kBAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAEpC;;;;;OAKG;IACU,mBAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAEtC;;;;;OAKG;IACU,oBAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAExC;;;;;OAKG;IACU,kBAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAEpC;;;;;OAKG;IACU,qBAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE1C;;;;;;;;;;;;;;OAcG;IACH,SAAgB,sBAAsB,CACpC,IAAsC;QAEtC,uBAAU,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAJe,qCAAsB,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;IACH,KAAK,EAAL,cAAK;IACL,MAAM,EAAN,eAAM;CACP,CAAC"}
|
|
@@ -1,8 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attach example values to Swagger documents.
|
|
3
|
+
*
|
|
4
|
+
* `SwaggerExample` is a namespace of decorators that attach example values
|
|
5
|
+
* to controller methods (request/response bodies, parameters), so that
|
|
6
|
+
* `@nestia/sdk`'s Swagger generator can populate the `example` / `examples`
|
|
7
|
+
* fields of the generated OpenAPI document.
|
|
8
|
+
*
|
|
9
|
+
* The decorators only affect Swagger document generation. They do not change
|
|
10
|
+
* runtime behavior, validation, or SDK function signatures.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import core from "@nestia/core";
|
|
16
|
+
* import { Controller } from "@nestjs/common";
|
|
17
|
+
* import typia from "typia";
|
|
18
|
+
*
|
|
19
|
+
* @Controller("bbs/articles")
|
|
20
|
+
* export class BbsArticlesController {
|
|
21
|
+
* // Single response example.
|
|
22
|
+
* @core.SwaggerExample.Response(typia.random<IBbsArticle>())
|
|
23
|
+
* @core.TypedRoute.Post()
|
|
24
|
+
* public async create(
|
|
25
|
+
* // Multiple named parameter examples plus a default one.
|
|
26
|
+
* @core.SwaggerExample.Parameter(typia.random<IBbsArticle.ICreate>())
|
|
27
|
+
* @core.SwaggerExample.Parameter("x", typia.random<IBbsArticle.ICreate>())
|
|
28
|
+
* @core.SwaggerExample.Parameter("y", typia.random<IBbsArticle.ICreate>())
|
|
29
|
+
* @core.TypedBody()
|
|
30
|
+
* input: IBbsArticle.ICreate,
|
|
31
|
+
* ): Promise<IBbsArticle> {
|
|
32
|
+
* // ...
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
38
|
+
*/
|
|
1
39
|
export declare namespace SwaggerExample {
|
|
40
|
+
/**
|
|
41
|
+
* Attach an example value to the response body of a controller method.
|
|
42
|
+
*
|
|
43
|
+
* Two forms are supported:
|
|
44
|
+
*
|
|
45
|
+
* - {@link Response | `Response(value)`}: registers `value` as the single
|
|
46
|
+
* default `example`.
|
|
47
|
+
* - {@link Response | `Response(key, value)`}: registers `value` under
|
|
48
|
+
* `examples[key]`. May be applied multiple times to attach several
|
|
49
|
+
* named examples.
|
|
50
|
+
*
|
|
51
|
+
* Both forms can coexist on the same method — the default `example` and
|
|
52
|
+
* any number of named `examples` will all surface in the generated
|
|
53
|
+
* Swagger document.
|
|
54
|
+
*
|
|
55
|
+
* @template T Type of the example value (typically the route's response DTO).
|
|
56
|
+
*/
|
|
2
57
|
function Response<T>(value: T): MethodDecorator;
|
|
3
58
|
function Response<T>(key: string, value: T): MethodDecorator;
|
|
59
|
+
/**
|
|
60
|
+
* Attach an example value to a request parameter (body, path, query, etc.)
|
|
61
|
+
* of a controller method.
|
|
62
|
+
*
|
|
63
|
+
* Two forms are supported:
|
|
64
|
+
*
|
|
65
|
+
* - {@link Parameter | `Parameter(value)`}: registers `value` as the single
|
|
66
|
+
* default `example` for that parameter.
|
|
67
|
+
* - {@link Parameter | `Parameter(key, value)`}: registers `value` under
|
|
68
|
+
* `examples[key]`. May be applied multiple times to attach several
|
|
69
|
+
* named examples to the same parameter.
|
|
70
|
+
*
|
|
71
|
+
* Apply alongside the actual parameter decorator
|
|
72
|
+
* (`@TypedBody()`, `@TypedParam()`, `@TypedQuery()`, etc.); decorator
|
|
73
|
+
* order does not matter.
|
|
74
|
+
*
|
|
75
|
+
* @template T Type of the example value (typically the parameter's DTO).
|
|
76
|
+
*/
|
|
4
77
|
function Parameter<T>(value: T): ParameterDecorator;
|
|
5
78
|
function Parameter<T>(key: string, value: T): ParameterDecorator;
|
|
79
|
+
/**
|
|
80
|
+
* Internal storage shape for `SwaggerExample` metadata.
|
|
81
|
+
*
|
|
82
|
+
* Reflects the OpenAPI spec's two example fields: a single default
|
|
83
|
+
* `example`, and/or a named map `examples`. `index` is used internally
|
|
84
|
+
* to associate parameter examples with the right parameter position.
|
|
85
|
+
*/
|
|
6
86
|
interface IData<T> {
|
|
7
87
|
examples?: Record<string, T>;
|
|
8
88
|
example?: T;
|
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwaggerExample = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Attach example values to Swagger documents.
|
|
6
|
+
*
|
|
7
|
+
* `SwaggerExample` is a namespace of decorators that attach example values
|
|
8
|
+
* to controller methods (request/response bodies, parameters), so that
|
|
9
|
+
* `@nestia/sdk`'s Swagger generator can populate the `example` / `examples`
|
|
10
|
+
* fields of the generated OpenAPI document.
|
|
11
|
+
*
|
|
12
|
+
* The decorators only affect Swagger document generation. They do not change
|
|
13
|
+
* runtime behavior, validation, or SDK function signatures.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import core from "@nestia/core";
|
|
19
|
+
* import { Controller } from "@nestjs/common";
|
|
20
|
+
* import typia from "typia";
|
|
21
|
+
*
|
|
22
|
+
* @Controller("bbs/articles")
|
|
23
|
+
* export class BbsArticlesController {
|
|
24
|
+
* // Single response example.
|
|
25
|
+
* @core.SwaggerExample.Response(typia.random<IBbsArticle>())
|
|
26
|
+
* @core.TypedRoute.Post()
|
|
27
|
+
* public async create(
|
|
28
|
+
* // Multiple named parameter examples plus a default one.
|
|
29
|
+
* @core.SwaggerExample.Parameter(typia.random<IBbsArticle.ICreate>())
|
|
30
|
+
* @core.SwaggerExample.Parameter("x", typia.random<IBbsArticle.ICreate>())
|
|
31
|
+
* @core.SwaggerExample.Parameter("y", typia.random<IBbsArticle.ICreate>())
|
|
32
|
+
* @core.TypedBody()
|
|
33
|
+
* input: IBbsArticle.ICreate,
|
|
34
|
+
* ): Promise<IBbsArticle> {
|
|
35
|
+
* // ...
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
41
|
+
*/
|
|
4
42
|
var SwaggerExample;
|
|
5
43
|
(function (SwaggerExample) {
|
|
6
44
|
function Response(...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwaggerExample.js","sourceRoot":"","sources":["../../src/decorators/SwaggerExample.ts"],"names":[],"mappings":";;;AAAA,IAAiB,cAAc,
|
|
1
|
+
{"version":3,"file":"SwaggerExample.js","sourceRoot":"","sources":["../../src/decorators/SwaggerExample.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,IAAiB,cAAc,CAyE9B;AAzED,WAAiB,cAAc;IAoB7B,SAAgB,QAAQ,CAAC,GAAG,IAAW;QACrC,OAAO,SAAS,sBAAsB,CACpC,OAAe,EACf,YAA6B,EAC7B,UAAwC;YAExC,YAAY,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC;IATe,uBAAQ,WASvB,CAAA;IAsBD,SAAgB,SAAS,CAAC,GAAG,IAAW;QACtC,OAAO,SAAS,uBAAuB,CACrC,MAAc,EACd,WAAwC,EACxC,KAAa;YAEb,YAAY,CAAC,kBAAkB,CAAC,MAAM,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3E,CAAC,CAAC;IACJ,CAAC;IARe,wBAAS,YAQxB,CAAA;AAcH,CAAC,EAzEgB,cAAc,8BAAd,cAAc,QAyE9B;AAED,MAAM,YAAY,GAChB,CAAI,IAA6B,EAAE,EAAE,CACrC,CAAC,IAAW,EAAE,EAAE;;IACd,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAA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C/B,MAAM,KAAK,GAA4C,OAAO,CAAC,WAAW,CACxE,kCAAkC,EAClC,MAAM,EACN,WAAW,CACZ,CAAC;IACF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,MAAM,MAAM,GAAgC,EAAE,CAAC;IAC/C,OAAO,CAAC,cAAc,CACpB,kCAAkC,EAClC,MAAM,EACN,MAAM,EACN,WAAW,CACZ,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,37 +1,4 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -72,7 +39,7 @@ function mount(sources) {
|
|
|
72
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
40
|
const controllers = [];
|
|
74
41
|
for (const file of sources) {
|
|
75
|
-
const external = yield
|
|
42
|
+
const external = yield import(file);
|
|
76
43
|
for (const key in external) {
|
|
77
44
|
const instance = external[key];
|
|
78
45
|
if (Reflect.getMetadata("path", instance) !== undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load_controller.js","sourceRoot":"","sources":["../../../src/decorators/internal/load_controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load_controller.js","sourceRoot":"","sources":["../../../src/decorators/internal/load_controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAAwC;AAGxC,2DAAwD;AAEjD,MAAM,gBAAgB,GAAG,CAC9B,IAAmE,EACnE,QAAkB,EACU,EAAE;;IAC9B,MAAM,OAAO,GAAa,MAAM,2BAAY,CAAC,IAAI,CAAC;QAChD,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAC1B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ;gBACxB,CAAC,CAAC,IAAI,CAAC,OAAO;gBACd,CAAC,CAAC,CAAC,IAAI,CAAC;QACZ,OAAO,EACL,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO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 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/core",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"tgrid": "^1.1.0",
|
|
53
53
|
"typia": "^12.0.0",
|
|
54
54
|
"ws": "^7.5.3",
|
|
55
|
-
"@nestia/fetcher": "^11.0
|
|
55
|
+
"@nestia/fetcher": "^11.1.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@nestjs/common": ">=7.0.1",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"reflect-metadata": ">=0.1.12",
|
|
61
61
|
"rxjs": ">=6.0.3",
|
|
62
62
|
"typia": "^12.0.0",
|
|
63
|
-
"@nestia/fetcher": "^11.0
|
|
63
|
+
"@nestia/fetcher": "^11.1.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@nestjs/common": "^11.1.6",
|
|
@@ -1,4 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attach example values to Swagger documents.
|
|
3
|
+
*
|
|
4
|
+
* `SwaggerExample` is a namespace of decorators that attach example values
|
|
5
|
+
* to controller methods (request/response bodies, parameters), so that
|
|
6
|
+
* `@nestia/sdk`'s Swagger generator can populate the `example` / `examples`
|
|
7
|
+
* fields of the generated OpenAPI document.
|
|
8
|
+
*
|
|
9
|
+
* The decorators only affect Swagger document generation. They do not change
|
|
10
|
+
* runtime behavior, validation, or SDK function signatures.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import core from "@nestia/core";
|
|
16
|
+
* import { Controller } from "@nestjs/common";
|
|
17
|
+
* import typia from "typia";
|
|
18
|
+
*
|
|
19
|
+
* @Controller("bbs/articles")
|
|
20
|
+
* export class BbsArticlesController {
|
|
21
|
+
* // Single response example.
|
|
22
|
+
* @core.SwaggerExample.Response(typia.random<IBbsArticle>())
|
|
23
|
+
* @core.TypedRoute.Post()
|
|
24
|
+
* public async create(
|
|
25
|
+
* // Multiple named parameter examples plus a default one.
|
|
26
|
+
* @core.SwaggerExample.Parameter(typia.random<IBbsArticle.ICreate>())
|
|
27
|
+
* @core.SwaggerExample.Parameter("x", typia.random<IBbsArticle.ICreate>())
|
|
28
|
+
* @core.SwaggerExample.Parameter("y", typia.random<IBbsArticle.ICreate>())
|
|
29
|
+
* @core.TypedBody()
|
|
30
|
+
* input: IBbsArticle.ICreate,
|
|
31
|
+
* ): Promise<IBbsArticle> {
|
|
32
|
+
* // ...
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
38
|
+
*/
|
|
1
39
|
export namespace SwaggerExample {
|
|
40
|
+
/**
|
|
41
|
+
* Attach an example value to the response body of a controller method.
|
|
42
|
+
*
|
|
43
|
+
* Two forms are supported:
|
|
44
|
+
*
|
|
45
|
+
* - {@link Response | `Response(value)`}: registers `value` as the single
|
|
46
|
+
* default `example`.
|
|
47
|
+
* - {@link Response | `Response(key, value)`}: registers `value` under
|
|
48
|
+
* `examples[key]`. May be applied multiple times to attach several
|
|
49
|
+
* named examples.
|
|
50
|
+
*
|
|
51
|
+
* Both forms can coexist on the same method — the default `example` and
|
|
52
|
+
* any number of named `examples` will all surface in the generated
|
|
53
|
+
* Swagger document.
|
|
54
|
+
*
|
|
55
|
+
* @template T Type of the example value (typically the route's response DTO).
|
|
56
|
+
*/
|
|
2
57
|
export function Response<T>(value: T): MethodDecorator;
|
|
3
58
|
export function Response<T>(key: string, value: T): MethodDecorator;
|
|
4
59
|
export function Response(...args: any[]): MethodDecorator {
|
|
@@ -12,6 +67,24 @@ export namespace SwaggerExample {
|
|
|
12
67
|
};
|
|
13
68
|
}
|
|
14
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Attach an example value to a request parameter (body, path, query, etc.)
|
|
72
|
+
* of a controller method.
|
|
73
|
+
*
|
|
74
|
+
* Two forms are supported:
|
|
75
|
+
*
|
|
76
|
+
* - {@link Parameter | `Parameter(value)`}: registers `value` as the single
|
|
77
|
+
* default `example` for that parameter.
|
|
78
|
+
* - {@link Parameter | `Parameter(key, value)`}: registers `value` under
|
|
79
|
+
* `examples[key]`. May be applied multiple times to attach several
|
|
80
|
+
* named examples to the same parameter.
|
|
81
|
+
*
|
|
82
|
+
* Apply alongside the actual parameter decorator
|
|
83
|
+
* (`@TypedBody()`, `@TypedParam()`, `@TypedQuery()`, etc.); decorator
|
|
84
|
+
* order does not matter.
|
|
85
|
+
*
|
|
86
|
+
* @template T Type of the example value (typically the parameter's DTO).
|
|
87
|
+
*/
|
|
15
88
|
export function Parameter<T>(value: T): ParameterDecorator;
|
|
16
89
|
export function Parameter<T>(key: string, value: T): ParameterDecorator;
|
|
17
90
|
export function Parameter(...args: any[]): ParameterDecorator {
|
|
@@ -24,6 +97,13 @@ export namespace SwaggerExample {
|
|
|
24
97
|
};
|
|
25
98
|
}
|
|
26
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Internal storage shape for `SwaggerExample` metadata.
|
|
102
|
+
*
|
|
103
|
+
* Reflects the OpenAPI spec's two example fields: a single default
|
|
104
|
+
* `example`, and/or a named map `examples`. `index` is used internally
|
|
105
|
+
* to associate parameter examples with the right parameter position.
|
|
106
|
+
*/
|
|
27
107
|
export interface IData<T> {
|
|
28
108
|
examples?: Record<string, T>;
|
|
29
109
|
example?: T;
|