@tsed/schema 6.95.6 → 6.95.10

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.
Files changed (147) hide show
  1. package/lib/cjs/domain/JsonSchema.js +17 -4
  2. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  3. package/lib/esm/domain/JsonSchema.js +17 -4
  4. package/lib/esm/domain/JsonSchema.js.map +1 -1
  5. package/package.json +5 -5
  6. package/lib/cjs/components/anyMapper.d.ts +0 -2
  7. package/lib/cjs/components/classMapper.d.ts +0 -3
  8. package/lib/cjs/components/genericsMapper.d.ts +0 -5
  9. package/lib/cjs/components/index.d.ts +0 -11
  10. package/lib/cjs/components/inheritedClassMapper.d.ts +0 -5
  11. package/lib/cjs/components/itemMapper.d.ts +0 -2
  12. package/lib/cjs/components/lazyRefMapper.d.ts +0 -3
  13. package/lib/cjs/components/mapMapper.d.ts +0 -9
  14. package/lib/cjs/components/objectMapper.d.ts +0 -8
  15. package/lib/cjs/components/ofMapper.d.ts +0 -3
  16. package/lib/cjs/components/propertiesMapper.d.ts +0 -3
  17. package/lib/cjs/components/schemaMapper.d.ts +0 -3
  18. package/lib/cjs/constants/httpMethods.d.ts +0 -12
  19. package/lib/cjs/constants/httpStatusMessages.d.ts +0 -272
  20. package/lib/cjs/decorators/class/children.d.ts +0 -11
  21. package/lib/cjs/decorators/collections/collectionContains.d.ts +0 -21
  22. package/lib/cjs/decorators/collections/collectionOf.d.ts +0 -101
  23. package/lib/cjs/decorators/collections/maxItems.d.ts +0 -47
  24. package/lib/cjs/decorators/collections/maxProperties.d.ts +0 -70
  25. package/lib/cjs/decorators/collections/minItems.d.ts +0 -51
  26. package/lib/cjs/decorators/collections/minProperties.d.ts +0 -69
  27. package/lib/cjs/decorators/collections/uniqueItems.d.ts +0 -50
  28. package/lib/cjs/decorators/common/additionalProperties.d.ts +0 -11
  29. package/lib/cjs/decorators/common/allOf.d.ts +0 -13
  30. package/lib/cjs/decorators/common/allow.d.ts +0 -28
  31. package/lib/cjs/decorators/common/any.d.ts +0 -38
  32. package/lib/cjs/decorators/common/anyOf.d.ts +0 -17
  33. package/lib/cjs/decorators/common/const.d.ts +0 -61
  34. package/lib/cjs/decorators/common/customKey.d.ts +0 -26
  35. package/lib/cjs/decorators/common/default.d.ts +0 -41
  36. package/lib/cjs/decorators/common/description.d.ts +0 -53
  37. package/lib/cjs/decorators/common/enum.d.ts +0 -98
  38. package/lib/cjs/decorators/common/example.d.ts +0 -11
  39. package/lib/cjs/decorators/common/examples.d.ts +0 -12
  40. package/lib/cjs/decorators/common/exclusiveMaximum.d.ts +0 -69
  41. package/lib/cjs/decorators/common/exclusiveMinimum.d.ts +0 -69
  42. package/lib/cjs/decorators/common/format.d.ts +0 -459
  43. package/lib/cjs/decorators/common/forwardGroups.d.ts +0 -10
  44. package/lib/cjs/decorators/common/groups.d.ts +0 -11
  45. package/lib/cjs/decorators/common/hidden.d.ts +0 -32
  46. package/lib/cjs/decorators/common/ignore.d.ts +0 -58
  47. package/lib/cjs/decorators/common/integer.d.ts +0 -61
  48. package/lib/cjs/decorators/common/jsonEntityFn.d.ts +0 -21
  49. package/lib/cjs/decorators/common/maxLength.d.ts +0 -76
  50. package/lib/cjs/decorators/common/maximum.d.ts +0 -138
  51. package/lib/cjs/decorators/common/minLength.d.ts +0 -77
  52. package/lib/cjs/decorators/common/minimum.d.ts +0 -136
  53. package/lib/cjs/decorators/common/multipleOf.d.ts +0 -68
  54. package/lib/cjs/decorators/common/name.d.ts +0 -32
  55. package/lib/cjs/decorators/common/nullable.d.ts +0 -25
  56. package/lib/cjs/decorators/common/oneOf.d.ts +0 -17
  57. package/lib/cjs/decorators/common/optional.d.ts +0 -10
  58. package/lib/cjs/decorators/common/pattern.d.ts +0 -93
  59. package/lib/cjs/decorators/common/property.d.ts +0 -11
  60. package/lib/cjs/decorators/common/readOnly.d.ts +0 -11
  61. package/lib/cjs/decorators/common/required.d.ts +0 -44
  62. package/lib/cjs/decorators/common/requiredGroups.d.ts +0 -10
  63. package/lib/cjs/decorators/common/schema.d.ts +0 -53
  64. package/lib/cjs/decorators/common/title.d.ts +0 -39
  65. package/lib/cjs/decorators/common/writeOnly.d.ts +0 -11
  66. package/lib/cjs/decorators/config/jsonEntityComponent.d.ts +0 -10
  67. package/lib/cjs/decorators/generics/genericOf.d.ts +0 -76
  68. package/lib/cjs/decorators/generics/generics.d.ts +0 -14
  69. package/lib/cjs/decorators/index.d.ts +0 -68
  70. package/lib/cjs/decorators/operations/consumes.d.ts +0 -19
  71. package/lib/cjs/decorators/operations/contentType.d.ts +0 -20
  72. package/lib/cjs/decorators/operations/deprecated.d.ts +0 -23
  73. package/lib/cjs/decorators/operations/header.d.ts +0 -49
  74. package/lib/cjs/decorators/operations/in.d.ts +0 -64
  75. package/lib/cjs/decorators/operations/inFile.d.ts +0 -25
  76. package/lib/cjs/decorators/operations/location.d.ts +0 -22
  77. package/lib/cjs/decorators/operations/operationId.d.ts +0 -10
  78. package/lib/cjs/decorators/operations/operationPath.d.ts +0 -21
  79. package/lib/cjs/decorators/operations/partial.d.ts +0 -10
  80. package/lib/cjs/decorators/operations/path.d.ts +0 -15
  81. package/lib/cjs/decorators/operations/produces.d.ts +0 -26
  82. package/lib/cjs/decorators/operations/redirect.d.ts +0 -52
  83. package/lib/cjs/decorators/operations/returns.d.ts +0 -253
  84. package/lib/cjs/decorators/operations/route.d.ts +0 -188
  85. package/lib/cjs/decorators/operations/security.d.ts +0 -23
  86. package/lib/cjs/decorators/operations/status.d.ts +0 -127
  87. package/lib/cjs/decorators/operations/summary.d.ts +0 -20
  88. package/lib/cjs/decorators/operations/tags.d.ts +0 -23
  89. package/lib/cjs/domain/DecoratorContext.d.ts +0 -28
  90. package/lib/cjs/domain/JsonAliasMap.d.ts +0 -12
  91. package/lib/cjs/domain/JsonClassStore.d.ts +0 -12
  92. package/lib/cjs/domain/JsonEntityStore.d.ts +0 -135
  93. package/lib/cjs/domain/JsonFormatTypes.d.ts +0 -17
  94. package/lib/cjs/domain/JsonLazyRef.d.ts +0 -11
  95. package/lib/cjs/domain/JsonMap.d.ts +0 -7
  96. package/lib/cjs/domain/JsonMethodStore.d.ts +0 -40
  97. package/lib/cjs/domain/JsonOperation.d.ts +0 -51
  98. package/lib/cjs/domain/JsonOperationPathsMap.d.ts +0 -7
  99. package/lib/cjs/domain/JsonOperationRoute.d.ts +0 -24
  100. package/lib/cjs/domain/JsonParameter.d.ts +0 -22
  101. package/lib/cjs/domain/JsonParameterStore.d.ts +0 -30
  102. package/lib/cjs/domain/JsonParameterTypes.d.ts +0 -16
  103. package/lib/cjs/domain/JsonPropertyStore.d.ts +0 -23
  104. package/lib/cjs/domain/JsonRequestBody.d.ts +0 -11
  105. package/lib/cjs/domain/JsonResponse.d.ts +0 -22
  106. package/lib/cjs/domain/JsonSchema.d.ts +0 -337
  107. package/lib/cjs/domain/SpecTypes.d.ts +0 -5
  108. package/lib/cjs/domain/index.d.ts +0 -16
  109. package/lib/cjs/hooks/alterIgnore.d.ts +0 -9
  110. package/lib/cjs/hooks/alterOneOf.d.ts +0 -3
  111. package/lib/cjs/hooks/alterRequiredGroups.d.ts +0 -6
  112. package/lib/cjs/index.d.ts +0 -20
  113. package/lib/cjs/interfaces/IgnoreCallback.d.ts +0 -4
  114. package/lib/cjs/interfaces/JsonHookContext.d.ts +0 -17
  115. package/lib/cjs/interfaces/JsonOpenSpec.d.ts +0 -9
  116. package/lib/cjs/interfaces/JsonSchemaOptions.d.ts +0 -26
  117. package/lib/cjs/interfaces/index.d.ts +0 -4
  118. package/lib/cjs/registries/JsonSchemaMapperContainer.d.ts +0 -19
  119. package/lib/cjs/utils/buildPath.d.ts +0 -6
  120. package/lib/cjs/utils/concatParameters.d.ts +0 -4
  121. package/lib/cjs/utils/concatPath.d.ts +0 -1
  122. package/lib/cjs/utils/defineStatusModel.d.ts +0 -3
  123. package/lib/cjs/utils/from.d.ts +0 -189
  124. package/lib/cjs/utils/generics.d.ts +0 -50
  125. package/lib/cjs/utils/getComputedType.d.ts +0 -5
  126. package/lib/cjs/utils/getInheritedStores.d.ts +0 -8
  127. package/lib/cjs/utils/getJsonEntityStore.d.ts +0 -15
  128. package/lib/cjs/utils/getJsonPathParameters.d.ts +0 -7
  129. package/lib/cjs/utils/getJsonSchema.d.ts +0 -4
  130. package/lib/cjs/utils/getJsonType.d.ts +0 -5
  131. package/lib/cjs/utils/getOperationsRoutes.d.ts +0 -8
  132. package/lib/cjs/utils/getOperationsStores.d.ts +0 -6
  133. package/lib/cjs/utils/getPropertiesStores.d.ts +0 -20
  134. package/lib/cjs/utils/getRequiredProperties.d.ts +0 -6
  135. package/lib/cjs/utils/getSpec.d.ts +0 -49
  136. package/lib/cjs/utils/isJsonClass.d.ts +0 -4
  137. package/lib/cjs/utils/isSuccessStatus.d.ts +0 -2
  138. package/lib/cjs/utils/mapHeaders.d.ts +0 -9
  139. package/lib/cjs/utils/mapNullableType.d.ts +0 -3
  140. package/lib/cjs/utils/mapRouteOptions.d.ts +0 -5
  141. package/lib/cjs/utils/matchGroups.d.ts +0 -4
  142. package/lib/cjs/utils/mergeOperation.d.ts +0 -17
  143. package/lib/cjs/utils/mergeSpec.d.ts +0 -23
  144. package/lib/cjs/utils/operationIdFormatter.d.ts +0 -4
  145. package/lib/cjs/utils/ref.d.ts +0 -14
  146. package/lib/cjs/utils/toJsonMapCollection.d.ts +0 -7
  147. package/lib/cjs/utils/toJsonRegex.d.ts +0 -5
@@ -1,52 +0,0 @@
1
- import { JsonHeader } from "../../interfaces/JsonOpenSpec";
2
- /**
3
- * Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.
4
- *
5
- * ```typescript
6
- * @Redirect('/foo/bar')
7
- * @Redirect(301, 'http://example.com').Type(Model)
8
- * private myMethod() {}
9
- * ```
10
- * Redirects can be a fully-qualified URL for redirecting to a different site:
11
- *
12
- * ```typescript
13
- * @Redirect('http://google.com');
14
- * private myMethod() {}
15
- * ```
16
- *
17
- * Redirects can be relative to the root of the host name. For example, if the application is on http://example.com/admin/post/new, the following would redirect to the URL http://example.com/admin:
18
- *
19
- * ```typescript
20
- * @Redirect('/admin');
21
- * ```
22
- * Redirects can be relative to the current URL. For example, from http://example.com/blog/admin/ (notice the trailing slash), the following would redirect to the URL http://example.com/blog/admin/post/new.
23
- *
24
- * ```typescript
25
- * @Redirect('post/new');
26
- * ```
27
- *
28
- * Redirecting to post/new from http://example.com/blog/admin (no trailing slash), will redirect to http://example.com/blog/post/new.
29
- *
30
- * If you found the above behavior confusing, think of path segments as directories (with trailing slashes) and files, it will start to make sense.
31
- *
32
- * Path-relative redirects are also possible. If you were on http://example.com/admin/post/new, the following would redirect to http//example.com/admin/post:
33
- *
34
- * ```typescript
35
- * @Redirect('..');
36
- * ``
37
- *
38
- * A back redirection redirects the request back to the referer, defaulting to / when the referer is missing.
39
- *
40
- * ```typescript
41
- * @Redirect('back');
42
- * ```
43
- *
44
- * @param url
45
- * @param meta
46
- * @decorator
47
- * @operation
48
- * @response
49
- * @headers
50
- */
51
- export declare function Redirect(url: string, meta?: JsonHeader): Function;
52
- export declare function Redirect(status: number, url: string, meta?: JsonHeader): Function;
@@ -1,253 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { OS3Example } from "@tsed/openspec";
3
- import { JsonSchema, JsonSchemaObject } from "../../domain/JsonSchema";
4
- import { JsonHeader, JsonHeaders } from "../../interfaces/JsonOpenSpec";
5
- import { GenericValue } from "../../utils/generics";
6
- export interface ReturnsChainedDecorators {
7
- <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
8
- (target: Function): void;
9
- /**
10
- * Set a Content-Type for the current response
11
- * @param value
12
- * @constructor
13
- */
14
- ContentType(value: string): this;
15
- /**
16
- * Add a description
17
- * @param description
18
- */
19
- Description(description: string): this;
20
- /**
21
- * Add examples
22
- * @param examples
23
- */
24
- Examples(examples: Record<string, OS3Example>): this;
25
- Examples(examples: Record<string, any>): this;
26
- Examples(examples: any): this;
27
- /**
28
- * Change the model type
29
- * @param type
30
- */
31
- Type(type: Type<any> | any): this;
32
- /**
33
- * Change the status
34
- * @param status
35
- * @constructor
36
- */
37
- Status(status: string | number): this;
38
- /**
39
- * Add the nested types
40
- * @param types
41
- */
42
- Of(...types: GenericValue[]): this;
43
- /**
44
- * Add the nested types
45
- * @param types
46
- */
47
- OneOf(...types: GenericValue[]): this;
48
- /**
49
- * Add the nested types
50
- * @param types
51
- */
52
- AllOf(...types: GenericValue[]): this;
53
- /**
54
- * Add the nested types
55
- * @param types
56
- */
57
- AnyOf(...types: GenericValue[]): this;
58
- /**
59
- * Declare a nested generic models
60
- * @param generics
61
- */
62
- Nested(...generics: GenericValue[]): this;
63
- /**
64
- * Add header.
65
- * @param key
66
- * @param value
67
- */
68
- Header(key: string, value: number | string | (JsonHeader & {
69
- value?: string | number | boolean;
70
- })): this;
71
- /**
72
- * Add headers
73
- */
74
- Headers(headers: JsonHeaders): this;
75
- /**
76
- * Add location hea
77
- */
78
- Location(location: string, meta?: JsonHeader): this;
79
- /**
80
- * Assign partial schema
81
- * @param schema
82
- */
83
- Schema(schema: Partial<JsonSchemaObject> | JsonSchema): this;
84
- /**
85
- * Add an inline title for the return model.
86
- * @param title
87
- */
88
- Title(title: string): this;
89
- /**
90
- *
91
- * @param groups
92
- * @constructor
93
- */
94
- Groups(...groups: string[]): this;
95
- [key: string]: any;
96
- }
97
- /**
98
- * Add responses documentation for a specific status code.
99
- *
100
- * ## Usage
101
- *
102
- * Ts.ED v5/v6 API introducing the chaining decorator concept. Now a decorator like Returns can be used with another decorators like Description.
103
- *
104
- * ::: warning
105
- * v5 has a basic support of the chaining decorator to facilitate the migration to v6!
106
- * :::
107
- *
108
- * ```typescript
109
- * import {Returns} from "@tsed/schema";
110
- *
111
- * @Controller("/")
112
- * class MyController {
113
- * @Returns(404, String).Description("Not Found")
114
- * @Returns(200, Model).Description("Success")
115
- * async myMethod(): Promise<Model> {}
116
- * }
117
- * ```
118
- *
119
- * ::: tip
120
- * TypeScript and your IDE will discover automatically the chained decorators. But for more details you can look on @@ReturnsChainedDecorators@@ interface, to know
121
- * what chained decorators are available under Returns decorator.
122
- * :::
123
- *
124
- * This example will produce this documentation in swagger:
125
- *
126
- * ```json
127
- * {
128
- * "responses": {
129
- * "404": {
130
- * "description": "Description",
131
- * "schema": {"type": "string"}
132
- * },
133
- * "2OO": {
134
- * "description": "Description",
135
- * "schema": {"$ref": "..."}
136
- * }
137
- * }
138
- * }
139
- * ```
140
- *
141
- * ## Declaring an Array
142
- *
143
- * Use chained decorators to declare an array with model as following:
144
- *
145
- * ```typescript
146
- * import {Returns} from "@tsed/schema";
147
- *
148
- * @Controller("/models")
149
- * class ModelCtrl {
150
- * @Get("/")
151
- * @Returns(200, Array).Of(Model).Description("Success")
152
- * async myMethod(): Promise<Model> {
153
- * }
154
- * }
155
- * ```
156
- *
157
- * Deprecated version:
158
- *
159
- * ```typescript
160
- * import {ReturnsArray} from "@tsed/common";
161
- * import {Returns} from "@tsed/schema";
162
- *
163
- * @Controller("/")
164
- * class MyController {
165
- * @ReturnsArray(200, Model) // deprecated
166
- * async myMethod(): Promise<Model> {}
167
- * }
168
- * ```
169
- *
170
- * ### Declaring a generic model <Badge text="6+"/>
171
- *
172
- * Sometime, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to
173
- * declare explicitly the generic models with the decorators.
174
- *
175
- * One of the generic's usage, can be a paginated list. With Returns decorator it's now possible to declare generic type and generate the appropriate OpenSpec documentation.
176
- *
177
- * Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:
178
- *
179
- * ```typescript
180
- * @Generics("T")
181
- * class Pagination<T> {
182
- * @CollectionOf("T")
183
- * data: T[];
184
- *
185
- * @Property()
186
- * totalCount: number;
187
- * }
188
- * ```
189
- *
190
- * Now, we need a model to be used with the generic Pagination model:
191
- *
192
- * ```typescript
193
- * class Product {
194
- * @Property()
195
- * id: string;
196
- *
197
- * @Property()
198
- * title: string;
199
- * }
200
- * ```
201
- *
202
- * Finally, we can use our models on a method as following:
203
- *
204
- * ```typescript
205
- * class Controller {
206
- * @OperationPath("POST", "/")
207
- * @Returns(200, Pagination).Of(Product).Description("description")
208
- * async method(): Promise<Pagination<Product> | null> {
209
- * return null;
210
- * }
211
- * }
212
- * ```
213
- *
214
- * ### Declaring a nested generics models <Badge text="6+"/>
215
- *
216
- * It's also possible to declare a nested generics models in order to have this type `Pagination<Submission<Product>>`:
217
- *
218
- * ```typescript
219
- * import {Generics, Property, Returns} from "@tsed/schema";
220
- * import {Post} from "@tsed/common";
221
- *
222
- * class Controller {
223
- * @Post("/")
224
- * @Returns(200, Pagination).Of(Submission).Nested(Product).Description("description")
225
- * async method(): Promise<Pagination<Submission<Product>> | null> {
226
- * return null;
227
- * }
228
- * }
229
- * ```
230
- *
231
- * And here is the Submission model:
232
- *
233
- * ```typescript
234
- * import {Generics, Property} from "@tsed/schema";
235
- *
236
- * @Generics("T")
237
- * class Submission<T> {
238
- * @Property()
239
- * _id: string;
240
- * @Property("T")
241
- * data: T;
242
- * }
243
- * ```
244
- *
245
- * @param status
246
- * @param model
247
- * @decorator
248
- * @swagger
249
- * @schema
250
- * @response
251
- * @operation
252
- */
253
- export declare function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;
@@ -1,188 +0,0 @@
1
- import { OperationMethods } from "../../constants/httpMethods";
2
- export interface RouteChainedDecorators {
3
- <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
4
- /**
5
- * @param string
6
- * @constructor
7
- */
8
- Path(string: string): this;
9
- /**
10
- * Set the operation method
11
- * @param method
12
- */
13
- Method(method: OperationMethods | string): this;
14
- /**
15
- * Set the operation id
16
- * @param id
17
- */
18
- Id(id: string): this;
19
- /**
20
- * Set the operation id
21
- * @param name
22
- */
23
- Name(name: string): this;
24
- /**
25
- *
26
- * @param description
27
- */
28
- Description(description: string): this;
29
- /**
30
- * Summary
31
- * @constructor
32
- * @param Summary
33
- */
34
- Summary(Summary: string): this;
35
- Use(...args: any[]): this;
36
- UseAfter(...args: any[]): this;
37
- UseBefore(...args: any[]): this;
38
- }
39
- /**
40
- * Describe a new route with a method and path.
41
- *
42
- * ```typescript
43
- * @Controller('/')
44
- * export class Ctrl {
45
- *
46
- * @Route('GET', '/')
47
- * get() { }
48
- * }
49
- *
50
- * ```
51
- *
52
- * @returns {Function}
53
- * @param method
54
- * @param path
55
- * @param args
56
- * @decorator
57
- * @operation
58
- */
59
- export declare function Route(method: string, path: string, ...args: any[]): RouteChainedDecorators;
60
- export declare function Route(...args: any[]): RouteChainedDecorators;
61
- /**
62
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
63
- *
64
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
65
- * For example, if you placed the following route at the top of all other route definitions, it would require that
66
- * all routes from that point on would require authentication, and automatically load a user.
67
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
68
- * to continue matching subsequent routes.
69
- * @param path
70
- * @param args
71
- * @returns {Function}
72
- * @decorator
73
- * @operation
74
- * @httpMethod
75
- */
76
- export declare function All(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
77
- /**
78
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
79
- *
80
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
81
- * For example, if you placed the following route at the top of all other route definitions, it would require that
82
- * all routes from that point on would require authentication, and automatically load a user.
83
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
84
- * to continue matching subsequent routes.
85
- * @param path
86
- * @param args
87
- * @returns {Function}
88
- * @decorator
89
- * @operation
90
- * @httpMethod
91
- */
92
- export declare function Get(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
93
- /**
94
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
95
- *
96
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
97
- * For example, if you placed the following route at the top of all other route definitions, it would require that
98
- * all routes from that point on would require authentication, and automatically load a user.
99
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
100
- * to continue matching subsequent routes.
101
- * @param path
102
- * @param args
103
- * @returns {Function}
104
- * @decorator
105
- * @operation
106
- * @httpMethod
107
- */
108
- export declare function Post(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
109
- /**
110
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
111
- *
112
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
113
- * For example, if you placed the following route at the top of all other route definitions, it would require that
114
- * all routes from that point on would require authentication, and automatically load a user.
115
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
116
- * to continue matching subsequent routes.
117
- * @param path
118
- * @param args
119
- * @returns {Function}
120
- * @decorator
121
- * @operation
122
- * @httpMethod
123
- */
124
- export declare function Put(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
125
- /**
126
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
127
- *
128
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
129
- * For example, if you placed the following route at the top of all other route definitions, it would require that
130
- * all routes from that point on would require authentication, and automatically load a user.
131
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
132
- * to continue matching subsequent routes.
133
- * @param path
134
- * @param args
135
- * @returns {Function}
136
- * @decorator
137
- * @operation
138
- * @httpMethod
139
- */
140
- export declare function Delete(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
141
- /**
142
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
143
- *
144
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
145
- * For example, if you placed the following route at the top of all other route definitions, it would require that
146
- * all routes from that point on would require authentication, and automatically load a user.
147
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
148
- * to continue matching subsequent routes.
149
- * @param path
150
- * @param args
151
- * @returns {Function}
152
- * @decorator
153
- * @operation
154
- * @httpMethod
155
- */
156
- export declare function Head(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
157
- /**
158
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
159
- *
160
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
161
- * For example, if you placed the following route at the top of all other route definitions, it would require that
162
- * all routes from that point on would require authentication, and automatically load a user.
163
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
164
- * to continue matching subsequent routes.
165
- * @param path
166
- * @param args
167
- * @returns {Function}
168
- * @decorator
169
- * @operation
170
- * @httpMethod
171
- */
172
- export declare function Patch(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
173
- /**
174
- * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
175
- *
176
- * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
177
- * For example, if you placed the following route at the top of all other route definitions, it would require that
178
- * all routes from that point on would require authentication, and automatically load a user.
179
- * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
180
- * to continue matching subsequent routes.
181
- * @param path
182
- * @param args
183
- * @returns {Function}
184
- * @decorator
185
- * @operation
186
- * @httpMethod
187
- */
188
- export declare function Options(path?: string | RegExp | any, ...args: any[]): RouteChainedDecorators;
@@ -1,23 +0,0 @@
1
- /**
2
- * Add security metadata on the decorated method.
3
- *
4
- * ## Examples
5
- * ### On method
6
- *
7
- * ```typescript
8
- * @Controller("/")
9
- * class ModelCtrl {
10
- * @Security("write:calendars")
11
- * async method() {}
12
- * }
13
- * ```
14
- *
15
- * @param name
16
- * @param scopes
17
- * @decorator
18
- * @swagger
19
- * @schema
20
- * @classDecorator
21
- * @operation
22
- */
23
- export declare function Security(name: string, ...scopes: string[]): (...args: any[]) => any;
@@ -1,127 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { ReturnsChainedDecorators } from "./returns";
3
- /**
4
- * Add responses documentation for a specific status code.
5
- *
6
- * ## Usage
7
- *
8
- * Ts.ED v6 API introducing the chaining decorator concept.
9
- * Now a decorator like Returns can be used with another decorators like Description.
10
- *
11
- * ```typescript
12
- * import {Returns} from "@tsed/schema";
13
- *
14
- * @Controller("/")
15
- * class MyController {
16
- * @Status(404, String).Description("Not Found")
17
- * @Status(200, Model).Description("Success")
18
- * async myMethod(): Promise<Model> {}
19
- * }
20
- * ```
21
- *
22
- * ::: tip
23
- * TypeScript and your IDE will discover automatically the chained decorators. But for more details you can look on @@ReturnsChainedDecorators@@ interface, to know
24
- * what chained decorators are available under Returns decorator.
25
- * :::
26
- *
27
- * This example will produce this documentation in swagger:
28
- *
29
- * ```json
30
- * {
31
- * "responses": {
32
- * "404": {
33
- * "description": "Description",
34
- * "schema": {"type": "string"}
35
- * },
36
- * "2OO": {
37
- * "description": "Description",
38
- * "schema": {"$ref": "..."}
39
- * }
40
- * }
41
- * }
42
- * ```
43
- *
44
- * ### Declaring a generic model
45
- *
46
- * Sometime, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to
47
- * declare explicitly the generic models with the decorators.
48
- *
49
- * One of the generic's usage, can be a paginated list. With Returns decorator it's now possible to declare generic type and generate the appropriate OpenSpec documentation.
50
- *
51
- * Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:
52
- *
53
- * ```typescript
54
- * @Generics("T")
55
- * class Pagination<T> {
56
- * @CollectionOf("T")
57
- * data: T[];
58
- *
59
- * @Property()
60
- * totalCount: number;
61
- * }
62
- * ```
63
- *
64
- * Now, we need a model to be used with the generic Pagination model:
65
- *
66
- * ```typescript
67
- * class Product {
68
- * @Property()
69
- * id: string;
70
- *
71
- * @Property()
72
- * title: string;
73
- * }
74
- * ```
75
- *
76
- * Finally, we can use our models on a method as following:
77
- *
78
- * ```typescript
79
- * class Controller {
80
- * @OperationPath("POST", "/")
81
- * @Status(200, Pagination).Of(Product).Description("description")
82
- * async method(): Promise<Pagination<Product> | null> {
83
- * return null;
84
- * }
85
- * }
86
- * ```
87
- *
88
- * ### Declaring a nested generics models <Badge text="6+"/>
89
- *
90
- * It's also possible to declare a nested generics models in order to have this type `Pagination<Submission<Product>>`:
91
- *
92
- * ```typescript
93
- * import {Generics, Property, Returns} from "@tsed/schema";
94
- * import {Post} from "@tsed/common";
95
- *
96
- * class Controller {
97
- * @Post("/")
98
- * @Status(200, Pagination).Of(Submission).Nested(Product).Description("description")
99
- * async method(): Promise<Pagination<Submission<Product>> | null> {
100
- * return null;
101
- * }
102
- * }
103
- * ```
104
- *
105
- * And here is the Submission model:
106
- *
107
- * ```typescript
108
- * import {Generics, Property} from "@tsed/schema";
109
- *
110
- * @Generics("T")
111
- * class Submission<T> {
112
- * @Property()
113
- * _id: string;
114
- * @Property("T")
115
- * data: T;
116
- * }
117
- * ```
118
- *
119
- * @param status
120
- * @param model
121
- * @decorator
122
- * @swagger
123
- * @schema
124
- * @response
125
- * @operation
126
- */
127
- export declare function Status(status: string | number, model?: Type<any> | any): ReturnsChainedDecorators;
@@ -1,20 +0,0 @@
1
- /**
2
- * Add summary metadata on the decorated element.
3
- *
4
- * ## Examples
5
- * ### On method
6
- *
7
- * ```typescript
8
- * class Model {
9
- * @Summary("summary")
10
- * id: string;
11
- * }
12
- * ```
13
- *
14
- * @param summary
15
- * @decorator
16
- * @swagger
17
- * @schema
18
- * @operation
19
- */
20
- export declare function Summary(summary: string): (...args: any[]) => any;
@@ -1,23 +0,0 @@
1
- import { OpenSpecTag } from "@tsed/openspec";
2
- /**
3
- * Add tags metadata on the decorated element.
4
- *
5
- * ## Examples
6
- * ### On method
7
- *
8
- * ```typescript
9
- * @Controller("/")
10
- * class MyController {
11
- * @Tags("api")
12
- * get() {}
13
- * }
14
- * ```
15
- *
16
- * @param tags
17
- * @decorator
18
- * @swagger
19
- * @schema
20
- * @classDecorator
21
- * @operation
22
- */
23
- export declare function Tags(...tags: (string | OpenSpecTag)[]): (...args: any[]) => any;