@zenofolio/hyper-decor 1.0.47 → 1.0.48
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/__internals/creators/request.creator.js +2 -2
- package/dist/__internals/creators/routes.creator.d.ts +1 -0
- package/dist/__internals/creators/routes.creator.js +2 -0
- package/dist/__internals/helpers/prepare.helper.d.ts +11 -0
- package/dist/__internals/helpers/prepare.helper.js +237 -0
- package/dist/__internals/utils/function.util.d.ts +1 -4
- package/dist/__internals/utils/function.util.js +22 -10
- package/dist/decorators/HyperApp.js +2 -209
- package/dist/decorators/Scope.js +1 -1
- package/dist/lib/openapi/collectors/class.collector.d.ts +9 -0
- package/dist/lib/openapi/collectors/class.collector.js +53 -0
- package/dist/lib/openapi/collectors/index.d.ts +3 -0
- package/dist/lib/openapi/collectors/index.js +19 -0
- package/dist/lib/openapi/collectors/method.collector.d.ts +3 -0
- package/dist/lib/openapi/collectors/method.collector.js +36 -0
- package/dist/lib/openapi/collectors/param.collector.d.ts +3 -0
- package/dist/lib/openapi/collectors/param.collector.js +27 -0
- package/dist/lib/openapi/constants.d.ts +46 -0
- package/dist/lib/openapi/constants.js +61 -0
- package/dist/lib/openapi/decorators/api-method.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-method.decorator.js +11 -0
- package/dist/lib/openapi/decorators/api-parameter.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-parameter.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-request-body.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-request-body.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-response.decodator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-response.decodator.js +10 -0
- package/dist/lib/openapi/decorators/api-security.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-security.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-tag.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-tag.decorator.js +10 -0
- package/dist/lib/openapi/decorators/index.d.ts +6 -0
- package/dist/lib/openapi/decorators/index.js +22 -0
- package/dist/lib/openapi/helpers/index.d.ts +6 -0
- package/dist/lib/openapi/helpers/index.js +22 -0
- package/dist/lib/openapi/helpers/method.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/method.helper.js +20 -0
- package/dist/lib/openapi/helpers/parameter.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/parameter.helper.js +16 -0
- package/dist/lib/openapi/helpers/request-body.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/request-body.helper.js +9 -0
- package/dist/lib/openapi/helpers/response.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/response.helper.js +18 -0
- package/dist/lib/openapi/helpers/security.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/security.helper.js +10 -0
- package/dist/lib/openapi/helpers/tag.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/tag.helper.js +10 -0
- package/dist/lib/openapi/index.d.ts +1 -0
- package/dist/lib/openapi/index.js +17 -0
- package/dist/lib/openapi/types.d.ts +131 -0
- package/dist/lib/openapi/types.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
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("./class.collector"), exports);
|
|
18
|
+
__exportStar(require("./method.collector"), exports);
|
|
19
|
+
__exportStar(require("./param.collector"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectMethodMetadata = collectMethodMetadata;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const param_collector_1 = require("./param.collector"); // Importamos el colector de parámetros
|
|
7
|
+
function collectMethodMetadata(target, methodName) {
|
|
8
|
+
const methodMetadata = {};
|
|
9
|
+
// Extraemos la metadata del método
|
|
10
|
+
const summary = Reflect.getMetadata(constants_1.METHOD_SUMMARY, target, methodName);
|
|
11
|
+
const operationId = Reflect.getMetadata(constants_1.METHOD_OPERATION_ID, target, methodName);
|
|
12
|
+
const tags = Reflect.getMetadata(constants_1.METHOD_TAGS, target, methodName);
|
|
13
|
+
// Extraemos las respuestas del método
|
|
14
|
+
const responses = Reflect.getMetadata(constants_1.RESPONSES, target, methodName) || {};
|
|
15
|
+
// Extraemos los parámetros del método
|
|
16
|
+
const parameters = (0, param_collector_1.collectParameterMetadata)(target, methodName);
|
|
17
|
+
// Extraemos la información del cuerpo de la solicitud
|
|
18
|
+
const requestBody = {
|
|
19
|
+
description: Reflect.getMetadata(constants_1.REQUEST_BODY_DESCRIPTION, target, methodName),
|
|
20
|
+
content: Reflect.getMetadata(constants_1.REQUEST_BODY_CONTENT, target, methodName),
|
|
21
|
+
};
|
|
22
|
+
// Asignamos las propiedades al objeto de metadata solo si existen
|
|
23
|
+
if (summary)
|
|
24
|
+
methodMetadata.summary = summary;
|
|
25
|
+
if (operationId)
|
|
26
|
+
methodMetadata.operationId = operationId;
|
|
27
|
+
if (tags)
|
|
28
|
+
methodMetadata.tags = tags;
|
|
29
|
+
if (responses && Object.keys(responses).length > 0)
|
|
30
|
+
methodMetadata.responses = responses;
|
|
31
|
+
if (parameters.length > 0)
|
|
32
|
+
methodMetadata.parameters = parameters;
|
|
33
|
+
if (requestBody.content)
|
|
34
|
+
methodMetadata.requestBody = requestBody;
|
|
35
|
+
return methodMetadata;
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectParameterMetadata = collectParameterMetadata;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const function_util_1 = require("../../../__internals/utils/function.util");
|
|
7
|
+
function collectParameterMetadata(target, methodName) {
|
|
8
|
+
const parameters = Reflect.getMetadata(constants_1.PARAMETERS, target, methodName) || [];
|
|
9
|
+
const methodParams = Reflect.getMetadata("design:paramtypes", target, methodName) || [];
|
|
10
|
+
// Intentamos obtener los nombres de los parámetros utilizando extractArgsNames
|
|
11
|
+
const paramNames = (0, function_util_1.extractArgsNames)(target[methodName]);
|
|
12
|
+
// Si no se encuentran parámetros en los metadatos y hay tipos de parámetros disponibles
|
|
13
|
+
if (parameters.length === 0 && methodParams.length > 0) {
|
|
14
|
+
methodParams.forEach((paramType, index) => {
|
|
15
|
+
const param = {
|
|
16
|
+
name: paramNames && paramNames[index] ? paramNames[index] : `param${index}`, // Asignamos nombre genérico o el nombre inferido
|
|
17
|
+
in: "query", // Definir el tipo de parámetro, se puede modificar según sea necesario
|
|
18
|
+
required: true,
|
|
19
|
+
schema: {
|
|
20
|
+
type: paramType.name.toLowerCase(), // Inferimos el tipo del parámetro
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
parameters.push(param);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return parameters;
|
|
27
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const OPENAPI_VERSION = "3.0.0";
|
|
2
|
+
export declare const INFO_TITLE = "openapi:info:title";
|
|
3
|
+
export declare const INFO_DESCRIPTION = "openapi:info:description";
|
|
4
|
+
export declare const INFO_VERSION = "openapi:info:version";
|
|
5
|
+
export declare const INFO_TERMS_OF_SERVICE = "openapi:info:termsOfService";
|
|
6
|
+
export declare const INFO_CONTACT = "openapi:info:contact";
|
|
7
|
+
export declare const INFO_LICENSE = "openapi:info:license";
|
|
8
|
+
export declare const PATHS = "openapi:paths";
|
|
9
|
+
export declare const METHOD_GET = "openapi:method:get";
|
|
10
|
+
export declare const METHOD_POST = "openapi:method:post";
|
|
11
|
+
export declare const METHOD_PUT = "openapi:method:put";
|
|
12
|
+
export declare const METHOD_DELETE = "openapi:method:delete";
|
|
13
|
+
export declare const METHOD_PATCH = "openapi:method:patch";
|
|
14
|
+
export declare const METHOD_HEAD = "openapi:method:head";
|
|
15
|
+
export declare const METHOD_OPTIONS = "openapi:method:options";
|
|
16
|
+
export declare const METHOD_TRACE = "openapi:method:trace";
|
|
17
|
+
export declare const PARAMETERS = "openapi:parameters";
|
|
18
|
+
export declare const PARAM_NAME = "openapi:parameter:name";
|
|
19
|
+
export declare const PARAM_IN = "openapi:parameter:in";
|
|
20
|
+
export declare const PARAM_REQUIRED = "openapi:parameter:required";
|
|
21
|
+
export declare const PARAM_DESCRIPTION = "openapi:parameter:description";
|
|
22
|
+
export declare const PARAM_SCHEMA = "openapi:parameter:schema";
|
|
23
|
+
export declare const REQUEST_BODY = "openapi:requestBody";
|
|
24
|
+
export declare const REQUEST_BODY_DESCRIPTION = "openapi:requestBody:description";
|
|
25
|
+
export declare const REQUEST_BODY_CONTENT = "openapi:requestBody:content";
|
|
26
|
+
export declare const RESPONSES = "openapi:responses";
|
|
27
|
+
export declare const RESPONSE_DESCRIPTION = "openapi:response:description";
|
|
28
|
+
export declare const RESPONSE_CONTENT = "openapi:response:content";
|
|
29
|
+
export declare const RESPONSE_SCHEMA = "openapi:response:schema";
|
|
30
|
+
export declare const SECURITY = "openapi:security";
|
|
31
|
+
export declare const SECURITY_SCHEME = "openapi:security:scheme";
|
|
32
|
+
export declare const TAGS = "openapi:tags";
|
|
33
|
+
export declare const TAG_NAME = "openapi:tag:name";
|
|
34
|
+
export declare const TAG_DESCRIPTION = "openapi:tag:description";
|
|
35
|
+
export declare const METHOD_METADATA = "openapi:method:metadata";
|
|
36
|
+
export declare const METHOD_SUMMARY = "openapi:method:summary";
|
|
37
|
+
export declare const METHOD_OPERATION_ID = "openapi:method:operationId";
|
|
38
|
+
export declare const METHOD_TAGS = "openapi:method:tags";
|
|
39
|
+
export declare const COMPONENTS = "openapi:components";
|
|
40
|
+
export declare const COMPONENTS_SCHEMAS = "openapi:components:schemas";
|
|
41
|
+
export declare const COMPONENTS_RESPONSES = "openapi:components:responses";
|
|
42
|
+
export declare const COMPONENTS_PARAMETERS = "openapi:components:parameters";
|
|
43
|
+
export declare const COMPONENTS_SECURITY_SCHEMES = "openapi:components:securitySchemes";
|
|
44
|
+
export declare const SECURITY_API_KEY = "openapi:security:apiKey";
|
|
45
|
+
export declare const SECURITY_OAUTH2 = "openapi:security:oauth2";
|
|
46
|
+
export declare const SECURITY_OIDC = "openapi:security:oidc";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// constants.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SECURITY_OIDC = exports.SECURITY_OAUTH2 = exports.SECURITY_API_KEY = exports.COMPONENTS_SECURITY_SCHEMES = exports.COMPONENTS_PARAMETERS = exports.COMPONENTS_RESPONSES = exports.COMPONENTS_SCHEMAS = exports.COMPONENTS = exports.METHOD_TAGS = exports.METHOD_OPERATION_ID = exports.METHOD_SUMMARY = exports.METHOD_METADATA = exports.TAG_DESCRIPTION = exports.TAG_NAME = exports.TAGS = exports.SECURITY_SCHEME = exports.SECURITY = exports.RESPONSE_SCHEMA = exports.RESPONSE_CONTENT = exports.RESPONSE_DESCRIPTION = exports.RESPONSES = exports.REQUEST_BODY_CONTENT = exports.REQUEST_BODY_DESCRIPTION = exports.REQUEST_BODY = exports.PARAM_SCHEMA = exports.PARAM_DESCRIPTION = exports.PARAM_REQUIRED = exports.PARAM_IN = exports.PARAM_NAME = exports.PARAMETERS = exports.METHOD_TRACE = exports.METHOD_OPTIONS = exports.METHOD_HEAD = exports.METHOD_PATCH = exports.METHOD_DELETE = exports.METHOD_PUT = exports.METHOD_POST = exports.METHOD_GET = exports.PATHS = exports.INFO_LICENSE = exports.INFO_CONTACT = exports.INFO_TERMS_OF_SERVICE = exports.INFO_VERSION = exports.INFO_DESCRIPTION = exports.INFO_TITLE = exports.OPENAPI_VERSION = void 0;
|
|
5
|
+
// OpenAPI Version
|
|
6
|
+
exports.OPENAPI_VERSION = "3.0.0";
|
|
7
|
+
// Info Metadata (Información general sobre la API)
|
|
8
|
+
exports.INFO_TITLE = "openapi:info:title";
|
|
9
|
+
exports.INFO_DESCRIPTION = "openapi:info:description";
|
|
10
|
+
exports.INFO_VERSION = "openapi:info:version";
|
|
11
|
+
exports.INFO_TERMS_OF_SERVICE = "openapi:info:termsOfService";
|
|
12
|
+
exports.INFO_CONTACT = "openapi:info:contact";
|
|
13
|
+
exports.INFO_LICENSE = "openapi:info:license";
|
|
14
|
+
// Paths (Rutas de la API)
|
|
15
|
+
exports.PATHS = "openapi:paths";
|
|
16
|
+
exports.METHOD_GET = "openapi:method:get";
|
|
17
|
+
exports.METHOD_POST = "openapi:method:post";
|
|
18
|
+
exports.METHOD_PUT = "openapi:method:put";
|
|
19
|
+
exports.METHOD_DELETE = "openapi:method:delete";
|
|
20
|
+
exports.METHOD_PATCH = "openapi:method:patch";
|
|
21
|
+
exports.METHOD_HEAD = "openapi:method:head";
|
|
22
|
+
exports.METHOD_OPTIONS = "openapi:method:options";
|
|
23
|
+
exports.METHOD_TRACE = "openapi:method:trace";
|
|
24
|
+
// Parameters (Parámetros de los métodos)
|
|
25
|
+
exports.PARAMETERS = "openapi:parameters";
|
|
26
|
+
exports.PARAM_NAME = "openapi:parameter:name";
|
|
27
|
+
exports.PARAM_IN = "openapi:parameter:in"; // query, header, path, cookie
|
|
28
|
+
exports.PARAM_REQUIRED = "openapi:parameter:required";
|
|
29
|
+
exports.PARAM_DESCRIPTION = "openapi:parameter:description";
|
|
30
|
+
exports.PARAM_SCHEMA = "openapi:parameter:schema";
|
|
31
|
+
// RequestBody (Cuerpo de la solicitud)
|
|
32
|
+
exports.REQUEST_BODY = "openapi:requestBody";
|
|
33
|
+
exports.REQUEST_BODY_DESCRIPTION = "openapi:requestBody:description";
|
|
34
|
+
exports.REQUEST_BODY_CONTENT = "openapi:requestBody:content";
|
|
35
|
+
// Responses (Respuestas de los métodos)
|
|
36
|
+
exports.RESPONSES = "openapi:responses";
|
|
37
|
+
exports.RESPONSE_DESCRIPTION = "openapi:response:description";
|
|
38
|
+
exports.RESPONSE_CONTENT = "openapi:response:content";
|
|
39
|
+
exports.RESPONSE_SCHEMA = "openapi:response:schema";
|
|
40
|
+
// Security (Esquemas de seguridad)
|
|
41
|
+
exports.SECURITY = "openapi:security";
|
|
42
|
+
exports.SECURITY_SCHEME = "openapi:security:scheme"; // Esquemas de seguridad como apiKey, oauth2, etc.
|
|
43
|
+
// Tags (Etiquetas de los métodos)
|
|
44
|
+
exports.TAGS = "openapi:tags";
|
|
45
|
+
exports.TAG_NAME = "openapi:tag:name";
|
|
46
|
+
exports.TAG_DESCRIPTION = "openapi:tag:description";
|
|
47
|
+
// Method Metadata (Metadatos adicionales de los métodos)
|
|
48
|
+
exports.METHOD_METADATA = "openapi:method:metadata";
|
|
49
|
+
exports.METHOD_SUMMARY = "openapi:method:summary";
|
|
50
|
+
exports.METHOD_OPERATION_ID = "openapi:method:operationId";
|
|
51
|
+
exports.METHOD_TAGS = "openapi:method:tags";
|
|
52
|
+
// Components (Componentes reutilizables)
|
|
53
|
+
exports.COMPONENTS = "openapi:components";
|
|
54
|
+
exports.COMPONENTS_SCHEMAS = "openapi:components:schemas"; // Esquemas reutilizables de parámetros y respuestas
|
|
55
|
+
exports.COMPONENTS_RESPONSES = "openapi:components:responses"; // Respuestas reutilizables
|
|
56
|
+
exports.COMPONENTS_PARAMETERS = "openapi:components:parameters"; // Parámetros reutilizables
|
|
57
|
+
exports.COMPONENTS_SECURITY_SCHEMES = "openapi:components:securitySchemes"; // Esquemas de seguridad reutilizables
|
|
58
|
+
// Security Schemes (Esquemas de seguridad)
|
|
59
|
+
exports.SECURITY_API_KEY = "openapi:security:apiKey";
|
|
60
|
+
exports.SECURITY_OAUTH2 = "openapi:security:oauth2";
|
|
61
|
+
exports.SECURITY_OIDC = "openapi:security:oidc"; // OpenID Connect
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiMethod = ApiMethod;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const method_helper_1 = require("../helpers/method.helper");
|
|
6
|
+
function ApiMethod(options) {
|
|
7
|
+
return (target, propertyKey, descriptor) => {
|
|
8
|
+
(0, method_helper_1.apimethod)(target, propertyKey, options);
|
|
9
|
+
return descriptor;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiParameter = ApiParameter;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const parameter_helper_1 = require("../helpers/parameter.helper");
|
|
6
|
+
function ApiParameter(options) {
|
|
7
|
+
return (target, propertyKey) => {
|
|
8
|
+
(0, parameter_helper_1.apiParameter)(target, propertyKey, options);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiRequestBody = ApiRequestBody;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const request_body_helper_1 = require("../helpers/request-body.helper");
|
|
6
|
+
function ApiRequestBody(options) {
|
|
7
|
+
return (target, propertyKey) => {
|
|
8
|
+
(0, request_body_helper_1.apiRequestBody)(target, propertyKey, options);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiResponse = ApiResponse;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const response_helper_1 = require("../helpers/response.helper");
|
|
6
|
+
function ApiResponse(options) {
|
|
7
|
+
return (target, propertyKey) => {
|
|
8
|
+
(0, response_helper_1.apiResponse)(target, propertyKey, options);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiSecurity = ApiSecurity;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const security_helper_1 = require("../helpers/security.helper");
|
|
6
|
+
function ApiSecurity(options) {
|
|
7
|
+
return (target) => {
|
|
8
|
+
(0, security_helper_1.apiSecurity)(target, options);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiTag = ApiTag;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const tag_helper_1 = require("../helpers/tag.helper");
|
|
6
|
+
function ApiTag(options) {
|
|
7
|
+
return (target) => {
|
|
8
|
+
(0, tag_helper_1.apiTag)(target, options);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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("./api-method.decorator"), exports);
|
|
18
|
+
__exportStar(require("./api-parameter.decorator"), exports);
|
|
19
|
+
__exportStar(require("./api-request-body.decorator"), exports);
|
|
20
|
+
__exportStar(require("./api-response.decodator"), exports);
|
|
21
|
+
__exportStar(require("./api-security.decorator"), exports);
|
|
22
|
+
__exportStar(require("./api-tag.decorator"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
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("./method.helper"), exports);
|
|
18
|
+
__exportStar(require("./parameter.helper"), exports);
|
|
19
|
+
__exportStar(require("./request-body.helper"), exports);
|
|
20
|
+
__exportStar(require("./response.helper"), exports);
|
|
21
|
+
__exportStar(require("./security.helper"), exports);
|
|
22
|
+
__exportStar(require("./tag.helper"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apimethod = apimethod;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const response_helper_1 = require("./response.helper");
|
|
7
|
+
function apimethod(target, propertyKey, options) {
|
|
8
|
+
if (options.summary) {
|
|
9
|
+
Reflect.defineMetadata(constants_1.METHOD_SUMMARY, options.summary, target, propertyKey);
|
|
10
|
+
}
|
|
11
|
+
if (options.operationId) {
|
|
12
|
+
Reflect.defineMetadata(constants_1.METHOD_OPERATION_ID, options.operationId, target, propertyKey);
|
|
13
|
+
}
|
|
14
|
+
if (options.tags) {
|
|
15
|
+
Reflect.defineMetadata(constants_1.METHOD_TAGS, options.tags, target, propertyKey);
|
|
16
|
+
}
|
|
17
|
+
if (options.responses) {
|
|
18
|
+
(0, response_helper_1.apiResponse)(target, propertyKey, options.responses);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apiParameter = apiParameter;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function apiParameter(target, propertyKey, options) {
|
|
7
|
+
const existingParameters = Reflect.getMetadata(constants_1.PARAMETERS, target, propertyKey) || [];
|
|
8
|
+
existingParameters.push({
|
|
9
|
+
name: options.name,
|
|
10
|
+
in: options.in,
|
|
11
|
+
required: options.required || false,
|
|
12
|
+
description: options.description,
|
|
13
|
+
schema: options.schema,
|
|
14
|
+
});
|
|
15
|
+
Reflect.defineMetadata(constants_1.PARAMETERS, existingParameters, target, propertyKey);
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apiRequestBody = apiRequestBody;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function apiRequestBody(target, propertyKey, options) {
|
|
7
|
+
Reflect.defineMetadata(constants_1.REQUEST_BODY_DESCRIPTION, options.description, target, propertyKey);
|
|
8
|
+
Reflect.defineMetadata(constants_1.REQUEST_BODY_CONTENT, options.content, target, propertyKey);
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apiResponse = apiResponse;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function apiResponse(target, propertyKey, options) {
|
|
7
|
+
const existingResponses = Reflect.getMetadata(constants_1.RESPONSES, target, propertyKey) || {};
|
|
8
|
+
for (const key in options) {
|
|
9
|
+
if (options.hasOwnProperty(key)) {
|
|
10
|
+
const response = options[key];
|
|
11
|
+
existingResponses[key] = {
|
|
12
|
+
description: response.description,
|
|
13
|
+
content: response.content,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
Reflect.defineMetadata(constants_1.RESPONSES, existingResponses, target, propertyKey);
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apiSecurity = apiSecurity;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function apiSecurity(target, options) {
|
|
7
|
+
const existingSecurity = Reflect.getMetadata(constants_1.SECURITY, target) || [];
|
|
8
|
+
existingSecurity.push(options);
|
|
9
|
+
Reflect.defineMetadata(constants_1.SECURITY, existingSecurity, target);
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.apiTag = apiTag;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function apiTag(target, options) {
|
|
7
|
+
const existingTags = Reflect.getMetadata(constants_1.TAGS, target) || [];
|
|
8
|
+
existingTags.push({ name: options.name, description: options.description });
|
|
9
|
+
Reflect.defineMetadata(constants_1.TAGS, existingTags, target);
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./collectors";
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./collectors"), exports);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export interface OpenAPIDocument {
|
|
2
|
+
openapi: string;
|
|
3
|
+
info: Info;
|
|
4
|
+
paths: Paths;
|
|
5
|
+
components?: Components;
|
|
6
|
+
security?: SecurityRequirement[];
|
|
7
|
+
tags?: Tag[];
|
|
8
|
+
}
|
|
9
|
+
export interface Info {
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
termsOfService?: string;
|
|
13
|
+
contact?: Contact;
|
|
14
|
+
license?: License;
|
|
15
|
+
version: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Contact {
|
|
18
|
+
name?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface License {
|
|
23
|
+
name: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface Paths {
|
|
27
|
+
[path: string]: PathItem;
|
|
28
|
+
}
|
|
29
|
+
export interface PathItem {
|
|
30
|
+
get?: Operation;
|
|
31
|
+
post?: Operation;
|
|
32
|
+
put?: Operation;
|
|
33
|
+
delete?: Operation;
|
|
34
|
+
patch?: Operation;
|
|
35
|
+
head?: Operation;
|
|
36
|
+
options?: Operation;
|
|
37
|
+
trace?: Operation;
|
|
38
|
+
}
|
|
39
|
+
export interface Operation {
|
|
40
|
+
summary?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
operationId?: string;
|
|
43
|
+
tags?: Tag[];
|
|
44
|
+
parameters?: Parameter[];
|
|
45
|
+
requestBody?: RequestBody;
|
|
46
|
+
responses: Responses;
|
|
47
|
+
security?: SecurityRequirement[];
|
|
48
|
+
}
|
|
49
|
+
export interface Parameter {
|
|
50
|
+
name: string;
|
|
51
|
+
in: "query" | "header" | "path" | "cookie";
|
|
52
|
+
description?: string;
|
|
53
|
+
required?: boolean;
|
|
54
|
+
deprecated?: boolean;
|
|
55
|
+
allowEmptyValue?: boolean;
|
|
56
|
+
schema: Schema;
|
|
57
|
+
}
|
|
58
|
+
export interface RequestBody {
|
|
59
|
+
description?: string;
|
|
60
|
+
content: {
|
|
61
|
+
[mediaType: string]: MediaType;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface MediaType {
|
|
65
|
+
schema: Schema;
|
|
66
|
+
}
|
|
67
|
+
export interface Responses {
|
|
68
|
+
[statusCode: string]: Response;
|
|
69
|
+
}
|
|
70
|
+
export interface Response {
|
|
71
|
+
description: string;
|
|
72
|
+
content?: {
|
|
73
|
+
[mediaType: string]: MediaType;
|
|
74
|
+
};
|
|
75
|
+
headers?: {
|
|
76
|
+
[name: string]: Header;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface Header {
|
|
80
|
+
description?: string;
|
|
81
|
+
required?: boolean;
|
|
82
|
+
schema: Schema;
|
|
83
|
+
}
|
|
84
|
+
export interface Schema {
|
|
85
|
+
type: string;
|
|
86
|
+
format?: string;
|
|
87
|
+
items?: Schema;
|
|
88
|
+
properties?: {
|
|
89
|
+
[key: string]: Schema;
|
|
90
|
+
};
|
|
91
|
+
additionalProperties?: boolean;
|
|
92
|
+
example?: any;
|
|
93
|
+
}
|
|
94
|
+
export interface SecurityRequirement {
|
|
95
|
+
[securityScheme: string]: string[];
|
|
96
|
+
}
|
|
97
|
+
export interface Tag {
|
|
98
|
+
name: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface Components {
|
|
102
|
+
schemas?: {
|
|
103
|
+
[schemaName: string]: Schema;
|
|
104
|
+
};
|
|
105
|
+
responses?: {
|
|
106
|
+
[responseName: string]: Response;
|
|
107
|
+
};
|
|
108
|
+
parameters?: {
|
|
109
|
+
[parameterName: string]: Parameter;
|
|
110
|
+
};
|
|
111
|
+
securitySchemes?: {
|
|
112
|
+
[schemeName: string]: SecurityScheme;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export interface SecurityScheme {
|
|
116
|
+
type: "apiKey" | "http" | "oauth2" | "openIdConnect";
|
|
117
|
+
in?: "header" | "query" | "cookie";
|
|
118
|
+
name?: string;
|
|
119
|
+
scheme?: string;
|
|
120
|
+
bearerFormat?: string;
|
|
121
|
+
openIdConnectUrl?: string;
|
|
122
|
+
oauth2?: OAuth2Scheme;
|
|
123
|
+
}
|
|
124
|
+
export interface OAuth2Scheme {
|
|
125
|
+
authorizationUrl: string;
|
|
126
|
+
tokenUrl: string;
|
|
127
|
+
refreshUrl?: string;
|
|
128
|
+
scopes: {
|
|
129
|
+
[scope: string]: string;
|
|
130
|
+
};
|
|
131
|
+
}
|