@mondart/nestjs-common-module 1.1.26 → 1.1.28
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.
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export declare function CustomApiResponse(options: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export declare function CustomApiResponse({ options, }: {
|
|
2
|
+
options: {
|
|
3
|
+
status: number;
|
|
4
|
+
description: string;
|
|
5
|
+
responseDto: any;
|
|
6
|
+
isArray?: boolean;
|
|
7
|
+
};
|
|
5
8
|
}): (target: any, key?: string, descriptor?: PropertyDescriptor) => void;
|
|
@@ -3,21 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CustomApiResponse = CustomApiResponse;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
-
const
|
|
6
|
+
const dto_1 = require("../dto");
|
|
7
7
|
const swagger_2 = require("@nestjs/swagger");
|
|
8
|
-
function CustomApiResponse(options) {
|
|
8
|
+
function CustomApiResponse({ options, }) {
|
|
9
9
|
return function (target, key, descriptor) {
|
|
10
|
+
const dataSchema = options.isArray
|
|
11
|
+
? {
|
|
12
|
+
type: 'array',
|
|
13
|
+
items: {
|
|
14
|
+
$ref: (0, swagger_1.getSchemaPath)(options.responseDto),
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
: {
|
|
18
|
+
$ref: (0, swagger_1.getSchemaPath)(options.responseDto),
|
|
19
|
+
};
|
|
10
20
|
return (0, common_1.applyDecorators)((0, swagger_2.ApiResponse)({
|
|
11
21
|
status: options.status,
|
|
12
22
|
description: options.description,
|
|
13
23
|
schema: {
|
|
14
|
-
$ref: (0, swagger_1.getSchemaPath)(success_response_dto_1.SuccessResponse),
|
|
15
24
|
type: 'object',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
allOf: [
|
|
26
|
+
{ $ref: (0, swagger_1.getSchemaPath)(dto_1.SuccessResponse) },
|
|
27
|
+
{
|
|
28
|
+
properties: {
|
|
29
|
+
data: dataSchema,
|
|
30
|
+
},
|
|
19
31
|
},
|
|
20
|
-
|
|
32
|
+
],
|
|
21
33
|
},
|
|
22
34
|
}))(target, key, descriptor);
|
|
23
35
|
};
|