@riktajs/swagger 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +0 -45
- package/dist/constants.js +0 -50
- package/dist/decorators/api-body.decorator.d.ts +0 -29
- package/dist/decorators/api-body.decorator.js +0 -29
- package/dist/decorators/api-exclude.decorator.d.ts +0 -62
- package/dist/decorators/api-exclude.decorator.js +0 -64
- package/dist/decorators/api-header.decorator.d.ts +0 -21
- package/dist/decorators/api-header.decorator.js +0 -21
- package/dist/decorators/api-operation.decorator.d.ts +0 -28
- package/dist/decorators/api-operation.decorator.js +0 -28
- package/dist/decorators/api-param.decorator.d.ts +0 -24
- package/dist/decorators/api-param.decorator.js +0 -24
- package/dist/decorators/api-property.decorator.d.ts +0 -58
- package/dist/decorators/api-property.decorator.js +0 -56
- package/dist/decorators/api-query.decorator.d.ts +0 -26
- package/dist/decorators/api-query.decorator.js +0 -26
- package/dist/decorators/api-response.decorator.d.ts +0 -55
- package/dist/decorators/api-response.decorator.js +0 -55
- package/dist/decorators/api-security.decorator.d.ts +0 -80
- package/dist/decorators/api-security.decorator.js +0 -84
- package/dist/decorators/api-tags.decorator.d.ts +0 -28
- package/dist/decorators/api-tags.decorator.js +0 -30
- package/dist/decorators/index.d.ts +0 -6
- package/dist/decorators/index.js +0 -14
- package/dist/index.d.ts +0 -55
- package/dist/index.js +0 -62
- package/dist/openapi/generator.d.ts +0 -49
- package/dist/openapi/generator.js +2 -86
- package/dist/openapi/index.d.ts +0 -6
- package/dist/openapi/index.js +0 -9
- package/dist/openapi/zod-to-openapi.d.ts +0 -47
- package/dist/openapi/zod-to-openapi.js +1 -71
- package/dist/plugin/index.d.ts +0 -6
- package/dist/plugin/index.js +0 -6
- package/dist/plugin/swagger.plugin.d.ts +0 -119
- package/dist/plugin/swagger.plugin.js +1 -110
- package/dist/types.d.ts +0 -173
- package/dist/types.js +0 -1
- package/package.json +4 -2
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/decorators/api-body.decorator.d.ts.map +0 -1
- package/dist/decorators/api-body.decorator.js.map +0 -1
- package/dist/decorators/api-exclude.decorator.d.ts.map +0 -1
- package/dist/decorators/api-exclude.decorator.js.map +0 -1
- package/dist/decorators/api-header.decorator.d.ts.map +0 -1
- package/dist/decorators/api-header.decorator.js.map +0 -1
- package/dist/decorators/api-operation.decorator.d.ts.map +0 -1
- package/dist/decorators/api-operation.decorator.js.map +0 -1
- package/dist/decorators/api-param.decorator.d.ts.map +0 -1
- package/dist/decorators/api-param.decorator.js.map +0 -1
- package/dist/decorators/api-property.decorator.d.ts.map +0 -1
- package/dist/decorators/api-property.decorator.js.map +0 -1
- package/dist/decorators/api-query.decorator.d.ts.map +0 -1
- package/dist/decorators/api-query.decorator.js.map +0 -1
- package/dist/decorators/api-response.decorator.d.ts.map +0 -1
- package/dist/decorators/api-response.decorator.js.map +0 -1
- package/dist/decorators/api-security.decorator.d.ts.map +0 -1
- package/dist/decorators/api-security.decorator.js.map +0 -1
- package/dist/decorators/api-tags.decorator.d.ts.map +0 -1
- package/dist/decorators/api-tags.decorator.js.map +0 -1
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/decorators/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/openapi/generator.d.ts.map +0 -1
- package/dist/openapi/generator.js.map +0 -1
- package/dist/openapi/index.d.ts.map +0 -1
- package/dist/openapi/index.js.map +0 -1
- package/dist/openapi/zod-to-openapi.d.ts.map +0 -1
- package/dist/openapi/zod-to-openapi.js.map +0 -1
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js.map +0 -1
- package/dist/plugin/swagger.plugin.d.ts.map +0 -1
- package/dist/plugin/swagger.plugin.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,56 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key for storing API tags on controller classes
|
|
3
|
-
* Used by @ApiTags() decorator
|
|
4
|
-
*/
|
|
5
1
|
export declare const API_TAGS_METADATA: unique symbol;
|
|
6
|
-
/**
|
|
7
|
-
* Key for storing API operation metadata on route methods
|
|
8
|
-
* Used by @ApiOperation() decorator
|
|
9
|
-
*/
|
|
10
2
|
export declare const API_OPERATION_METADATA: unique symbol;
|
|
11
|
-
/**
|
|
12
|
-
* Key for storing API response metadata on route methods
|
|
13
|
-
* Used by @ApiResponse() decorator
|
|
14
|
-
*/
|
|
15
3
|
export declare const API_RESPONSE_METADATA: unique symbol;
|
|
16
|
-
/**
|
|
17
|
-
* Key for storing API property metadata on class properties
|
|
18
|
-
* Used by @ApiProperty() decorator
|
|
19
|
-
*/
|
|
20
4
|
export declare const API_PROPERTY_METADATA: unique symbol;
|
|
21
|
-
/**
|
|
22
|
-
* Key for storing API body metadata on route methods
|
|
23
|
-
* Used by @ApiBody() decorator
|
|
24
|
-
*/
|
|
25
5
|
export declare const API_BODY_METADATA: unique symbol;
|
|
26
|
-
/**
|
|
27
|
-
* Key for storing API parameter metadata on route methods
|
|
28
|
-
* Used by @ApiParam() decorator
|
|
29
|
-
*/
|
|
30
6
|
export declare const API_PARAM_METADATA: unique symbol;
|
|
31
|
-
/**
|
|
32
|
-
* Key for storing API query metadata on route methods
|
|
33
|
-
* Used by @ApiQuery() decorator
|
|
34
|
-
*/
|
|
35
7
|
export declare const API_QUERY_METADATA: unique symbol;
|
|
36
|
-
/**
|
|
37
|
-
* Key for storing API header metadata on route methods
|
|
38
|
-
* Used by @ApiHeader() decorator
|
|
39
|
-
*/
|
|
40
8
|
export declare const API_HEADER_METADATA: unique symbol;
|
|
41
|
-
/**
|
|
42
|
-
* Key for storing API security metadata on route methods or controllers
|
|
43
|
-
* Used by @ApiSecurity() and @ApiBearerAuth() decorators
|
|
44
|
-
*/
|
|
45
9
|
export declare const API_SECURITY_METADATA: unique symbol;
|
|
46
|
-
/**
|
|
47
|
-
* Key for storing API exclude metadata on route methods
|
|
48
|
-
* Used by @ApiExcludeEndpoint() decorator
|
|
49
|
-
*/
|
|
50
10
|
export declare const API_EXCLUDE_METADATA: unique symbol;
|
|
51
|
-
/**
|
|
52
|
-
* Key for storing API deprecated metadata on route methods
|
|
53
|
-
* Used when operation is marked as deprecated
|
|
54
|
-
*/
|
|
55
11
|
export declare const API_DEPRECATED_METADATA: unique symbol;
|
|
56
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1,61 +1,11 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Swagger Package - Metadata Keys
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// Using Symbol.for() to ensure symbols are shared across packages
|
|
5
|
-
// and different import contexts (bundlers, tests, etc.)
|
|
6
|
-
/**
|
|
7
|
-
* Key for storing API tags on controller classes
|
|
8
|
-
* Used by @ApiTags() decorator
|
|
9
|
-
*/
|
|
10
1
|
export const API_TAGS_METADATA = Symbol.for('rikta:swagger:apiTags');
|
|
11
|
-
/**
|
|
12
|
-
* Key for storing API operation metadata on route methods
|
|
13
|
-
* Used by @ApiOperation() decorator
|
|
14
|
-
*/
|
|
15
2
|
export const API_OPERATION_METADATA = Symbol.for('rikta:swagger:apiOperation');
|
|
16
|
-
/**
|
|
17
|
-
* Key for storing API response metadata on route methods
|
|
18
|
-
* Used by @ApiResponse() decorator
|
|
19
|
-
*/
|
|
20
3
|
export const API_RESPONSE_METADATA = Symbol.for('rikta:swagger:apiResponse');
|
|
21
|
-
/**
|
|
22
|
-
* Key for storing API property metadata on class properties
|
|
23
|
-
* Used by @ApiProperty() decorator
|
|
24
|
-
*/
|
|
25
4
|
export const API_PROPERTY_METADATA = Symbol.for('rikta:swagger:apiProperty');
|
|
26
|
-
/**
|
|
27
|
-
* Key for storing API body metadata on route methods
|
|
28
|
-
* Used by @ApiBody() decorator
|
|
29
|
-
*/
|
|
30
5
|
export const API_BODY_METADATA = Symbol.for('rikta:swagger:apiBody');
|
|
31
|
-
/**
|
|
32
|
-
* Key for storing API parameter metadata on route methods
|
|
33
|
-
* Used by @ApiParam() decorator
|
|
34
|
-
*/
|
|
35
6
|
export const API_PARAM_METADATA = Symbol.for('rikta:swagger:apiParam');
|
|
36
|
-
/**
|
|
37
|
-
* Key for storing API query metadata on route methods
|
|
38
|
-
* Used by @ApiQuery() decorator
|
|
39
|
-
*/
|
|
40
7
|
export const API_QUERY_METADATA = Symbol.for('rikta:swagger:apiQuery');
|
|
41
|
-
/**
|
|
42
|
-
* Key for storing API header metadata on route methods
|
|
43
|
-
* Used by @ApiHeader() decorator
|
|
44
|
-
*/
|
|
45
8
|
export const API_HEADER_METADATA = Symbol.for('rikta:swagger:apiHeader');
|
|
46
|
-
/**
|
|
47
|
-
* Key for storing API security metadata on route methods or controllers
|
|
48
|
-
* Used by @ApiSecurity() and @ApiBearerAuth() decorators
|
|
49
|
-
*/
|
|
50
9
|
export const API_SECURITY_METADATA = Symbol.for('rikta:swagger:apiSecurity');
|
|
51
|
-
/**
|
|
52
|
-
* Key for storing API exclude metadata on route methods
|
|
53
|
-
* Used by @ApiExcludeEndpoint() decorator
|
|
54
|
-
*/
|
|
55
10
|
export const API_EXCLUDE_METADATA = Symbol.for('rikta:swagger:apiExclude');
|
|
56
|
-
/**
|
|
57
|
-
* Key for storing API deprecated metadata on route methods
|
|
58
|
-
* Used when operation is marked as deprecated
|
|
59
|
-
*/
|
|
60
11
|
export const API_DEPRECATED_METADATA = Symbol.for('rikta:swagger:apiDeprecated');
|
|
61
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1,33 +1,4 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import type { ApiBodyOptions } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiBody() decorator
|
|
5
|
-
*
|
|
6
|
-
* Documents the request body for an API operation.
|
|
7
|
-
* Supports both Zod schemas and OpenAPI schema objects.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Body options including schema, description, and examples
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const CreateUserSchema = z.object({
|
|
14
|
-
* name: z.string().min(2),
|
|
15
|
-
* email: z.string().email(),
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* @Post('/')
|
|
19
|
-
* @ApiBody({
|
|
20
|
-
* description: 'User creation data',
|
|
21
|
-
* schema: CreateUserSchema,
|
|
22
|
-
* required: true,
|
|
23
|
-
* })
|
|
24
|
-
* createUser(@Body() data: z.infer<typeof CreateUserSchema>) { }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
3
|
export declare function ApiBody(options: ApiBodyOptions): MethodDecorator;
|
|
28
|
-
/**
|
|
29
|
-
* Get body metadata from a method
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
4
|
export declare function getApiBody(target: Function, propertyKey: string | symbol): ApiBodyOptions | undefined;
|
|
33
|
-
//# sourceMappingURL=api-body.decorator.d.ts.map
|
|
@@ -1,40 +1,11 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { API_BODY_METADATA } from '../constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiBody() decorator
|
|
5
|
-
*
|
|
6
|
-
* Documents the request body for an API operation.
|
|
7
|
-
* Supports both Zod schemas and OpenAPI schema objects.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Body options including schema, description, and examples
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const CreateUserSchema = z.object({
|
|
14
|
-
* name: z.string().min(2),
|
|
15
|
-
* email: z.string().email(),
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* @Post('/')
|
|
19
|
-
* @ApiBody({
|
|
20
|
-
* description: 'User creation data',
|
|
21
|
-
* schema: CreateUserSchema,
|
|
22
|
-
* required: true,
|
|
23
|
-
* })
|
|
24
|
-
* createUser(@Body() data: z.infer<typeof CreateUserSchema>) { }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
3
|
export function ApiBody(options) {
|
|
28
4
|
return (target, propertyKey, descriptor) => {
|
|
29
5
|
Reflect.defineMetadata(API_BODY_METADATA, { ...options, required: options.required ?? true }, target, propertyKey);
|
|
30
6
|
return descriptor;
|
|
31
7
|
};
|
|
32
8
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Get body metadata from a method
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
9
|
export function getApiBody(target, propertyKey) {
|
|
38
10
|
return Reflect.getMetadata(API_BODY_METADATA, target.prototype, propertyKey);
|
|
39
11
|
}
|
|
40
|
-
//# sourceMappingURL=api-body.decorator.js.map
|
|
@@ -1,71 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
/**
|
|
3
|
-
* @ApiExcludeEndpoint() decorator
|
|
4
|
-
*
|
|
5
|
-
* Excludes an endpoint from the Swagger documentation.
|
|
6
|
-
* The route will still work but won't appear in the docs.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* @Controller('/users')
|
|
11
|
-
* class UserController {
|
|
12
|
-
* @Get('/')
|
|
13
|
-
* listUsers() { } // Documented
|
|
14
|
-
*
|
|
15
|
-
* @Get('/internal')
|
|
16
|
-
* @ApiExcludeEndpoint()
|
|
17
|
-
* internalEndpoint() { } // Not documented
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
2
|
export declare function ApiExcludeEndpoint(): MethodDecorator;
|
|
22
|
-
/**
|
|
23
|
-
* @ApiExcludeController() decorator
|
|
24
|
-
*
|
|
25
|
-
* Excludes an entire controller from the Swagger documentation.
|
|
26
|
-
* All routes in the controller will still work but won't appear in the docs.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* @ApiExcludeController()
|
|
31
|
-
* @Controller('/internal')
|
|
32
|
-
* class InternalController {
|
|
33
|
-
* @Get('/health')
|
|
34
|
-
* health() { } // Not documented
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
3
|
export declare function ApiExcludeController(): ClassDecorator;
|
|
39
|
-
/**
|
|
40
|
-
* Check if an endpoint is excluded from documentation
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
4
|
export declare function isApiExcluded(target: Function, propertyKey?: string | symbol): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* @ApiDeprecated() decorator
|
|
46
|
-
*
|
|
47
|
-
* Marks an endpoint as deprecated in the documentation.
|
|
48
|
-
* The endpoint will be styled differently in Swagger UI.
|
|
49
|
-
*
|
|
50
|
-
* @param message - Optional deprecation message
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* @Controller('/users')
|
|
55
|
-
* class UserController {
|
|
56
|
-
* @Get('/v1')
|
|
57
|
-
* @ApiDeprecated('Use /v2 instead')
|
|
58
|
-
* legacyEndpoint() { }
|
|
59
|
-
* }
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
5
|
export declare function ApiDeprecated(message?: string): MethodDecorator;
|
|
63
|
-
/**
|
|
64
|
-
* Check if an endpoint is deprecated
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
6
|
export declare function getApiDeprecated(target: Function, propertyKey: string | symbol): {
|
|
68
7
|
deprecated: boolean;
|
|
69
8
|
message?: string;
|
|
70
9
|
} | undefined;
|
|
71
|
-
//# sourceMappingURL=api-exclude.decorator.d.ts.map
|
|
@@ -1,95 +1,31 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { API_EXCLUDE_METADATA, API_DEPRECATED_METADATA } from '../constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiExcludeEndpoint() decorator
|
|
5
|
-
*
|
|
6
|
-
* Excludes an endpoint from the Swagger documentation.
|
|
7
|
-
* The route will still work but won't appear in the docs.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* @Controller('/users')
|
|
12
|
-
* class UserController {
|
|
13
|
-
* @Get('/')
|
|
14
|
-
* listUsers() { } // Documented
|
|
15
|
-
*
|
|
16
|
-
* @Get('/internal')
|
|
17
|
-
* @ApiExcludeEndpoint()
|
|
18
|
-
* internalEndpoint() { } // Not documented
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
3
|
export function ApiExcludeEndpoint() {
|
|
23
4
|
return (target, propertyKey, descriptor) => {
|
|
24
5
|
Reflect.defineMetadata(API_EXCLUDE_METADATA, true, target, propertyKey);
|
|
25
6
|
return descriptor;
|
|
26
7
|
};
|
|
27
8
|
}
|
|
28
|
-
/**
|
|
29
|
-
* @ApiExcludeController() decorator
|
|
30
|
-
*
|
|
31
|
-
* Excludes an entire controller from the Swagger documentation.
|
|
32
|
-
* All routes in the controller will still work but won't appear in the docs.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* @ApiExcludeController()
|
|
37
|
-
* @Controller('/internal')
|
|
38
|
-
* class InternalController {
|
|
39
|
-
* @Get('/health')
|
|
40
|
-
* health() { } // Not documented
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
9
|
export function ApiExcludeController() {
|
|
45
10
|
return (target) => {
|
|
46
11
|
Reflect.defineMetadata(API_EXCLUDE_METADATA, true, target);
|
|
47
12
|
};
|
|
48
13
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Check if an endpoint is excluded from documentation
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
14
|
export function isApiExcluded(target, propertyKey) {
|
|
54
|
-
// Check class-level exclusion
|
|
55
15
|
if (Reflect.getMetadata(API_EXCLUDE_METADATA, target) === true) {
|
|
56
16
|
return true;
|
|
57
17
|
}
|
|
58
|
-
// Check method-level exclusion
|
|
59
18
|
if (propertyKey !== undefined) {
|
|
60
19
|
return Reflect.getMetadata(API_EXCLUDE_METADATA, target.prototype, propertyKey) === true;
|
|
61
20
|
}
|
|
62
21
|
return false;
|
|
63
22
|
}
|
|
64
|
-
/**
|
|
65
|
-
* @ApiDeprecated() decorator
|
|
66
|
-
*
|
|
67
|
-
* Marks an endpoint as deprecated in the documentation.
|
|
68
|
-
* The endpoint will be styled differently in Swagger UI.
|
|
69
|
-
*
|
|
70
|
-
* @param message - Optional deprecation message
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* @Controller('/users')
|
|
75
|
-
* class UserController {
|
|
76
|
-
* @Get('/v1')
|
|
77
|
-
* @ApiDeprecated('Use /v2 instead')
|
|
78
|
-
* legacyEndpoint() { }
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
23
|
export function ApiDeprecated(message) {
|
|
83
24
|
return (target, propertyKey, descriptor) => {
|
|
84
25
|
Reflect.defineMetadata(API_DEPRECATED_METADATA, { deprecated: true, message }, target, propertyKey);
|
|
85
26
|
return descriptor;
|
|
86
27
|
};
|
|
87
28
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Check if an endpoint is deprecated
|
|
90
|
-
* @internal
|
|
91
|
-
*/
|
|
92
29
|
export function getApiDeprecated(target, propertyKey) {
|
|
93
30
|
return Reflect.getMetadata(API_DEPRECATED_METADATA, target.prototype, propertyKey);
|
|
94
31
|
}
|
|
95
|
-
//# sourceMappingURL=api-exclude.decorator.js.map
|
|
@@ -1,25 +1,4 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import type { ApiHeaderOptions } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiHeader() decorator
|
|
5
|
-
*
|
|
6
|
-
* Documents a header parameter for an API operation.
|
|
7
|
-
* Multiple @ApiHeader decorators can be applied for routes with multiple headers.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Header options including name, description, and required flag
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Get('/')
|
|
14
|
-
* @ApiHeader({ name: 'X-Request-ID', description: 'Unique request identifier', required: true })
|
|
15
|
-
* @ApiHeader({ name: 'X-Correlation-ID', description: 'Correlation ID for tracing' })
|
|
16
|
-
* listUsers() { }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
3
|
export declare function ApiHeader(options: ApiHeaderOptions): MethodDecorator;
|
|
20
|
-
/**
|
|
21
|
-
* Get all header parameter metadata from a method
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
4
|
export declare function getApiHeaders(target: Function, propertyKey: string | symbol): ApiHeaderOptions[];
|
|
25
|
-
//# sourceMappingURL=api-header.decorator.d.ts.map
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { API_HEADER_METADATA } from '../constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiHeader() decorator
|
|
5
|
-
*
|
|
6
|
-
* Documents a header parameter for an API operation.
|
|
7
|
-
* Multiple @ApiHeader decorators can be applied for routes with multiple headers.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Header options including name, description, and required flag
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Get('/')
|
|
14
|
-
* @ApiHeader({ name: 'X-Request-ID', description: 'Unique request identifier', required: true })
|
|
15
|
-
* @ApiHeader({ name: 'X-Correlation-ID', description: 'Correlation ID for tracing' })
|
|
16
|
-
* listUsers() { }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
3
|
export function ApiHeader(options) {
|
|
20
4
|
return (target, propertyKey, descriptor) => {
|
|
21
5
|
const existingHeaders = Reflect.getMetadata(API_HEADER_METADATA, target, propertyKey) ?? [];
|
|
@@ -23,11 +7,6 @@ export function ApiHeader(options) {
|
|
|
23
7
|
return descriptor;
|
|
24
8
|
};
|
|
25
9
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Get all header parameter metadata from a method
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
10
|
export function getApiHeaders(target, propertyKey) {
|
|
31
11
|
return Reflect.getMetadata(API_HEADER_METADATA, target.prototype, propertyKey) ?? [];
|
|
32
12
|
}
|
|
33
|
-
//# sourceMappingURL=api-header.decorator.js.map
|
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import type { ApiOperationOptions } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiOperation() decorator
|
|
5
|
-
*
|
|
6
|
-
* Describes a single API operation (endpoint) with summary, description,
|
|
7
|
-
* and other OpenAPI operation metadata.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Operation options
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Controller('/users')
|
|
14
|
-
* class UserController {
|
|
15
|
-
* @Get('/:id')
|
|
16
|
-
* @ApiOperation({
|
|
17
|
-
* summary: 'Get user by ID',
|
|
18
|
-
* description: 'Retrieves a single user by their unique identifier',
|
|
19
|
-
* operationId: 'getUserById',
|
|
20
|
-
* deprecated: false,
|
|
21
|
-
* })
|
|
22
|
-
* getUser(@Param('id') id: string) { }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
3
|
export declare function ApiOperation(options: ApiOperationOptions): MethodDecorator;
|
|
27
|
-
/**
|
|
28
|
-
* Get operation metadata from a method
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
4
|
export declare function getApiOperation(target: Function, propertyKey: string | symbol): ApiOperationOptions | undefined;
|
|
32
|
-
//# sourceMappingURL=api-operation.decorator.d.ts.map
|
|
@@ -1,39 +1,11 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { API_OPERATION_METADATA } from '../constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiOperation() decorator
|
|
5
|
-
*
|
|
6
|
-
* Describes a single API operation (endpoint) with summary, description,
|
|
7
|
-
* and other OpenAPI operation metadata.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Operation options
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Controller('/users')
|
|
14
|
-
* class UserController {
|
|
15
|
-
* @Get('/:id')
|
|
16
|
-
* @ApiOperation({
|
|
17
|
-
* summary: 'Get user by ID',
|
|
18
|
-
* description: 'Retrieves a single user by their unique identifier',
|
|
19
|
-
* operationId: 'getUserById',
|
|
20
|
-
* deprecated: false,
|
|
21
|
-
* })
|
|
22
|
-
* getUser(@Param('id') id: string) { }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
3
|
export function ApiOperation(options) {
|
|
27
4
|
return (target, propertyKey, descriptor) => {
|
|
28
5
|
Reflect.defineMetadata(API_OPERATION_METADATA, options, target, propertyKey);
|
|
29
6
|
return descriptor;
|
|
30
7
|
};
|
|
31
8
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Get operation metadata from a method
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
9
|
export function getApiOperation(target, propertyKey) {
|
|
37
10
|
return Reflect.getMetadata(API_OPERATION_METADATA, target.prototype, propertyKey);
|
|
38
11
|
}
|
|
39
|
-
//# sourceMappingURL=api-operation.decorator.js.map
|
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import type { ApiParamOptions } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiParam() decorator
|
|
5
|
-
*
|
|
6
|
-
* Documents a path parameter for an API operation.
|
|
7
|
-
* Multiple @ApiParam decorators can be applied for routes with multiple parameters.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Parameter options including name, description, and type
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Get('/:userId/posts/:postId')
|
|
14
|
-
* @ApiParam({ name: 'userId', description: 'User ID', type: 'string', format: 'uuid' })
|
|
15
|
-
* @ApiParam({ name: 'postId', description: 'Post ID', type: 'integer' })
|
|
16
|
-
* getUserPost(
|
|
17
|
-
* @Param('userId') userId: string,
|
|
18
|
-
* @Param('postId') postId: number
|
|
19
|
-
* ) { }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
3
|
export declare function ApiParam(options: ApiParamOptions): MethodDecorator;
|
|
23
|
-
/**
|
|
24
|
-
* Get all path parameter metadata from a method
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
4
|
export declare function getApiParams(target: Function, propertyKey: string | symbol): ApiParamOptions[];
|
|
28
|
-
//# sourceMappingURL=api-param.decorator.d.ts.map
|
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { API_PARAM_METADATA } from '../constants.js';
|
|
3
|
-
/**
|
|
4
|
-
* @ApiParam() decorator
|
|
5
|
-
*
|
|
6
|
-
* Documents a path parameter for an API operation.
|
|
7
|
-
* Multiple @ApiParam decorators can be applied for routes with multiple parameters.
|
|
8
|
-
*
|
|
9
|
-
* @param options - Parameter options including name, description, and type
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Get('/:userId/posts/:postId')
|
|
14
|
-
* @ApiParam({ name: 'userId', description: 'User ID', type: 'string', format: 'uuid' })
|
|
15
|
-
* @ApiParam({ name: 'postId', description: 'Post ID', type: 'integer' })
|
|
16
|
-
* getUserPost(
|
|
17
|
-
* @Param('userId') userId: string,
|
|
18
|
-
* @Param('postId') postId: number
|
|
19
|
-
* ) { }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
3
|
export function ApiParam(options) {
|
|
23
4
|
return (target, propertyKey, descriptor) => {
|
|
24
5
|
const existingParams = Reflect.getMetadata(API_PARAM_METADATA, target, propertyKey) ?? [];
|
|
@@ -26,11 +7,6 @@ export function ApiParam(options) {
|
|
|
26
7
|
return descriptor;
|
|
27
8
|
};
|
|
28
9
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Get all path parameter metadata from a method
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
10
|
export function getApiParams(target, propertyKey) {
|
|
34
11
|
return Reflect.getMetadata(API_PARAM_METADATA, target.prototype, propertyKey) ?? [];
|
|
35
12
|
}
|
|
36
|
-
//# sourceMappingURL=api-param.decorator.js.map
|
|
@@ -1,69 +1,11 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import type { ApiPropertyOptions } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Stored property metadata structure
|
|
5
|
-
*/
|
|
6
3
|
interface StoredPropertyMetadata {
|
|
7
4
|
propertyKey: string | symbol;
|
|
8
5
|
options: ApiPropertyOptions;
|
|
9
6
|
}
|
|
10
|
-
/**
|
|
11
|
-
* @ApiProperty() decorator
|
|
12
|
-
*
|
|
13
|
-
* Documents a property of a DTO class for schema generation.
|
|
14
|
-
* Used when you want to manually define schema properties instead of using Zod.
|
|
15
|
-
*
|
|
16
|
-
* @param options - Property options including type, description, and validation rules
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* class CreateUserDto {
|
|
21
|
-
* @ApiProperty({
|
|
22
|
-
* description: 'User email address',
|
|
23
|
-
* type: 'string',
|
|
24
|
-
* format: 'email',
|
|
25
|
-
* example: 'user@example.com',
|
|
26
|
-
* required: true,
|
|
27
|
-
* })
|
|
28
|
-
* email!: string;
|
|
29
|
-
*
|
|
30
|
-
* @ApiProperty({
|
|
31
|
-
* description: 'User age',
|
|
32
|
-
* type: 'integer',
|
|
33
|
-
* minimum: 0,
|
|
34
|
-
* maximum: 150,
|
|
35
|
-
* required: false,
|
|
36
|
-
* })
|
|
37
|
-
* age?: number;
|
|
38
|
-
*
|
|
39
|
-
* @ApiProperty({
|
|
40
|
-
* description: 'User role',
|
|
41
|
-
* enum: ['admin', 'user', 'guest'],
|
|
42
|
-
* default: 'user',
|
|
43
|
-
* })
|
|
44
|
-
* role!: string;
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
7
|
export declare function ApiProperty(options?: ApiPropertyOptions): PropertyDecorator;
|
|
49
|
-
/**
|
|
50
|
-
* @ApiPropertyOptional() decorator
|
|
51
|
-
*
|
|
52
|
-
* Shorthand for @ApiProperty({ required: false }).
|
|
53
|
-
* Marks a property as optional in the schema.
|
|
54
|
-
*/
|
|
55
8
|
export declare function ApiPropertyOptional(options?: Omit<ApiPropertyOptions, 'required'>): PropertyDecorator;
|
|
56
|
-
/**
|
|
57
|
-
* @ApiHideProperty() decorator
|
|
58
|
-
*
|
|
59
|
-
* Excludes a property from the generated schema.
|
|
60
|
-
* Useful for internal properties that shouldn't be documented.
|
|
61
|
-
*/
|
|
62
9
|
export declare function ApiHideProperty(): PropertyDecorator;
|
|
63
|
-
/**
|
|
64
|
-
* Get all property metadata from a class
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
10
|
export declare function getApiProperties(target: Function): StoredPropertyMetadata[];
|
|
68
11
|
export {};
|
|
69
|
-
//# sourceMappingURL=api-property.decorator.d.ts.map
|