nestjs-openapi-next 1.0.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/LICENSE +21 -0
- package/README.md +211 -0
- package/bun.lock +2154 -0
- package/dist/constants.d.ts +23 -0
- package/dist/constants.js +26 -0
- package/dist/decorators/api-basic.decorator.d.ts +1 -0
- package/dist/decorators/api-basic.decorator.js +7 -0
- package/dist/decorators/api-bearer.decorator.d.ts +1 -0
- package/dist/decorators/api-bearer.decorator.js +7 -0
- package/dist/decorators/api-body.decorator.d.ts +16 -0
- package/dist/decorators/api-body.decorator.js +22 -0
- package/dist/decorators/api-callbacks.decorator.d.ts +2 -0
- package/dist/decorators/api-callbacks.decorator.js +8 -0
- package/dist/decorators/api-consumes.decorator.d.ts +1 -0
- package/dist/decorators/api-consumes.decorator.js +8 -0
- package/dist/decorators/api-cookie.decorator.d.ts +1 -0
- package/dist/decorators/api-cookie.decorator.js +7 -0
- package/dist/decorators/api-default-getter.decorator.d.ts +2 -0
- package/dist/decorators/api-default-getter.decorator.js +12 -0
- package/dist/decorators/api-exclude-controller.decorator.d.ts +1 -0
- package/dist/decorators/api-exclude-controller.decorator.js +8 -0
- package/dist/decorators/api-exclude-endpoint.decorator.d.ts +1 -0
- package/dist/decorators/api-exclude-endpoint.decorator.js +10 -0
- package/dist/decorators/api-extension.decorator.d.ts +1 -0
- package/dist/decorators/api-extension.decorator.js +38 -0
- package/dist/decorators/api-extra-models.decorator.d.ts +1 -0
- package/dist/decorators/api-extra-models.decorator.js +17 -0
- package/dist/decorators/api-header.decorator.d.ts +7 -0
- package/dist/decorators/api-header.decorator.js +37 -0
- package/dist/decorators/api-hide-property.decorator.d.ts +1 -0
- package/dist/decorators/api-hide-property.decorator.js +6 -0
- package/dist/decorators/api-link.decorator.d.ts +7 -0
- package/dist/decorators/api-link.decorator.js +21 -0
- package/dist/decorators/api-oauth2.decorator.d.ts +1 -0
- package/dist/decorators/api-oauth2.decorator.js +7 -0
- package/dist/decorators/api-operation.decorator.d.ts +5 -0
- package/dist/decorators/api-operation.decorator.js +12 -0
- package/dist/decorators/api-param.decorator.d.ts +22 -0
- package/dist/decorators/api-param.decorator.js +17 -0
- package/dist/decorators/api-produces.decorator.d.ts +1 -0
- package/dist/decorators/api-produces.decorator.js +8 -0
- package/dist/decorators/api-property.decorator.d.ts +15 -0
- package/dist/decorators/api-property.decorator.js +48 -0
- package/dist/decorators/api-query-method.decorator.d.ts +1 -0
- package/dist/decorators/api-query-method.decorator.js +8 -0
- package/dist/decorators/api-query.decorator.d.ts +24 -0
- package/dist/decorators/api-query.decorator.js +25 -0
- package/dist/decorators/api-response.decorator.d.ts +39 -0
- package/dist/decorators/api-response.decorator.js +55 -0
- package/dist/decorators/api-schema.decorator.d.ts +6 -0
- package/dist/decorators/api-schema.decorator.js +8 -0
- package/dist/decorators/api-security-device-flow.decorator.d.ts +1 -0
- package/dist/decorators/api-security-device-flow.decorator.js +7 -0
- package/dist/decorators/api-security.decorator.d.ts +2 -0
- package/dist/decorators/api-security.decorator.js +25 -0
- package/dist/decorators/api-streaming-response.decorator.d.ts +7 -0
- package/dist/decorators/api-streaming-response.decorator.js +9 -0
- package/dist/decorators/api-tag-group.decorator.d.ts +11 -0
- package/dist/decorators/api-tag-group.decorator.js +13 -0
- package/dist/decorators/api-use-tags.decorator.d.ts +1 -0
- package/dist/decorators/api-use-tags.decorator.js +8 -0
- package/dist/decorators/helpers.d.ts +8 -0
- package/dist/decorators/helpers.js +123 -0
- package/dist/decorators/index.d.ts +28 -0
- package/dist/decorators/index.js +48 -0
- package/dist/document-builder.d.ts +29 -0
- package/dist/document-builder.js +142 -0
- package/dist/explorers/api-callbacks.explorer.d.ts +2 -0
- package/dist/explorers/api-callbacks.explorer.js +36 -0
- package/dist/explorers/api-consumes.explorer.d.ts +5 -0
- package/dist/explorers/api-consumes.explorer.js +11 -0
- package/dist/explorers/api-exclude-controller.explorer.d.ts +2 -0
- package/dist/explorers/api-exclude-controller.explorer.js +10 -0
- package/dist/explorers/api-exclude-endpoint.explorer.d.ts +2 -0
- package/dist/explorers/api-exclude-endpoint.explorer.js +6 -0
- package/dist/explorers/api-extra-models.explorer.d.ts +3 -0
- package/dist/explorers/api-extra-models.explorer.js +11 -0
- package/dist/explorers/api-headers.explorer.d.ts +7 -0
- package/dist/explorers/api-headers.explorer.js +9 -0
- package/dist/explorers/api-operation.explorer.d.ts +2 -0
- package/dist/explorers/api-operation.explorer.js +43 -0
- package/dist/explorers/api-parameters.explorer.d.ts +71 -0
- package/dist/explorers/api-parameters.explorer.js +47 -0
- package/dist/explorers/api-produces.explorer.d.ts +5 -0
- package/dist/explorers/api-produces.explorer.js +11 -0
- package/dist/explorers/api-response.explorer.d.ts +13 -0
- package/dist/explorers/api-response.explorer.js +103 -0
- package/dist/explorers/api-security.explorer.d.ts +5 -0
- package/dist/explorers/api-security.explorer.js +13 -0
- package/dist/explorers/api-use-tags.explorer.d.ts +5 -0
- package/dist/explorers/api-use-tags.explorer.js +18 -0
- package/dist/extra/swagger-shim.d.ts +100 -0
- package/dist/extra/swagger-shim.js +367 -0
- package/dist/fixtures/document.base.d.ts +2 -0
- package/dist/fixtures/document.base.js +16 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +23 -0
- package/dist/interfaces/callback-object.interface.d.ts +12 -0
- package/dist/interfaces/callback-object.interface.js +2 -0
- package/dist/interfaces/denormalized-doc-resolvers.interface.d.ts +7 -0
- package/dist/interfaces/denormalized-doc-resolvers.interface.js +2 -0
- package/dist/interfaces/denormalized-doc.interface.d.ts +8 -0
- package/dist/interfaces/denormalized-doc.interface.js +2 -0
- package/dist/interfaces/enum-schema-attributes.interface.d.ts +2 -0
- package/dist/interfaces/enum-schema-attributes.interface.js +2 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +18 -0
- package/dist/interfaces/module-route.interface.d.ts +2 -0
- package/dist/interfaces/module-route.interface.js +2 -0
- package/dist/interfaces/open-api-spec.interface.d.ts +252 -0
- package/dist/interfaces/open-api-spec.interface.js +2 -0
- package/dist/interfaces/schema-object-metadata.interface.d.ts +30 -0
- package/dist/interfaces/schema-object-metadata.interface.js +2 -0
- package/dist/interfaces/swagger-custom-options.interface.d.ts +24 -0
- package/dist/interfaces/swagger-custom-options.interface.js +2 -0
- package/dist/interfaces/swagger-document-options.interface.d.ts +10 -0
- package/dist/interfaces/swagger-document-options.interface.js +2 -0
- package/dist/interfaces/swagger-ui-init-options.interface.d.ts +7 -0
- package/dist/interfaces/swagger-ui-init-options.interface.js +2 -0
- package/dist/interfaces/swagger-ui-options.interface.d.ts +15 -0
- package/dist/interfaces/swagger-ui-options.interface.js +2 -0
- package/dist/plugin/compiler-plugin.d.ts +2 -0
- package/dist/plugin/compiler-plugin.js +30 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.js +18 -0
- package/dist/plugin/merge-options.d.ts +17 -0
- package/dist/plugin/merge-options.js +37 -0
- package/dist/plugin/metadata-loader.d.ts +7 -0
- package/dist/plugin/metadata-loader.js +51 -0
- package/dist/plugin/plugin-constants.d.ts +3 -0
- package/dist/plugin/plugin-constants.js +6 -0
- package/dist/plugin/plugin-debug-logger.d.ts +5 -0
- package/dist/plugin/plugin-debug-logger.js +7 -0
- package/dist/plugin/utils/ast-utils.d.ts +30 -0
- package/dist/plugin/utils/ast-utils.js +273 -0
- package/dist/plugin/utils/is-filename-matched.util.d.ts +1 -0
- package/dist/plugin/utils/is-filename-matched.util.js +5 -0
- package/dist/plugin/utils/plugin-utils.d.ts +30 -0
- package/dist/plugin/utils/plugin-utils.js +307 -0
- package/dist/plugin/utils/type-reference-to-identifier.util.d.ts +7 -0
- package/dist/plugin/utils/type-reference-to-identifier.util.js +52 -0
- package/dist/plugin/visitors/abstract.visitor.d.ts +4 -0
- package/dist/plugin/visitors/abstract.visitor.js +30 -0
- package/dist/plugin/visitors/controller-class.visitor.d.ts +20 -0
- package/dist/plugin/visitors/controller-class.visitor.js +265 -0
- package/dist/plugin/visitors/model-class.visitor.d.ts +35 -0
- package/dist/plugin/visitors/model-class.visitor.js +514 -0
- package/dist/plugin/visitors/readonly.visitor.d.ts +21 -0
- package/dist/plugin/visitors/readonly.visitor.js +40 -0
- package/dist/services/constants.d.ts +1 -0
- package/dist/services/constants.js +4 -0
- package/dist/services/decorators-properties.d.ts +21 -0
- package/dist/services/decorators-properties.js +149 -0
- package/dist/services/mimetype-content-wrapper.d.ts +4 -0
- package/dist/services/mimetype-content-wrapper.js +11 -0
- package/dist/services/model-properties-accessor.d.ts +6 -0
- package/dist/services/model-properties-accessor.js +37 -0
- package/dist/services/parameter-metadata-accessor.d.ts +22 -0
- package/dist/services/parameter-metadata-accessor.js +41 -0
- package/dist/services/parameters-metadata-mapper.d.ts +9 -0
- package/dist/services/parameters-metadata-mapper.js +38 -0
- package/dist/services/response-object-factory.d.ts +28 -0
- package/dist/services/response-object-factory.js +120 -0
- package/dist/services/response-object-mapper.d.ts +39 -0
- package/dist/services/response-object-mapper.js +38 -0
- package/dist/services/schema-object-factory.d.ts +156 -0
- package/dist/services/schema-object-factory.js +471 -0
- package/dist/services/swagger-types-mapper.d.ts +260 -0
- package/dist/services/swagger-types-mapper.js +107 -0
- package/dist/storages/global-parameters.storage.d.ts +8 -0
- package/dist/storages/global-parameters.storage.js +22 -0
- package/dist/storages/global-responses.storage.d.ts +10 -0
- package/dist/storages/global-responses.storage.js +21 -0
- package/dist/swagger-explorer.d.ts +41 -0
- package/dist/swagger-explorer.js +326 -0
- package/dist/swagger-module.d.ts +27 -0
- package/dist/swagger-module.js +223 -0
- package/dist/swagger-scanner.d.ts +25 -0
- package/dist/swagger-scanner.js +116 -0
- package/dist/swagger-transformer.d.ts +4 -0
- package/dist/swagger-transformer.js +22 -0
- package/dist/swagger-ui/constants.d.ts +3 -0
- package/dist/swagger-ui/constants.js +132 -0
- package/dist/swagger-ui/helpers.d.ts +2 -0
- package/dist/swagger-ui/helpers.js +16 -0
- package/dist/swagger-ui/index.d.ts +1 -0
- package/dist/swagger-ui/index.js +17 -0
- package/dist/swagger-ui/swagger-ui.d.ts +4 -0
- package/dist/swagger-ui/swagger-ui.js +62 -0
- package/dist/type-helpers/index.d.ts +4 -0
- package/dist/type-helpers/index.js +20 -0
- package/dist/type-helpers/intersection-type.helper.d.ts +8 -0
- package/dist/type-helpers/intersection-type.helper.js +42 -0
- package/dist/type-helpers/mapped-types.utils.d.ts +2 -0
- package/dist/type-helpers/mapped-types.utils.js +31 -0
- package/dist/type-helpers/omit-type.helper.d.ts +2 -0
- package/dist/type-helpers/omit-type.helper.js +40 -0
- package/dist/type-helpers/partial-type.helper.d.ts +4 -0
- package/dist/type-helpers/partial-type.helper.js +49 -0
- package/dist/type-helpers/pick-type.helper.d.ts +2 -0
- package/dist/type-helpers/pick-type.helper.js +40 -0
- package/dist/types/swagger-enum.type.d.ts +1 -0
- package/dist/types/swagger-enum.type.js +2 -0
- package/dist/utils/assign-two-levels-deep.d.ts +1 -0
- package/dist/utils/assign-two-levels-deep.js +12 -0
- package/dist/utils/enum.utils.d.ts +9 -0
- package/dist/utils/enum.utils.js +65 -0
- package/dist/utils/extend-metadata.util.d.ts +2 -0
- package/dist/utils/extend-metadata.util.js +11 -0
- package/dist/utils/get-global-prefix.d.ts +2 -0
- package/dist/utils/get-global-prefix.js +7 -0
- package/dist/utils/get-schema-path.util.d.ts +4 -0
- package/dist/utils/get-schema-path.util.js +26 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/is-body-parameter.util.d.ts +2 -0
- package/dist/utils/is-body-parameter.util.js +6 -0
- package/dist/utils/is-built-in-type.util.d.ts +2 -0
- package/dist/utils/is-built-in-type.util.js +8 -0
- package/dist/utils/is-date-ctor.util.d.ts +2 -0
- package/dist/utils/is-date-ctor.util.js +6 -0
- package/dist/utils/merge-and-uniq.util.d.ts +1 -0
- package/dist/utils/merge-and-uniq.util.js +7 -0
- package/dist/utils/normalize-rel-path.d.ts +1 -0
- package/dist/utils/normalize-rel-path.js +7 -0
- package/dist/utils/remove-undefined-keys.d.ts +5 -0
- package/dist/utils/remove-undefined-keys.js +11 -0
- package/dist/utils/resolve-path.util.d.ts +1 -0
- package/dist/utils/resolve-path.util.js +7 -0
- package/dist/utils/reverse-object-keys.util.d.ts +1 -0
- package/dist/utils/reverse-object-keys.util.js +11 -0
- package/dist/utils/sort-object-lexicographically.d.ts +5 -0
- package/dist/utils/sort-object-lexicographically.js +11 -0
- package/dist/utils/strip-last-slash.util.d.ts +1 -0
- package/dist/utils/strip-last-slash.util.js +8 -0
- package/dist/utils/validate-global-prefix.util.d.ts +1 -0
- package/dist/utils/validate-global-prefix.util.js +5 -0
- package/dist/utils/validate-path.util.d.ts +1 -0
- package/dist/utils/validate-path.util.js +5 -0
- package/eslint.config.mjs +47 -0
- package/nest-cli.json +6 -0
- package/package.json +116 -0
- package/plugin.js +10 -0
- package/tsconfig.build.json +21 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const DECORATORS_PREFIX = "swagger";
|
|
2
|
+
export declare const DECORATORS: {
|
|
3
|
+
API_OPERATION: string;
|
|
4
|
+
API_RESPONSE: string;
|
|
5
|
+
API_PRODUCES: string;
|
|
6
|
+
API_CONSUMES: string;
|
|
7
|
+
API_TAGS: string;
|
|
8
|
+
API_TAG_GROUP: string;
|
|
9
|
+
API_QUERY_METHOD: string;
|
|
10
|
+
API_CALLBACKS: string;
|
|
11
|
+
API_PARAMETERS: string;
|
|
12
|
+
API_HEADERS: string;
|
|
13
|
+
API_MODEL_PROPERTIES: string;
|
|
14
|
+
API_MODEL_PROPERTIES_ARRAY: string;
|
|
15
|
+
API_SECURITY: string;
|
|
16
|
+
API_EXCLUDE_ENDPOINT: string;
|
|
17
|
+
API_EXCLUDE_CONTROLLER: string;
|
|
18
|
+
API_EXTRA_MODELS: string;
|
|
19
|
+
API_EXTENSION: string;
|
|
20
|
+
API_SCHEMA: string;
|
|
21
|
+
API_DEFAULT_GETTER: string;
|
|
22
|
+
API_LINK: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DECORATORS = exports.DECORATORS_PREFIX = void 0;
|
|
4
|
+
exports.DECORATORS_PREFIX = 'swagger';
|
|
5
|
+
exports.DECORATORS = {
|
|
6
|
+
API_OPERATION: `${exports.DECORATORS_PREFIX}/apiOperation`,
|
|
7
|
+
API_RESPONSE: `${exports.DECORATORS_PREFIX}/apiResponse`,
|
|
8
|
+
API_PRODUCES: `${exports.DECORATORS_PREFIX}/apiProduces`,
|
|
9
|
+
API_CONSUMES: `${exports.DECORATORS_PREFIX}/apiConsumes`,
|
|
10
|
+
API_TAGS: `${exports.DECORATORS_PREFIX}/apiUseTags`,
|
|
11
|
+
API_TAG_GROUP: `${exports.DECORATORS_PREFIX}/apiTagGroup`,
|
|
12
|
+
API_QUERY_METHOD: `${exports.DECORATORS_PREFIX}/apiQueryMethod`,
|
|
13
|
+
API_CALLBACKS: `${exports.DECORATORS_PREFIX}/apiCallbacks`,
|
|
14
|
+
API_PARAMETERS: `${exports.DECORATORS_PREFIX}/apiParameters`,
|
|
15
|
+
API_HEADERS: `${exports.DECORATORS_PREFIX}/apiHeaders`,
|
|
16
|
+
API_MODEL_PROPERTIES: `${exports.DECORATORS_PREFIX}/apiModelProperties`,
|
|
17
|
+
API_MODEL_PROPERTIES_ARRAY: `${exports.DECORATORS_PREFIX}/apiModelPropertiesArray`,
|
|
18
|
+
API_SECURITY: `${exports.DECORATORS_PREFIX}/apiSecurity`,
|
|
19
|
+
API_EXCLUDE_ENDPOINT: `${exports.DECORATORS_PREFIX}/apiExcludeEndpoint`,
|
|
20
|
+
API_EXCLUDE_CONTROLLER: `${exports.DECORATORS_PREFIX}/apiExcludeController`,
|
|
21
|
+
API_EXTRA_MODELS: `${exports.DECORATORS_PREFIX}/apiExtraModels`,
|
|
22
|
+
API_EXTENSION: `${exports.DECORATORS_PREFIX}/apiExtension`,
|
|
23
|
+
API_SCHEMA: `${exports.DECORATORS_PREFIX}/apiSchema`,
|
|
24
|
+
API_DEFAULT_GETTER: `${exports.DECORATORS_PREFIX}/apiDefaultGetter`,
|
|
25
|
+
API_LINK: `${exports.DECORATORS_PREFIX}/apiLink`
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiBasicAuth(name?: string): ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiBasicAuth = ApiBasicAuth;
|
|
4
|
+
const api_security_decorator_1 = require("./api-security.decorator");
|
|
5
|
+
function ApiBasicAuth(name = 'basic') {
|
|
6
|
+
return (0, api_security_decorator_1.ApiSecurity)(name);
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiBearerAuth(name?: string): ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiBearerAuth = ApiBearerAuth;
|
|
4
|
+
const api_security_decorator_1 = require("./api-security.decorator");
|
|
5
|
+
function ApiBearerAuth(name = 'bearer') {
|
|
6
|
+
return (0, api_security_decorator_1.ApiSecurity)(name);
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { ExamplesObject, ReferenceObject, RequestBodyObject, SchemaObject } from '../interfaces/open-api-spec.interface';
|
|
3
|
+
import { SwaggerEnumType } from '../types/swagger-enum.type';
|
|
4
|
+
type RequestBodyOptions = Omit<RequestBodyObject, 'content'>;
|
|
5
|
+
interface ApiBodyMetadata extends RequestBodyOptions {
|
|
6
|
+
type?: Type<unknown> | Function | [Function] | string;
|
|
7
|
+
isArray?: boolean;
|
|
8
|
+
enum?: SwaggerEnumType;
|
|
9
|
+
}
|
|
10
|
+
interface ApiBodySchemaHost extends RequestBodyOptions {
|
|
11
|
+
schema: SchemaObject | ReferenceObject;
|
|
12
|
+
examples?: ExamplesObject;
|
|
13
|
+
}
|
|
14
|
+
export type ApiBodyOptions = ApiBodyMetadata | ApiBodySchemaHost;
|
|
15
|
+
export declare function ApiBody(options: ApiBodyOptions): MethodDecorator;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiBody = ApiBody;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const enum_utils_1 = require("../utils/enum.utils");
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
7
|
+
const defaultBodyMetadata = {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true
|
|
10
|
+
};
|
|
11
|
+
function ApiBody(options) {
|
|
12
|
+
const [type, isArray] = (0, helpers_1.getTypeIsArrayTuple)(options.type, options.isArray);
|
|
13
|
+
const param = Object.assign(Object.assign({ in: 'body' }, (0, lodash_1.omit)(options, 'enum')), { type,
|
|
14
|
+
isArray });
|
|
15
|
+
if ((0, enum_utils_1.isEnumArray)(options)) {
|
|
16
|
+
(0, enum_utils_1.addEnumArraySchema)(param, options);
|
|
17
|
+
}
|
|
18
|
+
else if ((0, enum_utils_1.isEnumDefined)(options)) {
|
|
19
|
+
(0, enum_utils_1.addEnumSchema)(param, options);
|
|
20
|
+
}
|
|
21
|
+
return (0, helpers_1.createParamDecorator)(param, defaultBodyMetadata);
|
|
22
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiCallbacks = ApiCallbacks;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
function ApiCallbacks(...callbackObject) {
|
|
7
|
+
return (0, helpers_1.createMixedDecorator)(constants_1.DECORATORS.API_CALLBACKS, callbackObject);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiConsumes(...mimeTypes: string[]): MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiConsumes = ApiConsumes;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
function ApiConsumes(...mimeTypes) {
|
|
7
|
+
return (0, helpers_1.createMixedDecorator)(constants_1.DECORATORS.API_CONSUMES, mimeTypes);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiCookieAuth(name?: string): ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiCookieAuth = ApiCookieAuth;
|
|
4
|
+
const api_security_decorator_1 = require("./api-security.decorator");
|
|
5
|
+
function ApiCookieAuth(name = 'cookie') {
|
|
6
|
+
return (0, api_security_decorator_1.ApiSecurity)(name);
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiDefaultGetter = ApiDefaultGetter;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function ApiDefaultGetter(type, parameter) {
|
|
6
|
+
return (prototype, key, descriptor) => {
|
|
7
|
+
if (type.prototype) {
|
|
8
|
+
Reflect.defineMetadata(constants_1.DECORATORS.API_DEFAULT_GETTER, { getter: descriptor.value, parameter, prototype }, type.prototype);
|
|
9
|
+
}
|
|
10
|
+
return descriptor;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiExcludeController(disable?: boolean): ClassDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExcludeController = ApiExcludeController;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
function ApiExcludeController(disable = true) {
|
|
7
|
+
return (0, helpers_1.createClassDecorator)(constants_1.DECORATORS.API_EXCLUDE_CONTROLLER, [disable]);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiExcludeEndpoint(disable?: boolean): MethodDecorator;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExcludeEndpoint = ApiExcludeEndpoint;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
function ApiExcludeEndpoint(disable = true) {
|
|
7
|
+
return (0, helpers_1.createMethodDecorator)(constants_1.DECORATORS.API_EXCLUDE_ENDPOINT, {
|
|
8
|
+
disable
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiExtension(extensionKey: string, extensionProperties: any): (target: object | Function, key?: string | symbol, descriptor?: TypedPropertyDescriptor<any>) => any;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExtension = ApiExtension;
|
|
4
|
+
const constants_1 = require("@nestjs/common/constants");
|
|
5
|
+
const constants_2 = require("../constants");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
8
|
+
function applyExtension(target, key, value) {
|
|
9
|
+
const extensions = Reflect.getMetadata(constants_2.DECORATORS.API_EXTENSION, target) || {};
|
|
10
|
+
Reflect.defineMetadata(constants_2.DECORATORS.API_EXTENSION, Object.assign({ [key]: value }, extensions), target);
|
|
11
|
+
}
|
|
12
|
+
function ApiExtension(extensionKey, extensionProperties) {
|
|
13
|
+
if (!extensionKey.startsWith('x-')) {
|
|
14
|
+
throw new Error('Extension key is not prefixed. Please ensure you prefix it with `x-`.');
|
|
15
|
+
}
|
|
16
|
+
return (target, key, descriptor) => {
|
|
17
|
+
const extensionValue = (0, lodash_1.clone)(extensionProperties);
|
|
18
|
+
if (descriptor) {
|
|
19
|
+
applyExtension(descriptor.value, extensionKey, extensionValue);
|
|
20
|
+
return descriptor;
|
|
21
|
+
}
|
|
22
|
+
if (typeof target === 'object') {
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
const apiMethods = Object.getOwnPropertyNames(target.prototype)
|
|
26
|
+
.filter((propertyKey) => !(0, shared_utils_1.isConstructor)(propertyKey))
|
|
27
|
+
.map((propertyKey) => { var _a; return (_a = Object.getOwnPropertyDescriptor(target.prototype, propertyKey)) === null || _a === void 0 ? void 0 : _a.value; })
|
|
28
|
+
.filter((methodDescriptor) => methodDescriptor !== undefined &&
|
|
29
|
+
Reflect.hasMetadata(constants_1.METHOD_METADATA, methodDescriptor));
|
|
30
|
+
if (apiMethods.length > 0) {
|
|
31
|
+
apiMethods.forEach((method) => applyExtension(method, extensionKey, extensionValue));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
applyExtension(target, extensionKey, extensionValue);
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiExtraModels(...models: Function[]): (target: object, key?: string | symbol, descriptor?: TypedPropertyDescriptor<any>) => any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExtraModels = ApiExtraModels;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function ApiExtraModels(...models) {
|
|
6
|
+
return (target, key, descriptor) => {
|
|
7
|
+
if (descriptor) {
|
|
8
|
+
const extraModels = Reflect.getMetadata(constants_1.DECORATORS.API_EXTRA_MODELS, descriptor.value) ||
|
|
9
|
+
[];
|
|
10
|
+
Reflect.defineMetadata(constants_1.DECORATORS.API_EXTRA_MODELS, [...extraModels, ...models], descriptor.value);
|
|
11
|
+
return descriptor;
|
|
12
|
+
}
|
|
13
|
+
const extraModels = Reflect.getMetadata(constants_1.DECORATORS.API_EXTRA_MODELS, target) || [];
|
|
14
|
+
Reflect.defineMetadata(constants_1.DECORATORS.API_EXTRA_MODELS, [...extraModels, ...models], target);
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParameterObject } from '../interfaces/open-api-spec.interface';
|
|
2
|
+
import { SwaggerEnumType } from '../types/swagger-enum.type';
|
|
3
|
+
export interface ApiHeaderOptions extends Omit<ParameterObject, 'in'> {
|
|
4
|
+
enum?: SwaggerEnumType;
|
|
5
|
+
}
|
|
6
|
+
export declare function ApiHeader(options: ApiHeaderOptions): MethodDecorator & ClassDecorator;
|
|
7
|
+
export declare const ApiHeaders: (headers: ApiHeaderOptions[]) => MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiHeaders = void 0;
|
|
4
|
+
exports.ApiHeader = ApiHeader;
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const enum_utils_1 = require("../utils/enum.utils");
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
const defaultHeaderOptions = {
|
|
10
|
+
name: ''
|
|
11
|
+
};
|
|
12
|
+
function ApiHeader(options) {
|
|
13
|
+
const param = (0, lodash_1.pickBy)({
|
|
14
|
+
name: (0, lodash_1.isNil)(options.name) ? defaultHeaderOptions.name : options.name,
|
|
15
|
+
in: 'header',
|
|
16
|
+
description: options.description,
|
|
17
|
+
required: options.required,
|
|
18
|
+
examples: options.examples,
|
|
19
|
+
schema: Object.assign({ type: 'string' }, (options.schema || {}))
|
|
20
|
+
}, (0, lodash_1.negate)(lodash_1.isUndefined));
|
|
21
|
+
if (options.enum) {
|
|
22
|
+
const enumValues = (0, enum_utils_1.getEnumValues)(options.enum);
|
|
23
|
+
param.schema = Object.assign(Object.assign({}, param.schema), { enum: enumValues, type: (0, enum_utils_1.getEnumType)(enumValues) });
|
|
24
|
+
}
|
|
25
|
+
return (target, key, descriptor) => {
|
|
26
|
+
if (descriptor) {
|
|
27
|
+
return (0, helpers_1.createParamDecorator)(param, defaultHeaderOptions)(target, key, descriptor);
|
|
28
|
+
}
|
|
29
|
+
return (0, helpers_1.createClassDecorator)(constants_1.DECORATORS.API_HEADERS, [param])(target);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const ApiHeaders = (headers) => {
|
|
33
|
+
return (target, key, descriptor) => {
|
|
34
|
+
headers.forEach((options) => ApiHeader(options)(target, key, descriptor));
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.ApiHeaders = ApiHeaders;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiHideProperty(): PropertyDecorator;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiLink = ApiLink;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function ApiLink({ from, fromField = 'id', routeParam }) {
|
|
6
|
+
return (controllerPrototype, key, descriptor) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const { prototype } = from;
|
|
9
|
+
if (prototype) {
|
|
10
|
+
const links = (_a = Reflect.getMetadata(constants_1.DECORATORS.API_LINK, prototype)) !== null && _a !== void 0 ? _a : [];
|
|
11
|
+
links.push({
|
|
12
|
+
method: descriptor.value,
|
|
13
|
+
prototype: controllerPrototype,
|
|
14
|
+
field: fromField,
|
|
15
|
+
parameter: routeParam
|
|
16
|
+
});
|
|
17
|
+
Reflect.defineMetadata(constants_1.DECORATORS.API_LINK, links, prototype);
|
|
18
|
+
}
|
|
19
|
+
return descriptor;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiOAuth2(scopes: string[], name?: string): ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiOAuth2 = ApiOAuth2;
|
|
4
|
+
const api_security_decorator_1 = require("./api-security.decorator");
|
|
5
|
+
function ApiOAuth2(scopes, name = 'oauth2') {
|
|
6
|
+
return (0, api_security_decorator_1.ApiSecurity)(name, scopes);
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { OperationObject } from '../interfaces/open-api-spec.interface';
|
|
2
|
+
export type ApiOperationOptions = Partial<OperationObject>;
|
|
3
|
+
export declare function ApiOperation(options: ApiOperationOptions, { overrideExisting }?: {
|
|
4
|
+
overrideExisting: boolean;
|
|
5
|
+
}): MethodDecorator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiOperation = ApiOperation;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
7
|
+
const defaultOperationOptions = {
|
|
8
|
+
summary: ''
|
|
9
|
+
};
|
|
10
|
+
function ApiOperation(options, { overrideExisting } = { overrideExisting: true }) {
|
|
11
|
+
return (0, helpers_1.createMethodDecorator)(constants_1.DECORATORS.API_OPERATION, (0, lodash_1.pickBy)(Object.assign(Object.assign({}, defaultOperationOptions), options), (0, lodash_1.negate)(lodash_1.isUndefined)), { overrideExisting });
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { EnumSchemaAttributes } from '../interfaces/enum-schema-attributes.interface';
|
|
3
|
+
import { ParameterObject, SchemaObject } from '../interfaces/open-api-spec.interface';
|
|
4
|
+
import { SwaggerEnumType } from '../types/swagger-enum.type';
|
|
5
|
+
type ParameterOptions = Omit<ParameterObject, 'in' | 'schema'>;
|
|
6
|
+
interface ApiParamCommonMetadata extends ParameterOptions {
|
|
7
|
+
type?: Type<unknown> | Function | [Function] | string;
|
|
8
|
+
format?: string;
|
|
9
|
+
enum?: SwaggerEnumType;
|
|
10
|
+
enumName?: string;
|
|
11
|
+
enumSchema?: EnumSchemaAttributes;
|
|
12
|
+
}
|
|
13
|
+
type ApiParamMetadata = ApiParamCommonMetadata | (ApiParamCommonMetadata & {
|
|
14
|
+
enumName: string;
|
|
15
|
+
enumSchema?: EnumSchemaAttributes;
|
|
16
|
+
});
|
|
17
|
+
interface ApiParamSchemaHost extends ParameterOptions {
|
|
18
|
+
schema: SchemaObject;
|
|
19
|
+
}
|
|
20
|
+
export type ApiParamOptions = ApiParamMetadata | ApiParamSchemaHost;
|
|
21
|
+
export declare function ApiParam(options: ApiParamOptions): MethodDecorator & ClassDecorator;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiParam = ApiParam;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const enum_utils_1 = require("../utils/enum.utils");
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
7
|
+
const defaultParamOptions = {
|
|
8
|
+
name: '',
|
|
9
|
+
required: true
|
|
10
|
+
};
|
|
11
|
+
function ApiParam(options) {
|
|
12
|
+
const param = Object.assign({ name: (0, lodash_1.isNil)(options.name) ? defaultParamOptions.name : options.name, in: 'path' }, (0, lodash_1.omit)(options, 'enum'));
|
|
13
|
+
if ((0, enum_utils_1.isEnumDefined)(options)) {
|
|
14
|
+
(0, enum_utils_1.addEnumSchema)(param, options);
|
|
15
|
+
}
|
|
16
|
+
return (0, helpers_1.createParamDecorator)(param, defaultParamOptions);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiProduces(...mimeTypes: string[]): MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiProduces = ApiProduces;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
function ApiProduces(...mimeTypes) {
|
|
7
|
+
return (0, helpers_1.createMixedDecorator)(constants_1.DECORATORS.API_PRODUCES, mimeTypes);
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { EnumSchemaAttributes } from '../interfaces/enum-schema-attributes.interface';
|
|
3
|
+
import { SchemaObjectMetadata } from '../interfaces/schema-object-metadata.interface';
|
|
4
|
+
export type ApiPropertyCommonOptions = SchemaObjectMetadata & {
|
|
5
|
+
'x-enumNames'?: string[];
|
|
6
|
+
link?: () => Type<unknown> | Function;
|
|
7
|
+
};
|
|
8
|
+
export type ApiPropertyOptions = ApiPropertyCommonOptions | (ApiPropertyCommonOptions & {
|
|
9
|
+
enumName: string;
|
|
10
|
+
enumSchema?: EnumSchemaAttributes;
|
|
11
|
+
});
|
|
12
|
+
export declare function ApiProperty(options?: ApiPropertyOptions): PropertyDecorator;
|
|
13
|
+
export declare function createApiPropertyDecorator(options?: ApiPropertyOptions, overrideExisting?: boolean): PropertyDecorator;
|
|
14
|
+
export declare function ApiPropertyOptional(options?: ApiPropertyOptions): PropertyDecorator;
|
|
15
|
+
export declare function ApiResponseProperty(options?: Pick<ApiPropertyOptions, 'type' | 'example' | 'format' | 'deprecated' | 'enum'>): PropertyDecorator;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiProperty = ApiProperty;
|
|
4
|
+
exports.createApiPropertyDecorator = createApiPropertyDecorator;
|
|
5
|
+
exports.ApiPropertyOptional = ApiPropertyOptional;
|
|
6
|
+
exports.ApiResponseProperty = ApiResponseProperty;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const enum_utils_1 = require("../utils/enum.utils");
|
|
9
|
+
const helpers_1 = require("./helpers");
|
|
10
|
+
const isEnumArray = (opts) => opts.isArray && 'enum' in opts && opts.enum !== undefined;
|
|
11
|
+
function ApiProperty(options = {}) {
|
|
12
|
+
return createApiPropertyDecorator(options);
|
|
13
|
+
}
|
|
14
|
+
function createApiPropertyDecorator(options = {}, overrideExisting = true) {
|
|
15
|
+
const [type, isArray] = (0, helpers_1.getTypeIsArrayTuple)(options.type, options.isArray);
|
|
16
|
+
options = Object.assign(Object.assign({}, options), { type,
|
|
17
|
+
isArray });
|
|
18
|
+
if (isEnumArray(options)) {
|
|
19
|
+
options.type = 'array';
|
|
20
|
+
const enumValues = (0, enum_utils_1.getEnumValues)(options.enum);
|
|
21
|
+
options.items = {
|
|
22
|
+
type: (0, enum_utils_1.getEnumType)(enumValues),
|
|
23
|
+
enum: enumValues
|
|
24
|
+
};
|
|
25
|
+
delete options.enum;
|
|
26
|
+
}
|
|
27
|
+
else if ('enum' in options && options.enum !== undefined) {
|
|
28
|
+
const enumValues = (0, enum_utils_1.getEnumValues)(options.enum);
|
|
29
|
+
options.enum = enumValues;
|
|
30
|
+
options.type = (0, enum_utils_1.getEnumType)(enumValues);
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(options.type)) {
|
|
33
|
+
options.type = 'array';
|
|
34
|
+
options.items = {
|
|
35
|
+
type: 'array',
|
|
36
|
+
items: {
|
|
37
|
+
type: options.type[0]
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return (0, helpers_1.createPropertyDecorator)(constants_1.DECORATORS.API_MODEL_PROPERTIES, options, overrideExisting);
|
|
42
|
+
}
|
|
43
|
+
function ApiPropertyOptional(options = {}) {
|
|
44
|
+
return ApiProperty(Object.assign(Object.assign({}, options), { required: false }));
|
|
45
|
+
}
|
|
46
|
+
function ApiResponseProperty(options = {}) {
|
|
47
|
+
return ApiProperty(Object.assign({ readOnly: true }, options));
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiQueryMethod(): MethodDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiQueryMethod = ApiQueryMethod;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
function ApiQueryMethod() {
|
|
7
|
+
return (0, helpers_1.createMethodDecorator)(constants_1.DECORATORS.API_QUERY_METHOD, true);
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { EnumSchemaAttributes } from '../interfaces/enum-schema-attributes.interface';
|
|
3
|
+
import { ParameterObject, ReferenceObject, SchemaObject } from '../interfaces/open-api-spec.interface';
|
|
4
|
+
import { SwaggerEnumType } from '../types/swagger-enum.type';
|
|
5
|
+
type ParameterOptions = Omit<ParameterObject, 'in' | 'schema' | 'name'>;
|
|
6
|
+
interface ApiQueryCommonMetadata extends ParameterOptions {
|
|
7
|
+
type?: Type<unknown> | Function | [Function] | string;
|
|
8
|
+
isArray?: boolean;
|
|
9
|
+
enum?: SwaggerEnumType;
|
|
10
|
+
}
|
|
11
|
+
export type ApiQueryMetadata = ApiQueryCommonMetadata | ({
|
|
12
|
+
name: string;
|
|
13
|
+
} & ApiQueryCommonMetadata & Omit<SchemaObject, 'required'>) | ({
|
|
14
|
+
name?: string;
|
|
15
|
+
enumName: string;
|
|
16
|
+
enumSchema?: EnumSchemaAttributes;
|
|
17
|
+
} & ApiQueryCommonMetadata);
|
|
18
|
+
interface ApiQuerySchemaHost extends ParameterOptions {
|
|
19
|
+
name?: string;
|
|
20
|
+
schema: SchemaObject | ReferenceObject;
|
|
21
|
+
}
|
|
22
|
+
export type ApiQueryOptions = ApiQueryMetadata | ApiQuerySchemaHost;
|
|
23
|
+
export declare function ApiQuery(options: ApiQueryOptions): MethodDecorator & ClassDecorator;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiQuery = ApiQuery;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const enum_utils_1 = require("../utils/enum.utils");
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
7
|
+
const defaultQueryOptions = {
|
|
8
|
+
name: '',
|
|
9
|
+
required: true
|
|
10
|
+
};
|
|
11
|
+
function ApiQuery(options) {
|
|
12
|
+
const apiQueryMetadata = options;
|
|
13
|
+
const [type, isArray] = (0, helpers_1.getTypeIsArrayTuple)(apiQueryMetadata.type, apiQueryMetadata.isArray);
|
|
14
|
+
const param = Object.assign(Object.assign({ name: 'name' in options ? options.name : defaultQueryOptions.name, in: 'query' }, (0, lodash_1.omit)(options, 'enum')), { type });
|
|
15
|
+
if ((0, enum_utils_1.isEnumArray)(options)) {
|
|
16
|
+
(0, enum_utils_1.addEnumArraySchema)(param, options);
|
|
17
|
+
}
|
|
18
|
+
else if ((0, enum_utils_1.isEnumDefined)(options)) {
|
|
19
|
+
(0, enum_utils_1.addEnumSchema)(param, options);
|
|
20
|
+
}
|
|
21
|
+
if (isArray) {
|
|
22
|
+
param.isArray = isArray;
|
|
23
|
+
}
|
|
24
|
+
return (0, helpers_1.createParamDecorator)(param, defaultQueryOptions);
|
|
25
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { ReferenceObject, ResponseObject, SchemaObject } from '../interfaces/open-api-spec.interface';
|
|
3
|
+
type ApiResponseExampleValue = any;
|
|
4
|
+
export interface ApiResponseExamples {
|
|
5
|
+
summary: string;
|
|
6
|
+
value: ApiResponseExampleValue;
|
|
7
|
+
}
|
|
8
|
+
export interface ApiResponseCommonMetadata extends Omit<ResponseObject, 'description'> {
|
|
9
|
+
status?: number | 'default' | '1XX' | '2XX' | '3XX' | '4XX' | '5XX';
|
|
10
|
+
type?: Type<unknown> | Function | [Function] | string;
|
|
11
|
+
isArray?: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
export type ApiResponseMetadata = (ApiResponseCommonMetadata & {
|
|
15
|
+
example?: ApiResponseExampleValue;
|
|
16
|
+
}) | (ApiResponseCommonMetadata & {
|
|
17
|
+
examples?: {
|
|
18
|
+
[key: string]: ApiResponseExamples;
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
export interface ApiResponseSchemaHost extends Omit<ResponseObject, 'description'> {
|
|
22
|
+
schema: SchemaObject & Partial<ReferenceObject>;
|
|
23
|
+
status?: number | 'default' | '1XX' | '2XX' | '3XX' | '4XX' | '5XX';
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
export type ApiResponseOptions = ApiResponseMetadata | ApiResponseSchemaHost;
|
|
27
|
+
export type ApiResponseNoStatusOptions = (Omit<ApiResponseCommonMetadata, 'status'> & {
|
|
28
|
+
example?: ApiResponseExampleValue;
|
|
29
|
+
}) | (Omit<ApiResponseCommonMetadata, 'status'> & {
|
|
30
|
+
examples?: {
|
|
31
|
+
[key: string]: ApiResponseExamples;
|
|
32
|
+
};
|
|
33
|
+
}) | Omit<ApiResponseSchemaHost, 'status'>;
|
|
34
|
+
export declare function ApiResponse(options: ApiResponseOptions, { overrideExisting }?: {
|
|
35
|
+
overrideExisting: boolean;
|
|
36
|
+
}): MethodDecorator & ClassDecorator;
|
|
37
|
+
export declare const ApiContinueResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiSwitchingProtocolsResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiProcessingResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiEarlyhintsResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiOkResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiCreatedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiAcceptedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiNonAuthoritativeInformationResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiNoContentResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiResetContentResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiPartialContentResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiAmbiguousResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiMovedPermanentlyResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiFoundResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiSeeOtherResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiNotModifiedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiTemporaryRedirectResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiPermanentRedirectResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiBadRequestResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiUnauthorizedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiPaymentRequiredResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiForbiddenResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiNotFoundResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiMethodNotAllowedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiNotAcceptableResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiProxyAuthenticationRequiredResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiRequestTimeoutResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiConflictResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiGoneResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiLengthRequiredResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiPreconditionFailedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiPayloadTooLargeResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiUriTooLongResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiUnsupportedMediaTypeResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiRequestedRangeNotSatisfiableResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiExpectationFailedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiIAmATeapotResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiMisdirectedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiUnprocessableEntityResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiFailedDependencyResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiPreconditionRequiredResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiTooManyRequestsResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiInternalServerErrorResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiNotImplementedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiBadGatewayResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiServiceUnavailableResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiGatewayTimeoutResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator, ApiHttpVersionNotSupportedResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator;
|
|
38
|
+
export declare const ApiDefaultResponse: (options?: ApiResponseNoStatusOptions) => MethodDecorator & ClassDecorator;
|
|
39
|
+
export {};
|