@globalart/nestjs-swagger 1.2.5 → 1.2.7

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/README.md CHANGED
@@ -2,203 +2,10 @@
2
2
 
3
3
  A simple documentation builder for NestJS Swagger module that simplifies creating OpenAPI documentation for your REST APIs.
4
4
 
5
- ## Installation
5
+ ## Documentation
6
6
 
7
- ```bash
8
- npm install @globalart/nestjs-swagger
9
- ```
7
+ For complete documentation, examples, and API reference, please visit the [official documentation](https://globalart.js.org/packages/nestjs-swagger).
10
8
 
11
- or
9
+ ## License
12
10
 
13
- ```bash
14
- yarn add @globalart/nestjs-swagger
15
- ```
16
-
17
- ## Description
18
-
19
- This package provides a convenient `SwaggerDocumentation` decorator for automatic Swagger documentation generation in NestJS applications. It significantly simplifies the process of adding documentation to your endpoints by providing a unified interface for describing operations and possible errors.
20
-
21
- ## Key Features
22
-
23
- - 📝 Simple decorator for endpoint documentation
24
- - 🔧 Pre-configured descriptions for standard HTTP errors
25
- - 📊 Support for paginated responses
26
- - 🎯 Support for arrays in responses
27
- - 📋 Automatic schema generation for DTOs
28
- - 🛡️ Full TypeScript typing
29
-
30
- ## Quick Start
31
-
32
- ```typescript
33
- import { Controller, Get } from '@nestjs/common';
34
- import { SwaggerDocumentation, ERROR_DESCRIPTIONS } from '@globalart/nestjs-swagger';
35
-
36
- @Controller('users')
37
- export class UsersController {
38
- @Get()
39
- @SwaggerDocumentation({
40
- endpointDescription: 'Get list of all users',
41
- endpointSummary: 'List users',
42
- error400Description: ERROR_DESCRIPTIONS.BAD_REQUEST,
43
- error401Description: ERROR_DESCRIPTIONS.UNAUTHORIZED,
44
- error500Description: ERROR_DESCRIPTIONS.INTERNAL_SERVER_ERROR
45
- })
46
- async getAllUsers() {
47
- return [];
48
- }
49
- }
50
- ```
51
-
52
- ## API Reference
53
-
54
- ### SwaggerDocumentation
55
-
56
- Decorator for automatic Swagger documentation generation.
57
-
58
- #### Parameters
59
-
60
- | Parameter | Type | Description |
61
- | --------------------- | ---------- | ------------------------------------ |
62
- | `endpointDescription` | `string` | Detailed endpoint description |
63
- | `endpointSummary` | `string` | Brief endpoint description |
64
- | `responseDto` | `Function` | DTO class for response |
65
- | `isArray` | `boolean` | Indicates that response is an array |
66
- | `isPaginated` | `boolean` | Indicates that response is paginated |
67
- | `error400Description` | `string` | 400 error description |
68
- | `error401Description` | `string` | 401 error description |
69
- | `error403Description` | `string` | 403 error description |
70
- | `error404Description` | `string` | 404 error description |
71
- | `error409Description` | `string` | 409 error description |
72
- | `error422Description` | `string` | 422 error description |
73
- | `error429Description` | `string` | 429 error description |
74
- | `error500Description` | `string` | 500 error description |
75
- | `error503Description` | `string` | 503 error description |
76
-
77
- ### ERROR_DESCRIPTIONS
78
-
79
- Object with pre-configured error descriptions:
80
-
81
- ```typescript
82
- export const ERROR_DESCRIPTIONS = {
83
- BAD_REQUEST: "Invalid request data or parameters",
84
- UNAUTHORIZED: "Authentication required",
85
- FORBIDDEN: "Access denied",
86
- NOT_FOUND: "Resource not found",
87
- CONFLICT: "Resource already exists or conflict detected",
88
- UNPROCESSABLE_ENTITY: "Validation error",
89
- RATE_LIMIT_EXCEEDED: "Rate limit exceeded. Too many requests",
90
- INTERNAL_SERVER_ERROR: "Internal server error",
91
- SERVICE_UNAVAILABLE: "Service temporarily unavailable"
92
- };
93
- ```
94
-
95
- ## Usage Examples
96
-
97
- ### Basic Usage
98
-
99
- ```typescript
100
- import { Controller, Get } from '@nestjs/common';
101
- import { SwaggerDocumentation, ERROR_DESCRIPTIONS } from '@globalart/nestjs-swagger';
102
-
103
- @Controller()
104
- export class AppController {
105
- @Get('hello')
106
- @SwaggerDocumentation({
107
- endpointDescription: 'Simple greeting endpoint',
108
- endpointSummary: 'Greeting',
109
- error400Description: ERROR_DESCRIPTIONS.BAD_REQUEST,
110
- error401Description: ERROR_DESCRIPTIONS.UNAUTHORIZED,
111
- error403Description: ERROR_DESCRIPTIONS.FORBIDDEN,
112
- error404Description: ERROR_DESCRIPTIONS.NOT_FOUND,
113
- error429Description: ERROR_DESCRIPTIONS.RATE_LIMIT_EXCEEDED,
114
- error500Description: ERROR_DESCRIPTIONS.INTERNAL_SERVER_ERROR
115
- })
116
- async hello() {
117
- return 'Hello World';
118
- }
119
- }
120
- ```
121
-
122
- ### Using with DTO
123
-
124
- ```typescript
125
- import { ApiProperty } from '@nestjs/swagger';
126
-
127
- export class UserDto {
128
- @ApiProperty()
129
- id: number;
130
-
131
- @ApiProperty()
132
- name: string;
133
-
134
- @ApiProperty()
135
- email: string;
136
- }
137
-
138
- @Controller('users')
139
- export class UsersController {
140
- @Get(':id')
141
- @SwaggerDocumentation({
142
- endpointDescription: 'Get user by ID',
143
- endpointSummary: 'Get user',
144
- responseDto: UserDto,
145
- error404Description: ERROR_DESCRIPTIONS.NOT_FOUND,
146
- error500Description: ERROR_DESCRIPTIONS.INTERNAL_SERVER_ERROR
147
- })
148
- async getUserById(@Param('id') id: number) {
149
- // user retrieval logic
150
- }
151
- }
152
- ```
153
-
154
- ### Working with Arrays
155
-
156
- ```typescript
157
- @Controller('users')
158
- export class UsersController {
159
- @Get()
160
- @SwaggerDocumentation({
161
- endpointDescription: 'Get list of all users',
162
- endpointSummary: 'List users',
163
- responseDto: UserDto,
164
- isArray: true,
165
- error500Description: ERROR_DESCRIPTIONS.INTERNAL_SERVER_ERROR
166
- })
167
- async getAllUsers() {
168
- // user list retrieval logic
169
- }
170
- }
171
- ```
172
-
173
- ### Paginated Responses
174
-
175
- ```typescript
176
- @Controller('users')
177
- export class UsersController {
178
- @Get()
179
- @SwaggerDocumentation({
180
- endpointDescription: 'Get paginated list of users',
181
- endpointSummary: 'Paginated user list',
182
- responseDto: UserDto,
183
- isPaginated: true,
184
- error400Description: ERROR_DESCRIPTIONS.BAD_REQUEST,
185
- error500Description: ERROR_DESCRIPTIONS.INTERNAL_SERVER_ERROR
186
- })
187
- async getPaginatedUsers(@Query() query: PaginationDto) {
188
- // pagination logic
189
- }
190
- }
191
- ```
192
-
193
- ## Paginated Response Structure
194
-
195
- When using `isPaginated: true`, the response is automatically wrapped in the structure:
196
-
197
- ```typescript
198
- {
199
- data: T[], // array of objects of the specified DTO
200
- totalCount: number, // total number of records
201
- offset: number, // offset
202
- limit: number // limit of records per page
203
- }
204
- ```
11
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,86 @@
1
+ let _nestjs_common = require("@nestjs/common");
2
+ let _nestjs_swagger = require("@nestjs/swagger");
3
+
4
+ //#region src/constants.ts
5
+ const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
6
+ const ERROR_DESCRIPTIONS = {
7
+ BAD_REQUEST: "Invalid request data or parameters",
8
+ UNAUTHORIZED: "Authentication required",
9
+ FORBIDDEN: "Access denied",
10
+ NOT_FOUND: "Resource not found",
11
+ CONFLICT: "Resource already exists or conflict detected",
12
+ UNPROCESSABLE_ENTITY: "Validation error",
13
+ RATE_LIMIT_EXCEEDED: "Rate limit exceeded. Too many requests",
14
+ INTERNAL_SERVER_ERROR: "Internal server error",
15
+ SERVICE_UNAVAILABLE: "Service temporarily unavailable"
16
+ };
17
+
18
+ //#endregion
19
+ //#region \0@oxc-project+runtime@0.106.0/helpers/decorateMetadata.js
20
+ function __decorateMetadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+
24
+ //#endregion
25
+ //#region \0@oxc-project+runtime@0.106.0/helpers/decorate.js
26
+ function __decorate(decorators, target, key, desc) {
27
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
28
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
29
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
31
+ }
32
+
33
+ //#endregion
34
+ //#region src/dtos/index.ts
35
+ var PaginatedResponseDto = class {
36
+ data;
37
+ totalCount;
38
+ offset;
39
+ limit;
40
+ };
41
+ __decorate([(0, _nestjs_swagger.ApiProperty)(), __decorateMetadata("design:type", Number)], PaginatedResponseDto.prototype, "totalCount", void 0);
42
+ __decorate([(0, _nestjs_swagger.ApiProperty)(), __decorateMetadata("design:type", Number)], PaginatedResponseDto.prototype, "offset", void 0);
43
+ __decorate([(0, _nestjs_swagger.ApiProperty)(), __decorateMetadata("design:type", Number)], PaginatedResponseDto.prototype, "limit", void 0);
44
+
45
+ //#endregion
46
+ //#region src/decorators/index.ts
47
+ const SwaggerDocumentation = (data) => {
48
+ const operationId = data.operationId;
49
+ const decorators = [(0, _nestjs_swagger.ApiOperation)({
50
+ operationId,
51
+ description: data.endpointDescription,
52
+ summary: data.endpointSummary,
53
+ deprecated: data.deprecated
54
+ })];
55
+ if (data.error400Description) decorators.push((0, _nestjs_swagger.ApiBadRequestResponse)({ description: data.error400Description }));
56
+ if (data.error401Description) decorators.push((0, _nestjs_swagger.ApiUnauthorizedResponse)({ description: data.error401Description }));
57
+ if (data.error403Description) decorators.push((0, _nestjs_swagger.ApiForbiddenResponse)({ description: data.error403Description }));
58
+ if (data.error404Description) decorators.push((0, _nestjs_swagger.ApiNotFoundResponse)({ description: data.error404Description }));
59
+ if (data.error409Description) decorators.push((0, _nestjs_swagger.ApiConflictResponse)({ description: data.error409Description }));
60
+ if (data.error422Description) decorators.push((0, _nestjs_swagger.ApiUnprocessableEntityResponse)({ description: data.error422Description }));
61
+ if (data.error429Description) decorators.push((0, _nestjs_swagger.ApiTooManyRequestsResponse)({ description: data.error429Description }));
62
+ if (data.error500Description) decorators.push((0, _nestjs_swagger.ApiInternalServerErrorResponse)({ description: data.error500Description }));
63
+ if (data.error503Description) decorators.push((0, _nestjs_swagger.ApiServiceUnavailableResponse)({ description: data.error503Description }));
64
+ if (data.isPaginated && data.responseDto) decorators.push((0, _nestjs_swagger.ApiOkResponse)({
65
+ schema: { allOf: [{ $ref: (0, _nestjs_swagger.getSchemaPath)(PaginatedResponseDto) }, { properties: { data: {
66
+ type: "array",
67
+ items: { $ref: (0, _nestjs_swagger.getSchemaPath)(data.responseDto) }
68
+ } } }] },
69
+ description: API_RESPONSE_DESCRIPTION
70
+ }), (0, _nestjs_swagger.ApiExtraModels)(data.responseDto, PaginatedResponseDto));
71
+ else if (data.responseDto) decorators.push((0, _nestjs_swagger.ApiOkResponse)({
72
+ schema: data.isArray ? {
73
+ type: "array",
74
+ items: { $ref: (0, _nestjs_swagger.getSchemaPath)(data.responseDto) }
75
+ } : { $ref: (0, _nestjs_swagger.getSchemaPath)(data.responseDto) },
76
+ description: API_RESPONSE_DESCRIPTION
77
+ }), (0, _nestjs_swagger.ApiExtraModels)(data.responseDto));
78
+ else decorators.push((0, _nestjs_swagger.ApiOkResponse)({ description: API_RESPONSE_DESCRIPTION }));
79
+ return (0, _nestjs_common.applyDecorators)(...decorators);
80
+ };
81
+
82
+ //#endregion
83
+ exports.API_RESPONSE_DESCRIPTION = API_RESPONSE_DESCRIPTION;
84
+ exports.ERROR_DESCRIPTIONS = ERROR_DESCRIPTIONS;
85
+ exports.SwaggerDocumentation = SwaggerDocumentation;
86
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/constants.ts","../src/dtos/index.ts","../src/decorators/index.ts"],"sourcesContent":["export const API_RESPONSE_DESCRIPTION =\n \"If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text\";\n\nexport const ERROR_DESCRIPTIONS = {\n BAD_REQUEST: \"Invalid request data or parameters\",\n UNAUTHORIZED: \"Authentication required\",\n FORBIDDEN: \"Access denied\",\n NOT_FOUND: \"Resource not found\",\n CONFLICT: \"Resource already exists or conflict detected\",\n UNPROCESSABLE_ENTITY: \"Validation error\",\n RATE_LIMIT_EXCEEDED: \"Rate limit exceeded. Too many requests\",\n INTERNAL_SERVER_ERROR: \"Internal server error\",\n SERVICE_UNAVAILABLE: \"Service temporarily unavailable\",\n};\n","import { ApiProperty } from \"@nestjs/swagger\";\n\nexport class PaginatedResponseDto<T> {\n data!: T[];\n\n @ApiProperty()\n totalCount!: number;\n\n @ApiProperty()\n offset!: number;\n\n @ApiProperty()\n limit!: number;\n}\n","import { applyDecorators } from \"@nestjs/common\";\nimport {\n ApiBadRequestResponse,\n ApiConflictResponse,\n ApiExtraModels,\n ApiForbiddenResponse,\n ApiInternalServerErrorResponse,\n ApiNotFoundResponse,\n ApiOkResponse,\n ApiOperation,\n ApiServiceUnavailableResponse,\n ApiTooManyRequestsResponse,\n ApiUnauthorizedResponse,\n ApiUnprocessableEntityResponse,\n getSchemaPath,\n} from \"@nestjs/swagger\";\nimport { API_RESPONSE_DESCRIPTION } from \"../constants\";\nimport { PaginatedResponseDto } from \"../dtos\";\nimport { SwaggerDocumentationOptions } from \"../interfaces\";\nimport { createHash } from \"crypto\";\n\n// SwaggerDocumentation is a decorator function to generate Swagger documentation for endpoints based on the provided options.\nexport const SwaggerDocumentation = (data: SwaggerDocumentationOptions) => {\n const operationId = data.operationId;\n\n const decorators = [\n ApiOperation({\n operationId,\n description: data.endpointDescription,\n summary: data.endpointSummary,\n deprecated: data.deprecated,\n }),\n ];\n\n if (data.error400Description) {\n decorators.push(\n ApiBadRequestResponse({\n description: data.error400Description,\n })\n );\n }\n\n if (data.error401Description) {\n decorators.push(\n ApiUnauthorizedResponse({\n description: data.error401Description,\n })\n );\n }\n\n if (data.error403Description) {\n decorators.push(\n ApiForbiddenResponse({\n description: data.error403Description,\n })\n );\n }\n\n if (data.error404Description) {\n decorators.push(\n ApiNotFoundResponse({\n description: data.error404Description,\n })\n );\n }\n\n if (data.error409Description) {\n decorators.push(\n ApiConflictResponse({\n description: data.error409Description,\n })\n );\n }\n\n if (data.error422Description) {\n decorators.push(\n ApiUnprocessableEntityResponse({\n description: data.error422Description,\n })\n );\n }\n\n if (data.error429Description) {\n decorators.push(\n ApiTooManyRequestsResponse({\n description: data.error429Description,\n })\n );\n }\n\n if (data.error500Description) {\n decorators.push(\n ApiInternalServerErrorResponse({\n description: data.error500Description,\n })\n );\n }\n\n if (data.error503Description) {\n decorators.push(\n ApiServiceUnavailableResponse({\n description: data.error503Description,\n })\n );\n }\n\n if (data.isPaginated && data.responseDto) {\n decorators.push(\n ApiOkResponse({\n schema: {\n allOf: [\n { $ref: getSchemaPath(PaginatedResponseDto) },\n {\n properties: {\n data: {\n type: \"array\",\n items: {\n $ref: getSchemaPath(data.responseDto),\n },\n },\n },\n },\n ],\n },\n description: API_RESPONSE_DESCRIPTION,\n }),\n ApiExtraModels(data.responseDto, PaginatedResponseDto)\n );\n } else if (data.responseDto) {\n decorators.push(\n ApiOkResponse({\n schema: data.isArray\n ? {\n type: \"array\",\n items: { $ref: getSchemaPath(data.responseDto) },\n }\n : { $ref: getSchemaPath(data.responseDto) },\n description: API_RESPONSE_DESCRIPTION,\n }),\n ApiExtraModels(data.responseDto)\n );\n } else {\n decorators.push(\n ApiOkResponse({\n description: API_RESPONSE_DESCRIPTION,\n })\n );\n }\n\n return applyDecorators(...decorators);\n};\n"],"mappings":";;;;AAAA,MAAa,2BACX;AAEF,MAAa,qBAAqB;CAChC,aAAa;CACb,cAAc;CACd,WAAW;CACX,WAAW;CACX,UAAU;CACV,sBAAsB;CACtB,qBAAqB;CACrB,uBAAuB;CACvB,qBAAqB;CACtB;;;;;;;;;;;;;;;;;;;ACXD,IAAa,uBAAb,MAAqC;CACnC;CAEA,AACA;CAEA,AACA;CAEA,AACA;;8CAPc;8CAGA;8CAGA;;;;ACWhB,MAAa,wBAAwB,SAAsC;CACzE,MAAM,cAAc,KAAK;CAEzB,MAAM,aAAa,mCACJ;EACX;EACA,aAAa,KAAK;EAClB,SAAS,KAAK;EACd,YAAY,KAAK;EAClB,CAAC,CACH;AAED,KAAI,KAAK,oBACP,YAAW,gDACa,EACpB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,kDACe,EACtB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,+CACY,EACnB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,8CACW,EAClB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,8CACW,EAClB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,yDACsB,EAC7B,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,qDACkB,EACzB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,yDACsB,EAC7B,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,wDACqB,EAC5B,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,eAAe,KAAK,YAC3B,YAAW,wCACK;EACZ,QAAQ,EACN,OAAO,CACL,EAAE,yCAAoB,qBAAqB,EAAE,EAC7C,EACE,YAAY,EACV,MAAM;GACJ,MAAM;GACN,OAAO,EACL,yCAAoB,KAAK,YAAY,EACtC;GACF,EACF,EACF,CACF,EACF;EACD,aAAa;EACd,CAAC,sCACa,KAAK,aAAa,qBAAqB,CACvD;UACQ,KAAK,YACd,YAAW,wCACK;EACZ,QAAQ,KAAK,UACT;GACE,MAAM;GACN,OAAO,EAAE,yCAAoB,KAAK,YAAY,EAAE;GACjD,GACD,EAAE,yCAAoB,KAAK,YAAY,EAAE;EAC7C,aAAa;EACd,CAAC,sCACa,KAAK,YAAY,CACjC;KAED,YAAW,wCACK,EACZ,aAAa,0BACd,CAAC,CACH;AAGH,4CAAuB,GAAG,WAAW"}
@@ -0,0 +1,41 @@
1
+ //#region src/constants.d.ts
2
+ declare const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
3
+ declare const ERROR_DESCRIPTIONS: {
4
+ BAD_REQUEST: string;
5
+ UNAUTHORIZED: string;
6
+ FORBIDDEN: string;
7
+ NOT_FOUND: string;
8
+ CONFLICT: string;
9
+ UNPROCESSABLE_ENTITY: string;
10
+ RATE_LIMIT_EXCEEDED: string;
11
+ INTERNAL_SERVER_ERROR: string;
12
+ SERVICE_UNAVAILABLE: string;
13
+ };
14
+ //#endregion
15
+ //#region src/interfaces/index.d.ts
16
+ interface SwaggerDocumentationErrorStatus {
17
+ error400Description?: string;
18
+ error401Description?: string;
19
+ error403Description?: string;
20
+ error404Description?: string;
21
+ error409Description?: string;
22
+ error422Description?: string;
23
+ error429Description?: string;
24
+ error500Description?: string;
25
+ error503Description?: string;
26
+ }
27
+ interface SwaggerDocumentationOptions extends SwaggerDocumentationErrorStatus {
28
+ endpointSummary: string;
29
+ endpointDescription?: string;
30
+ operationId?: string;
31
+ responseDto?: any;
32
+ isArray?: boolean;
33
+ isPaginated?: boolean;
34
+ deprecated?: boolean;
35
+ }
36
+ //#endregion
37
+ //#region src/decorators/index.d.ts
38
+ declare const SwaggerDocumentation: (data: SwaggerDocumentationOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
39
+ //#endregion
40
+ export { API_RESPONSE_DESCRIPTION, ERROR_DESCRIPTIONS, SwaggerDocumentation, SwaggerDocumentationErrorStatus, SwaggerDocumentationOptions };
41
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,41 @@
1
+ //#region src/constants.d.ts
2
+ declare const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
3
+ declare const ERROR_DESCRIPTIONS: {
4
+ BAD_REQUEST: string;
5
+ UNAUTHORIZED: string;
6
+ FORBIDDEN: string;
7
+ NOT_FOUND: string;
8
+ CONFLICT: string;
9
+ UNPROCESSABLE_ENTITY: string;
10
+ RATE_LIMIT_EXCEEDED: string;
11
+ INTERNAL_SERVER_ERROR: string;
12
+ SERVICE_UNAVAILABLE: string;
13
+ };
14
+ //#endregion
15
+ //#region src/interfaces/index.d.ts
16
+ interface SwaggerDocumentationErrorStatus {
17
+ error400Description?: string;
18
+ error401Description?: string;
19
+ error403Description?: string;
20
+ error404Description?: string;
21
+ error409Description?: string;
22
+ error422Description?: string;
23
+ error429Description?: string;
24
+ error500Description?: string;
25
+ error503Description?: string;
26
+ }
27
+ interface SwaggerDocumentationOptions extends SwaggerDocumentationErrorStatus {
28
+ endpointSummary: string;
29
+ endpointDescription?: string;
30
+ operationId?: string;
31
+ responseDto?: any;
32
+ isArray?: boolean;
33
+ isPaginated?: boolean;
34
+ deprecated?: boolean;
35
+ }
36
+ //#endregion
37
+ //#region src/decorators/index.d.ts
38
+ declare const SwaggerDocumentation: (data: SwaggerDocumentationOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
39
+ //#endregion
40
+ export { API_RESPONSE_DESCRIPTION, ERROR_DESCRIPTIONS, SwaggerDocumentation, SwaggerDocumentationErrorStatus, SwaggerDocumentationOptions };
41
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,84 @@
1
+ import { applyDecorators } from "@nestjs/common";
2
+ import { ApiBadRequestResponse, ApiConflictResponse, ApiExtraModels, ApiForbiddenResponse, ApiInternalServerErrorResponse, ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiProperty, ApiServiceUnavailableResponse, ApiTooManyRequestsResponse, ApiUnauthorizedResponse, ApiUnprocessableEntityResponse, getSchemaPath } from "@nestjs/swagger";
3
+
4
+ //#region src/constants.ts
5
+ const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
6
+ const ERROR_DESCRIPTIONS = {
7
+ BAD_REQUEST: "Invalid request data or parameters",
8
+ UNAUTHORIZED: "Authentication required",
9
+ FORBIDDEN: "Access denied",
10
+ NOT_FOUND: "Resource not found",
11
+ CONFLICT: "Resource already exists or conflict detected",
12
+ UNPROCESSABLE_ENTITY: "Validation error",
13
+ RATE_LIMIT_EXCEEDED: "Rate limit exceeded. Too many requests",
14
+ INTERNAL_SERVER_ERROR: "Internal server error",
15
+ SERVICE_UNAVAILABLE: "Service temporarily unavailable"
16
+ };
17
+
18
+ //#endregion
19
+ //#region \0@oxc-project+runtime@0.106.0/helpers/decorateMetadata.js
20
+ function __decorateMetadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+
24
+ //#endregion
25
+ //#region \0@oxc-project+runtime@0.106.0/helpers/decorate.js
26
+ function __decorate(decorators, target, key, desc) {
27
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
28
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
29
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
31
+ }
32
+
33
+ //#endregion
34
+ //#region src/dtos/index.ts
35
+ var PaginatedResponseDto = class {
36
+ data;
37
+ totalCount;
38
+ offset;
39
+ limit;
40
+ };
41
+ __decorate([ApiProperty(), __decorateMetadata("design:type", Number)], PaginatedResponseDto.prototype, "totalCount", void 0);
42
+ __decorate([ApiProperty(), __decorateMetadata("design:type", Number)], PaginatedResponseDto.prototype, "offset", void 0);
43
+ __decorate([ApiProperty(), __decorateMetadata("design:type", Number)], PaginatedResponseDto.prototype, "limit", void 0);
44
+
45
+ //#endregion
46
+ //#region src/decorators/index.ts
47
+ const SwaggerDocumentation = (data) => {
48
+ const operationId = data.operationId;
49
+ const decorators = [ApiOperation({
50
+ operationId,
51
+ description: data.endpointDescription,
52
+ summary: data.endpointSummary,
53
+ deprecated: data.deprecated
54
+ })];
55
+ if (data.error400Description) decorators.push(ApiBadRequestResponse({ description: data.error400Description }));
56
+ if (data.error401Description) decorators.push(ApiUnauthorizedResponse({ description: data.error401Description }));
57
+ if (data.error403Description) decorators.push(ApiForbiddenResponse({ description: data.error403Description }));
58
+ if (data.error404Description) decorators.push(ApiNotFoundResponse({ description: data.error404Description }));
59
+ if (data.error409Description) decorators.push(ApiConflictResponse({ description: data.error409Description }));
60
+ if (data.error422Description) decorators.push(ApiUnprocessableEntityResponse({ description: data.error422Description }));
61
+ if (data.error429Description) decorators.push(ApiTooManyRequestsResponse({ description: data.error429Description }));
62
+ if (data.error500Description) decorators.push(ApiInternalServerErrorResponse({ description: data.error500Description }));
63
+ if (data.error503Description) decorators.push(ApiServiceUnavailableResponse({ description: data.error503Description }));
64
+ if (data.isPaginated && data.responseDto) decorators.push(ApiOkResponse({
65
+ schema: { allOf: [{ $ref: getSchemaPath(PaginatedResponseDto) }, { properties: { data: {
66
+ type: "array",
67
+ items: { $ref: getSchemaPath(data.responseDto) }
68
+ } } }] },
69
+ description: API_RESPONSE_DESCRIPTION
70
+ }), ApiExtraModels(data.responseDto, PaginatedResponseDto));
71
+ else if (data.responseDto) decorators.push(ApiOkResponse({
72
+ schema: data.isArray ? {
73
+ type: "array",
74
+ items: { $ref: getSchemaPath(data.responseDto) }
75
+ } : { $ref: getSchemaPath(data.responseDto) },
76
+ description: API_RESPONSE_DESCRIPTION
77
+ }), ApiExtraModels(data.responseDto));
78
+ else decorators.push(ApiOkResponse({ description: API_RESPONSE_DESCRIPTION }));
79
+ return applyDecorators(...decorators);
80
+ };
81
+
82
+ //#endregion
83
+ export { API_RESPONSE_DESCRIPTION, ERROR_DESCRIPTIONS, SwaggerDocumentation };
84
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/constants.ts","../src/dtos/index.ts","../src/decorators/index.ts"],"sourcesContent":["export const API_RESPONSE_DESCRIPTION =\n \"If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text\";\n\nexport const ERROR_DESCRIPTIONS = {\n BAD_REQUEST: \"Invalid request data or parameters\",\n UNAUTHORIZED: \"Authentication required\",\n FORBIDDEN: \"Access denied\",\n NOT_FOUND: \"Resource not found\",\n CONFLICT: \"Resource already exists or conflict detected\",\n UNPROCESSABLE_ENTITY: \"Validation error\",\n RATE_LIMIT_EXCEEDED: \"Rate limit exceeded. Too many requests\",\n INTERNAL_SERVER_ERROR: \"Internal server error\",\n SERVICE_UNAVAILABLE: \"Service temporarily unavailable\",\n};\n","import { ApiProperty } from \"@nestjs/swagger\";\n\nexport class PaginatedResponseDto<T> {\n data!: T[];\n\n @ApiProperty()\n totalCount!: number;\n\n @ApiProperty()\n offset!: number;\n\n @ApiProperty()\n limit!: number;\n}\n","import { applyDecorators } from \"@nestjs/common\";\nimport {\n ApiBadRequestResponse,\n ApiConflictResponse,\n ApiExtraModels,\n ApiForbiddenResponse,\n ApiInternalServerErrorResponse,\n ApiNotFoundResponse,\n ApiOkResponse,\n ApiOperation,\n ApiServiceUnavailableResponse,\n ApiTooManyRequestsResponse,\n ApiUnauthorizedResponse,\n ApiUnprocessableEntityResponse,\n getSchemaPath,\n} from \"@nestjs/swagger\";\nimport { API_RESPONSE_DESCRIPTION } from \"../constants\";\nimport { PaginatedResponseDto } from \"../dtos\";\nimport { SwaggerDocumentationOptions } from \"../interfaces\";\nimport { createHash } from \"crypto\";\n\n// SwaggerDocumentation is a decorator function to generate Swagger documentation for endpoints based on the provided options.\nexport const SwaggerDocumentation = (data: SwaggerDocumentationOptions) => {\n const operationId = data.operationId;\n\n const decorators = [\n ApiOperation({\n operationId,\n description: data.endpointDescription,\n summary: data.endpointSummary,\n deprecated: data.deprecated,\n }),\n ];\n\n if (data.error400Description) {\n decorators.push(\n ApiBadRequestResponse({\n description: data.error400Description,\n })\n );\n }\n\n if (data.error401Description) {\n decorators.push(\n ApiUnauthorizedResponse({\n description: data.error401Description,\n })\n );\n }\n\n if (data.error403Description) {\n decorators.push(\n ApiForbiddenResponse({\n description: data.error403Description,\n })\n );\n }\n\n if (data.error404Description) {\n decorators.push(\n ApiNotFoundResponse({\n description: data.error404Description,\n })\n );\n }\n\n if (data.error409Description) {\n decorators.push(\n ApiConflictResponse({\n description: data.error409Description,\n })\n );\n }\n\n if (data.error422Description) {\n decorators.push(\n ApiUnprocessableEntityResponse({\n description: data.error422Description,\n })\n );\n }\n\n if (data.error429Description) {\n decorators.push(\n ApiTooManyRequestsResponse({\n description: data.error429Description,\n })\n );\n }\n\n if (data.error500Description) {\n decorators.push(\n ApiInternalServerErrorResponse({\n description: data.error500Description,\n })\n );\n }\n\n if (data.error503Description) {\n decorators.push(\n ApiServiceUnavailableResponse({\n description: data.error503Description,\n })\n );\n }\n\n if (data.isPaginated && data.responseDto) {\n decorators.push(\n ApiOkResponse({\n schema: {\n allOf: [\n { $ref: getSchemaPath(PaginatedResponseDto) },\n {\n properties: {\n data: {\n type: \"array\",\n items: {\n $ref: getSchemaPath(data.responseDto),\n },\n },\n },\n },\n ],\n },\n description: API_RESPONSE_DESCRIPTION,\n }),\n ApiExtraModels(data.responseDto, PaginatedResponseDto)\n );\n } else if (data.responseDto) {\n decorators.push(\n ApiOkResponse({\n schema: data.isArray\n ? {\n type: \"array\",\n items: { $ref: getSchemaPath(data.responseDto) },\n }\n : { $ref: getSchemaPath(data.responseDto) },\n description: API_RESPONSE_DESCRIPTION,\n }),\n ApiExtraModels(data.responseDto)\n );\n } else {\n decorators.push(\n ApiOkResponse({\n description: API_RESPONSE_DESCRIPTION,\n })\n );\n }\n\n return applyDecorators(...decorators);\n};\n"],"mappings":";;;;AAAA,MAAa,2BACX;AAEF,MAAa,qBAAqB;CAChC,aAAa;CACb,cAAc;CACd,WAAW;CACX,WAAW;CACX,UAAU;CACV,sBAAsB;CACtB,qBAAqB;CACrB,uBAAuB;CACvB,qBAAqB;CACtB;;;;;;;;;;;;;;;;;;;ACXD,IAAa,uBAAb,MAAqC;CACnC;CAEA,AACA;CAEA,AACA;CAEA,AACA;;YAPC,aAAa;YAGb,aAAa;YAGb,aAAa;;;;ACWhB,MAAa,wBAAwB,SAAsC;CACzE,MAAM,cAAc,KAAK;CAEzB,MAAM,aAAa,CACjB,aAAa;EACX;EACA,aAAa,KAAK;EAClB,SAAS,KAAK;EACd,YAAY,KAAK;EAClB,CAAC,CACH;AAED,KAAI,KAAK,oBACP,YAAW,KACT,sBAAsB,EACpB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,wBAAwB,EACtB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,qBAAqB,EACnB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,oBAAoB,EAClB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,oBAAoB,EAClB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,+BAA+B,EAC7B,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,2BAA2B,EACzB,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,+BAA+B,EAC7B,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,oBACP,YAAW,KACT,8BAA8B,EAC5B,aAAa,KAAK,qBACnB,CAAC,CACH;AAGH,KAAI,KAAK,eAAe,KAAK,YAC3B,YAAW,KACT,cAAc;EACZ,QAAQ,EACN,OAAO,CACL,EAAE,MAAM,cAAc,qBAAqB,EAAE,EAC7C,EACE,YAAY,EACV,MAAM;GACJ,MAAM;GACN,OAAO,EACL,MAAM,cAAc,KAAK,YAAY,EACtC;GACF,EACF,EACF,CACF,EACF;EACD,aAAa;EACd,CAAC,EACF,eAAe,KAAK,aAAa,qBAAqB,CACvD;UACQ,KAAK,YACd,YAAW,KACT,cAAc;EACZ,QAAQ,KAAK,UACT;GACE,MAAM;GACN,OAAO,EAAE,MAAM,cAAc,KAAK,YAAY,EAAE;GACjD,GACD,EAAE,MAAM,cAAc,KAAK,YAAY,EAAE;EAC7C,aAAa;EACd,CAAC,EACF,eAAe,KAAK,YAAY,CACjC;KAED,YAAW,KACT,cAAc,EACZ,aAAa,0BACd,CAAC,CACH;AAGH,QAAO,gBAAgB,GAAG,WAAW"}
package/package.json CHANGED
@@ -1,28 +1,35 @@
1
1
  {
2
2
  "name": "@globalart/nestjs-swagger",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "A simple documentation builder for NestJS Swagger Module",
5
5
  "author": {
6
6
  "name": "GlobalArt, Inc"
7
7
  },
8
8
  "license": "MIT",
9
- "main": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
9
+ "type": "module",
11
10
  "files": [
12
11
  "dist",
13
12
  "README.md",
14
13
  "LICENSE"
15
14
  ],
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.mjs",
17
+ "types": "./dist/index.d.cts",
16
18
  "exports": {
17
19
  ".": {
18
- "require": "./dist/index.js",
19
- "import": "./dist/index.js",
20
- "types": "./dist/index.d.ts"
20
+ "import": {
21
+ "types": "./dist/index.d.mts",
22
+ "default": "./dist/index.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./dist/index.d.cts",
26
+ "default": "./dist/index.cjs"
27
+ }
21
28
  }
22
29
  },
23
30
  "repository": {
24
31
  "type": "git",
25
- "url": "git+https://github.com/GlobalArtInc/nestjs-toolkit.git#main"
32
+ "url": "git+https://github.com/GlobalArtInc/ecosystem.git#main"
26
33
  },
27
34
  "keywords": [
28
35
  "nestjs",
@@ -34,33 +41,34 @@
34
41
  "test": "jest --runInBand --passWithNoTests",
35
42
  "test:cov": "jest --coverage --passWithNoTests",
36
43
  "coveralls": "yarn run test:cov --coverageReporters=text-lcov | coveralls",
37
- "build": "rm -rf ./dist && tsc",
38
- "build:watch": "tsc --watch",
44
+ "build": "tsdown",
45
+ "build:watch": "tsdown --watch",
39
46
  "prepublishOnly": "npm run build",
40
47
  "publish:dev": "npm publish --access public --tag dev",
41
- "publish:npm": "release-it"
48
+ "publish:npm": "release-it --config ../../.release-it.json"
42
49
  },
43
50
  "dependencies": {
44
- "@nestjs/common": "^11.1.6",
45
- "@nestjs/core": "^11.1.6",
46
- "@nestjs/swagger": "^11.2.0",
47
- "@nestjs/testing": "^11.1.6",
51
+ "@nestjs/common": "11.1.11",
52
+ "@nestjs/core": "11.1.11",
53
+ "@nestjs/swagger": "^11.2.3",
54
+ "@nestjs/testing": "11.1.11",
48
55
  "@nestjs/typeorm": "^11.0.0",
49
56
  "mysql": "^2.18.1"
50
57
  },
51
58
  "devDependencies": {
52
59
  "@types/jest": "^30.0.0",
53
- "@types/node": "^24.3.0",
60
+ "@types/node": "25.0.3",
54
61
  "coveralls": "^3.1.1",
55
- "jest": "^30.0.3",
56
- "prettier": "^3.6.2",
62
+ "jest": "^30.2.0",
63
+ "prettier": "3.7.4",
57
64
  "reflect-metadata": "^0.2.2",
58
- "release-it": "19.0.4",
65
+ "release-it": "19.2.3",
59
66
  "rxjs": "^7.8.2",
60
- "ts-jest": "^29.4.0",
67
+ "ts-jest": "29.4.6",
61
68
  "ts-node": "^10.9.2",
62
- "typeorm": "0.3.26",
63
- "typescript": "^5.9.2"
69
+ "tsdown": "0.19.0-beta.3",
70
+ "typeorm": "0.3.28",
71
+ "typescript": "^5.9.3"
64
72
  },
65
73
  "jest": {
66
74
  "coveragePathIgnorePatterns": [
@@ -1,12 +0,0 @@
1
- export declare const API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
2
- export declare const ERROR_DESCRIPTIONS: {
3
- BAD_REQUEST: string;
4
- UNAUTHORIZED: string;
5
- FORBIDDEN: string;
6
- NOT_FOUND: string;
7
- CONFLICT: string;
8
- UNPROCESSABLE_ENTITY: string;
9
- RATE_LIMIT_EXCEEDED: string;
10
- INTERNAL_SERVER_ERROR: string;
11
- SERVICE_UNAVAILABLE: string;
12
- };
package/dist/constants.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ERROR_DESCRIPTIONS = exports.API_RESPONSE_DESCRIPTION = void 0;
4
- exports.API_RESPONSE_DESCRIPTION = "If the server is available, it always responds with code 200 or 201. Error code 400 and higher will replace the ok field: it equals false and the error text in the error field. If the input data does not pass validation, the error field contains an object with invalid fields and error text";
5
- exports.ERROR_DESCRIPTIONS = {
6
- BAD_REQUEST: "Invalid request data or parameters",
7
- UNAUTHORIZED: "Authentication required",
8
- FORBIDDEN: "Access denied",
9
- NOT_FOUND: "Resource not found",
10
- CONFLICT: "Resource already exists or conflict detected",
11
- UNPROCESSABLE_ENTITY: "Validation error",
12
- RATE_LIMIT_EXCEEDED: "Rate limit exceeded. Too many requests",
13
- INTERNAL_SERVER_ERROR: "Internal server error",
14
- SERVICE_UNAVAILABLE: "Service temporarily unavailable",
15
- };
@@ -1,2 +0,0 @@
1
- import { SwaggerDocumentationOptions } from "../interfaces";
2
- export declare const SwaggerDocumentation: (data: SwaggerDocumentationOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SwaggerDocumentation = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const swagger_1 = require("@nestjs/swagger");
6
- const constants_1 = require("../constants");
7
- const dtos_1 = require("../dtos");
8
- const crypto_1 = require("crypto");
9
- // SwaggerDocumentation is a decorator function to generate Swagger documentation for endpoints based on the provided options.
10
- const SwaggerDocumentation = (data) => {
11
- const operationId = data.operationId ||
12
- (0, crypto_1.createHash)("md5").update(`${data.endpointSummary}`).digest("hex");
13
- const decorators = [
14
- (0, swagger_1.ApiOperation)({
15
- operationId,
16
- description: data.endpointDescription,
17
- summary: data.endpointSummary,
18
- }),
19
- ];
20
- if (data.error400Description) {
21
- decorators.push((0, swagger_1.ApiBadRequestResponse)({
22
- description: data.error400Description,
23
- }));
24
- }
25
- if (data.error401Description) {
26
- decorators.push((0, swagger_1.ApiUnauthorizedResponse)({
27
- description: data.error401Description,
28
- }));
29
- }
30
- if (data.error403Description) {
31
- decorators.push((0, swagger_1.ApiForbiddenResponse)({
32
- description: data.error403Description,
33
- }));
34
- }
35
- if (data.error404Description) {
36
- decorators.push((0, swagger_1.ApiNotFoundResponse)({
37
- description: data.error404Description,
38
- }));
39
- }
40
- if (data.error409Description) {
41
- decorators.push((0, swagger_1.ApiConflictResponse)({
42
- description: data.error409Description,
43
- }));
44
- }
45
- if (data.error422Description) {
46
- decorators.push((0, swagger_1.ApiUnprocessableEntityResponse)({
47
- description: data.error422Description,
48
- }));
49
- }
50
- if (data.error429Description) {
51
- decorators.push((0, swagger_1.ApiTooManyRequestsResponse)({
52
- description: data.error429Description,
53
- }));
54
- }
55
- if (data.error500Description) {
56
- decorators.push((0, swagger_1.ApiInternalServerErrorResponse)({
57
- description: data.error500Description,
58
- }));
59
- }
60
- if (data.error503Description) {
61
- decorators.push((0, swagger_1.ApiServiceUnavailableResponse)({
62
- description: data.error503Description,
63
- }));
64
- }
65
- if (data.isPaginated && data.responseDto) {
66
- decorators.push((0, swagger_1.ApiOkResponse)({
67
- schema: {
68
- allOf: [
69
- { $ref: (0, swagger_1.getSchemaPath)(dtos_1.PaginatedResponseDto) },
70
- {
71
- properties: {
72
- data: {
73
- type: "array",
74
- items: {
75
- $ref: (0, swagger_1.getSchemaPath)(data.responseDto),
76
- },
77
- },
78
- },
79
- },
80
- ],
81
- },
82
- description: constants_1.API_RESPONSE_DESCRIPTION,
83
- }), (0, swagger_1.ApiExtraModels)(data.responseDto, dtos_1.PaginatedResponseDto));
84
- }
85
- else if (data.responseDto) {
86
- decorators.push((0, swagger_1.ApiOkResponse)({
87
- schema: data.isArray
88
- ? {
89
- type: "array",
90
- items: { $ref: (0, swagger_1.getSchemaPath)(data.responseDto) },
91
- }
92
- : { $ref: (0, swagger_1.getSchemaPath)(data.responseDto) },
93
- description: constants_1.API_RESPONSE_DESCRIPTION,
94
- }), (0, swagger_1.ApiExtraModels)(data.responseDto));
95
- }
96
- else {
97
- decorators.push((0, swagger_1.ApiOkResponse)({
98
- description: constants_1.API_RESPONSE_DESCRIPTION,
99
- }));
100
- }
101
- return (0, common_1.applyDecorators)(...decorators);
102
- };
103
- exports.SwaggerDocumentation = SwaggerDocumentation;
@@ -1,6 +0,0 @@
1
- export declare class PaginatedResponseDto<T> {
2
- data: T[];
3
- totalCount: number;
4
- offset: number;
5
- limit: number;
6
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PaginatedResponseDto = void 0;
13
- const swagger_1 = require("@nestjs/swagger");
14
- class PaginatedResponseDto {
15
- data;
16
- totalCount;
17
- offset;
18
- limit;
19
- }
20
- exports.PaginatedResponseDto = PaginatedResponseDto;
21
- __decorate([
22
- (0, swagger_1.ApiProperty)(),
23
- __metadata("design:type", Number)
24
- ], PaginatedResponseDto.prototype, "totalCount", void 0);
25
- __decorate([
26
- (0, swagger_1.ApiProperty)(),
27
- __metadata("design:type", Number)
28
- ], PaginatedResponseDto.prototype, "offset", void 0);
29
- __decorate([
30
- (0, swagger_1.ApiProperty)(),
31
- __metadata("design:type", Number)
32
- ], PaginatedResponseDto.prototype, "limit", void 0);
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./constants";
2
- export * from "./decorators";
3
- export * from "./interfaces";
package/dist/index.js DELETED
@@ -1,19 +0,0 @@
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("./constants"), exports);
18
- __exportStar(require("./decorators"), exports);
19
- __exportStar(require("./interfaces"), exports);
@@ -1,19 +0,0 @@
1
- export interface SwaggerDocumentationErrorStatus {
2
- error400Description?: string;
3
- error401Description?: string;
4
- error403Description?: string;
5
- error404Description?: string;
6
- error409Description?: string;
7
- error422Description?: string;
8
- error429Description?: string;
9
- error500Description?: string;
10
- error503Description?: string;
11
- }
12
- export interface SwaggerDocumentationOptions extends SwaggerDocumentationErrorStatus {
13
- endpointSummary: string;
14
- endpointDescription?: string;
15
- operationId?: string;
16
- responseDto?: any;
17
- isArray?: boolean;
18
- isPaginated?: boolean;
19
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });