@tsed/schema 7.79.3 → 7.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/schema.umd.min.js.map +1 -1
- package/lib/cjs/components/default/inlineEnumsMapper.js +2 -2
- package/lib/cjs/components/default/inlineEnumsMapper.js.map +1 -1
- package/lib/cjs/components/default/nullableMapper.js +4 -4
- package/lib/cjs/components/default/nullableMapper.js.map +1 -1
- package/lib/cjs/components/default/requiredMapper.js +4 -4
- package/lib/cjs/components/default/requiredMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/nullableMapper.js +4 -4
- package/lib/cjs/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/cjs/utils/generateSpec.js +1 -24
- package/lib/cjs/utils/generateSpec.js.map +1 -1
- package/lib/esm/components/default/inlineEnumsMapper.js.map +1 -1
- package/lib/esm/components/default/nullableMapper.js.map +1 -1
- package/lib/esm/components/default/requiredMapper.js.map +1 -1
- package/lib/esm/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/esm/utils/getJsonSchema.js +1 -1
- package/lib/types/components/default/inlineEnumsMapper.d.ts +2 -2
- package/lib/types/components/default/nullableMapper.d.ts +1 -1
- package/lib/types/components/default/requiredMapper.d.ts +2 -2
- package/lib/types/components/open-spec/nullableMapper.d.ts +1 -1
- package/lib/types-esm/components/async-api/channelsMapper.d.ts +2 -0
- package/lib/types-esm/components/async-api/generate.d.ts +1 -0
- package/lib/types-esm/components/async-api/messageMapper.d.ts +6 -0
- package/lib/types-esm/components/async-api/payloadMapper.d.ts +4 -0
- package/lib/types-esm/components/async-api/responseMapper.d.ts +6 -0
- package/lib/types-esm/components/default/anyMapper.d.ts +2 -0
- package/lib/types-esm/components/default/classMapper.d.ts +3 -0
- package/lib/types-esm/components/default/genericsMapper.d.ts +5 -0
- package/lib/types-esm/components/default/inheritedClassMapper.d.ts +5 -0
- package/lib/types-esm/components/default/inlineEnumsMapper.d.ts +3 -0
- package/lib/types-esm/components/default/itemMapper.d.ts +2 -0
- package/lib/types-esm/components/default/lazyRefMapper.d.ts +3 -0
- package/lib/types-esm/components/default/mapMapper.d.ts +9 -0
- package/lib/types-esm/components/default/nullableMapper.d.ts +2 -0
- package/lib/types-esm/components/default/objectMapper.d.ts +8 -0
- package/lib/types-esm/components/default/ofMapper.d.ts +3 -0
- package/lib/types-esm/components/default/propertiesMapper.d.ts +3 -0
- package/lib/types-esm/components/default/requiredMapper.d.ts +3 -0
- package/lib/types-esm/components/default/schemaMapper.d.ts +3 -0
- package/lib/types-esm/components/index.d.ts +33 -0
- package/lib/types-esm/components/open-spec/generate.d.ts +1 -0
- package/lib/types-esm/components/open-spec/nullableMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationInFilesMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationInParameterMapper.d.ts +10 -0
- package/lib/types-esm/components/open-spec/operationInParametersMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationInQueryMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationMediaMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationRequestBodyMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationResponseMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/pathsMapper.d.ts +2 -0
- package/lib/types-esm/constants/OperationVerbs.d.ts +20 -0
- package/lib/types-esm/constants/httpStatusMessages.d.ts +11 -0
- package/lib/types-esm/constants/jsonSchemaProperties.d.ts +7 -0
- package/lib/types-esm/decorators/class/children.d.ts +11 -0
- package/lib/types-esm/decorators/class/discriminatorValue.d.ts +42 -0
- package/lib/types-esm/decorators/collections/collectionContains.d.ts +21 -0
- package/lib/types-esm/decorators/collections/collectionOf.d.ts +101 -0
- package/lib/types-esm/decorators/collections/maxItems.d.ts +48 -0
- package/lib/types-esm/decorators/collections/maxProperties.d.ts +71 -0
- package/lib/types-esm/decorators/collections/minItems.d.ts +52 -0
- package/lib/types-esm/decorators/collections/minProperties.d.ts +70 -0
- package/lib/types-esm/decorators/collections/uniqueItems.d.ts +51 -0
- package/lib/types-esm/decorators/common/additionalProperties.d.ts +11 -0
- package/lib/types-esm/decorators/common/allOf.d.ts +13 -0
- package/lib/types-esm/decorators/common/allow.d.ts +28 -0
- package/lib/types-esm/decorators/common/any.d.ts +38 -0
- package/lib/types-esm/decorators/common/anyOf.d.ts +17 -0
- package/lib/types-esm/decorators/common/const.d.ts +61 -0
- package/lib/types-esm/decorators/common/customKey.d.ts +26 -0
- package/lib/types-esm/decorators/common/default.d.ts +41 -0
- package/lib/types-esm/decorators/common/defaultMsg.d.ts +32 -0
- package/lib/types-esm/decorators/common/description.d.ts +53 -0
- package/lib/types-esm/decorators/common/discriminatorKey.d.ts +1 -0
- package/lib/types-esm/decorators/common/enum.d.ts +101 -0
- package/lib/types-esm/decorators/common/errorMsg.d.ts +6 -0
- package/lib/types-esm/decorators/common/example.d.ts +11 -0
- package/lib/types-esm/decorators/common/examples.d.ts +12 -0
- package/lib/types-esm/decorators/common/exclusiveMaximum.d.ts +70 -0
- package/lib/types-esm/decorators/common/exclusiveMinimum.d.ts +70 -0
- package/lib/types-esm/decorators/common/format.d.ts +466 -0
- package/lib/types-esm/decorators/common/forwardGroups.d.ts +10 -0
- package/lib/types-esm/decorators/common/groups.d.ts +12 -0
- package/lib/types-esm/decorators/common/hidden.d.ts +32 -0
- package/lib/types-esm/decorators/common/ignore.d.ts +59 -0
- package/lib/types-esm/decorators/common/integer.d.ts +61 -0
- package/lib/types-esm/decorators/common/jsonEntityFn.d.ts +21 -0
- package/lib/types-esm/decorators/common/maxLength.d.ts +77 -0
- package/lib/types-esm/decorators/common/maximum.d.ts +139 -0
- package/lib/types-esm/decorators/common/minLength.d.ts +78 -0
- package/lib/types-esm/decorators/common/minimum.d.ts +137 -0
- package/lib/types-esm/decorators/common/multipleOf.d.ts +69 -0
- package/lib/types-esm/decorators/common/name.d.ts +32 -0
- package/lib/types-esm/decorators/common/nullable.d.ts +25 -0
- package/lib/types-esm/decorators/common/oneOf.d.ts +17 -0
- package/lib/types-esm/decorators/common/optional.d.ts +10 -0
- package/lib/types-esm/decorators/common/pattern.d.ts +94 -0
- package/lib/types-esm/decorators/common/property.d.ts +11 -0
- package/lib/types-esm/decorators/common/readOnly.d.ts +11 -0
- package/lib/types-esm/decorators/common/recordOf.d.ts +46 -0
- package/lib/types-esm/decorators/common/required.d.ts +44 -0
- package/lib/types-esm/decorators/common/requiredGroups.d.ts +10 -0
- package/lib/types-esm/decorators/common/schema.d.ts +53 -0
- package/lib/types-esm/decorators/common/title.d.ts +39 -0
- package/lib/types-esm/decorators/common/typeError.d.ts +8 -0
- package/lib/types-esm/decorators/common/writeOnly.d.ts +11 -0
- package/lib/types-esm/decorators/config/jsonEntityComponent.d.ts +10 -0
- package/lib/types-esm/decorators/generics/genericOf.d.ts +76 -0
- package/lib/types-esm/decorators/generics/generics.d.ts +14 -0
- package/lib/types-esm/decorators/operations/acceptMime.d.ts +19 -0
- package/lib/types-esm/decorators/operations/consumes.d.ts +19 -0
- package/lib/types-esm/decorators/operations/contentType.d.ts +20 -0
- package/lib/types-esm/decorators/operations/deprecated.d.ts +23 -0
- package/lib/types-esm/decorators/operations/header.d.ts +49 -0
- package/lib/types-esm/decorators/operations/in.d.ts +64 -0
- package/lib/types-esm/decorators/operations/inFile.d.ts +25 -0
- package/lib/types-esm/decorators/operations/location.d.ts +22 -0
- package/lib/types-esm/decorators/operations/operation.d.ts +60 -0
- package/lib/types-esm/decorators/operations/operationId.d.ts +10 -0
- package/lib/types-esm/decorators/operations/operationPath.d.ts +21 -0
- package/lib/types-esm/decorators/operations/partial.d.ts +10 -0
- package/lib/types-esm/decorators/operations/path.d.ts +15 -0
- package/lib/types-esm/decorators/operations/produces.d.ts +26 -0
- package/lib/types-esm/decorators/operations/publish.d.ts +1 -0
- package/lib/types-esm/decorators/operations/redirect.d.ts +52 -0
- package/lib/types-esm/decorators/operations/returns.d.ts +267 -0
- package/lib/types-esm/decorators/operations/route.d.ts +133 -0
- package/lib/types-esm/decorators/operations/security.d.ts +23 -0
- package/lib/types-esm/decorators/operations/status.d.ts +127 -0
- package/lib/types-esm/decorators/operations/subscribe.d.ts +1 -0
- package/lib/types-esm/decorators/operations/summary.d.ts +20 -0
- package/lib/types-esm/decorators/operations/tags.d.ts +23 -0
- package/lib/types-esm/decorators/operations/view.d.ts +23 -0
- package/lib/types-esm/domain/DecoratorContext.d.ts +28 -0
- package/lib/types-esm/domain/JsonAliasMap.d.ts +12 -0
- package/lib/types-esm/domain/JsonClassStore.d.ts +12 -0
- package/lib/types-esm/domain/JsonDiscriminator.d.ts +18 -0
- package/lib/types-esm/domain/JsonEntityStore.d.ts +110 -0
- package/lib/types-esm/domain/JsonFormatTypes.d.ts +17 -0
- package/lib/types-esm/domain/JsonLazyRef.d.ts +9 -0
- package/lib/types-esm/domain/JsonMap.d.ts +9 -0
- package/lib/types-esm/domain/JsonMedia.d.ts +11 -0
- package/lib/types-esm/domain/JsonMethodStore.d.ts +92 -0
- package/lib/types-esm/domain/JsonOperation.d.ts +51 -0
- package/lib/types-esm/domain/JsonOperationPathsMap.d.ts +7 -0
- package/lib/types-esm/domain/JsonOperationRoute.d.ts +25 -0
- package/lib/types-esm/domain/JsonParameter.d.ts +22 -0
- package/lib/types-esm/domain/JsonParameterStore.d.ts +52 -0
- package/lib/types-esm/domain/JsonParameterTypes.d.ts +16 -0
- package/lib/types-esm/domain/JsonPropertyStore.d.ts +32 -0
- package/lib/types-esm/domain/JsonRequestBody.d.ts +12 -0
- package/lib/types-esm/domain/JsonResponse.d.ts +18 -0
- package/lib/types-esm/domain/JsonSchema.d.ts +340 -0
- package/lib/types-esm/domain/SpecTypes.d.ts +6 -0
- package/lib/types-esm/hooks/alterIgnore.d.ts +10 -0
- package/lib/types-esm/hooks/alterOneOf.d.ts +3 -0
- package/lib/types-esm/hooks/alterRequiredGroups.d.ts +6 -0
- package/lib/types-esm/index.d.ts +182 -0
- package/lib/types-esm/interfaces/IgnoreCallback.d.ts +4 -0
- package/lib/types-esm/interfaces/JsonHookContext.d.ts +17 -0
- package/lib/types-esm/interfaces/JsonOpenSpec.d.ts +9 -0
- package/lib/types-esm/interfaces/JsonSchemaOptions.d.ts +30 -0
- package/lib/types-esm/registries/JsonSchemaMapperContainer.d.ts +21 -0
- package/lib/types-esm/registries/enumRegistries.d.ts +2 -0
- package/lib/types-esm/utils/buildPath.d.ts +6 -0
- package/lib/types-esm/utils/concatParameters.d.ts +4 -0
- package/lib/types-esm/utils/concatPath.d.ts +1 -0
- package/lib/types-esm/utils/defineStatusModel.d.ts +3 -0
- package/lib/types-esm/utils/from.d.ts +190 -0
- package/lib/types-esm/utils/generateSpec.d.ts +16 -0
- package/lib/types-esm/utils/generics.d.ts +50 -0
- package/lib/types-esm/utils/getComputedType.d.ts +5 -0
- package/lib/types-esm/utils/getInheritedStores.d.ts +8 -0
- package/lib/types-esm/utils/getJsonEntityStore.d.ts +15 -0
- package/lib/types-esm/utils/getJsonPathParameters.d.ts +7 -0
- package/lib/types-esm/utils/getJsonSchema.d.ts +4 -0
- package/lib/types-esm/utils/getJsonType.d.ts +5 -0
- package/lib/types-esm/utils/getOperationsRoutes.d.ts +10 -0
- package/lib/types-esm/utils/getOperationsStores.d.ts +6 -0
- package/lib/types-esm/utils/getPropertiesStores.d.ts +20 -0
- package/lib/types-esm/utils/getSpec.d.ts +34 -0
- package/lib/types-esm/utils/getSpecType.d.ts +12 -0
- package/lib/types-esm/utils/isSuccessStatus.d.ts +2 -0
- package/lib/types-esm/utils/mapHeaders.d.ts +9 -0
- package/lib/types-esm/utils/mapOpenSpec.d.ts +10 -0
- package/lib/types-esm/utils/mapOpenSpec2.d.ts +9 -0
- package/lib/types-esm/utils/mapOpenSpec3.d.ts +8 -0
- package/lib/types-esm/utils/mapOpenSpecInfo.d.ts +6 -0
- package/lib/types-esm/utils/mapOperationOptions.d.ts +5 -0
- package/lib/types-esm/utils/matchGroups.d.ts +4 -0
- package/lib/types-esm/utils/mergeSpec.d.ts +23 -0
- package/lib/types-esm/utils/operationIdFormatter.d.ts +6 -0
- package/lib/types-esm/utils/ref.d.ts +14 -0
- package/lib/types-esm/utils/removeHiddenOperation.d.ts +2 -0
- package/lib/types-esm/utils/serializeEnumValues.d.ts +5 -0
- package/lib/types-esm/utils/somethingOf.d.ts +1 -0
- package/lib/types-esm/utils/toJsonMapCollection.d.ts +7 -0
- package/lib/types-esm/utils/toJsonRegex.d.ts +5 -0
- package/lib/types-esm/utils/transformToOS2.d.ts +25 -0
- package/lib/types-esm/utils/withErrorMsg.d.ts +6 -0
- package/package.json +21 -17
- package/vitest.config.mts +21 -0
- package/jest.config.js +0 -21
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/tsconfig.esm.json +0 -36
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export interface ArrayOfChainedDecorators {
|
|
2
|
+
(...args: any): any;
|
|
3
|
+
/**
|
|
4
|
+
* An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.
|
|
5
|
+
*
|
|
6
|
+
* ::: warning
|
|
7
|
+
* The value `minItems` MUST be a non-negative integer.
|
|
8
|
+
* :::
|
|
9
|
+
*
|
|
10
|
+
* ::: tip
|
|
11
|
+
* Omitting this keyword has the same behavior as a value of 0.
|
|
12
|
+
* :::
|
|
13
|
+
*/
|
|
14
|
+
MinItems(minItems: number): this;
|
|
15
|
+
/**
|
|
16
|
+
* The value `maxItems` MUST be a non-negative integer.
|
|
17
|
+
*
|
|
18
|
+
* An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.
|
|
19
|
+
*
|
|
20
|
+
* :: warning
|
|
21
|
+
* The value `maxItems` MUST be a non-negative integer.
|
|
22
|
+
* :::
|
|
23
|
+
*/
|
|
24
|
+
MaxItems(maxItems: number): this;
|
|
25
|
+
/**
|
|
26
|
+
* Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
|
|
27
|
+
*
|
|
28
|
+
* The array instance will be valid against "contains" if at least one of its elements is valid against the given schema.
|
|
29
|
+
*/
|
|
30
|
+
Contains(): this;
|
|
31
|
+
/**
|
|
32
|
+
* If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.
|
|
33
|
+
*/
|
|
34
|
+
UniqueItems(uniqueItems?: boolean): this;
|
|
35
|
+
}
|
|
36
|
+
export interface MapOfChainedDecorators {
|
|
37
|
+
(...args: any): any;
|
|
38
|
+
/**
|
|
39
|
+
* An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.
|
|
40
|
+
*
|
|
41
|
+
* ::: warning
|
|
42
|
+
* The value of this keyword MUST be a non-negative integer.
|
|
43
|
+
* :::
|
|
44
|
+
*/
|
|
45
|
+
MinProperties(minProperties: number): this;
|
|
46
|
+
/**
|
|
47
|
+
* An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.
|
|
48
|
+
*
|
|
49
|
+
* ::: warning
|
|
50
|
+
* The value of this keyword MUST be a non-negative integer.
|
|
51
|
+
* :::
|
|
52
|
+
*/
|
|
53
|
+
MaxProperties(maxProperties: number): this;
|
|
54
|
+
}
|
|
55
|
+
export interface CollectionOfChainedDecorators extends MapOfChainedDecorators, ArrayOfChainedDecorators {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
|
|
59
|
+
*
|
|
60
|
+
* ```typescript
|
|
61
|
+
* class Model {
|
|
62
|
+
* @CollectionOf(String).MinLength(0).MaxLength(0)
|
|
63
|
+
* property: string[];
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
* ::: warning
|
|
67
|
+
* You mustn't use the `type Type = string | number` as parameters Type.
|
|
68
|
+
*
|
|
69
|
+
* This example doesn't work:
|
|
70
|
+
*
|
|
71
|
+
* ```typescript
|
|
72
|
+
* type Type = "string" | "number"
|
|
73
|
+
* class Model {
|
|
74
|
+
* @CollectionOf(Type)
|
|
75
|
+
* property: Type[];
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
* :::
|
|
79
|
+
*
|
|
80
|
+
* @param {Type<any>} type
|
|
81
|
+
* @param collectionType
|
|
82
|
+
* @decorator
|
|
83
|
+
* @validation
|
|
84
|
+
* @swagger
|
|
85
|
+
* @schema
|
|
86
|
+
* @input
|
|
87
|
+
* @collections
|
|
88
|
+
*/
|
|
89
|
+
export declare function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators;
|
|
90
|
+
/**
|
|
91
|
+
* Alias of @@GenericOf@@ decorator.
|
|
92
|
+
* @param type
|
|
93
|
+
* @decorator
|
|
94
|
+
*/
|
|
95
|
+
export declare function ArrayOf(type: any): ArrayOfChainedDecorators;
|
|
96
|
+
/**
|
|
97
|
+
* Alias of @@GenericOf@@ decorator.
|
|
98
|
+
* @param type
|
|
99
|
+
* @decorator
|
|
100
|
+
*/
|
|
101
|
+
export declare function MapOf(type: any): MapOfChainedDecorators;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value `maxItems` MUST be a non-negative integer.
|
|
3
|
+
*
|
|
4
|
+
* An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.
|
|
5
|
+
*
|
|
6
|
+
* :: warning
|
|
7
|
+
* The value `maxItems` MUST be a non-negative integer.
|
|
8
|
+
* :::
|
|
9
|
+
*
|
|
10
|
+
* :: warning
|
|
11
|
+
* This decorator will be removed in v7.
|
|
12
|
+
* For v6 user, use @@MaxItems@@ from @tsed/schema instead of @tsed/common.
|
|
13
|
+
* :::
|
|
14
|
+
*
|
|
15
|
+
* ## Example
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* class Model {
|
|
19
|
+
* @CollectionOf(String)
|
|
20
|
+
* @MaxItems(10)
|
|
21
|
+
* property: string[];
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Will produce:
|
|
26
|
+
*
|
|
27
|
+
* ```json
|
|
28
|
+
* {
|
|
29
|
+
* "type": "object",
|
|
30
|
+
* "properties": {
|
|
31
|
+
* "property": {
|
|
32
|
+
* "type": "number",
|
|
33
|
+
* "maxItems": 10
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param {number} maxItems
|
|
40
|
+
* @decorator
|
|
41
|
+
* @validation
|
|
42
|
+
* @swagger
|
|
43
|
+
* @schema
|
|
44
|
+
* @input
|
|
45
|
+
* @collections
|
|
46
|
+
* @ajv-errors
|
|
47
|
+
*/
|
|
48
|
+
export declare const MaxItems: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(maxItems: number) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* The value of this keyword MUST be a non-negative integer.
|
|
6
|
+
* :::
|
|
7
|
+
*
|
|
8
|
+
* ::: warning
|
|
9
|
+
* This decorator will be removed in v7.
|
|
10
|
+
* For v6 user, use @@MaxProperties@@ from @tsed/schema instead of @tsed/common.
|
|
11
|
+
* :::
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
* ### On prop
|
|
15
|
+
* ```typescript
|
|
16
|
+
* class Model {
|
|
17
|
+
* @MaxProperties(10)
|
|
18
|
+
* property: any;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Will produce:
|
|
23
|
+
*
|
|
24
|
+
* ```json
|
|
25
|
+
* {
|
|
26
|
+
* "type": "object",
|
|
27
|
+
* "properties": {
|
|
28
|
+
* "property": {
|
|
29
|
+
* "type": "any",
|
|
30
|
+
* "maxProperties": 10
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ### On class
|
|
37
|
+
*
|
|
38
|
+
* ```typescript
|
|
39
|
+
* @MaxProperties(10)
|
|
40
|
+
* class Model {
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Will produce:
|
|
45
|
+
*
|
|
46
|
+
* ```json
|
|
47
|
+
* {
|
|
48
|
+
* "type": "object",
|
|
49
|
+
* "maxProperties": 10
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ### On Parameter
|
|
54
|
+
*
|
|
55
|
+
* ```typescript
|
|
56
|
+
*
|
|
57
|
+
* class Model {
|
|
58
|
+
* method(@Any() @MaxProperties(10) obj: any){}
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param {number} maxProperties The maximum properties allowed on the given object
|
|
63
|
+
* @decorator
|
|
64
|
+
* @validation
|
|
65
|
+
* @swagger
|
|
66
|
+
* @schema
|
|
67
|
+
* @input
|
|
68
|
+
* @collections
|
|
69
|
+
* @ajv-errors
|
|
70
|
+
*/
|
|
71
|
+
export declare const MaxProperties: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(maxProperties: number) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* The value `minItems` MUST be a non-negative integer.
|
|
6
|
+
* :::
|
|
7
|
+
*
|
|
8
|
+
* ::: tip
|
|
9
|
+
* Omitting this keyword has the same behavior as a value of 0.
|
|
10
|
+
* :::
|
|
11
|
+
*
|
|
12
|
+
* ::: warning
|
|
13
|
+
* For v6 user, use @@MinItems@@ from @tsed/schema instead of @tsed/common.
|
|
14
|
+
* :::
|
|
15
|
+
*
|
|
16
|
+
* ## Example
|
|
17
|
+
*
|
|
18
|
+
* ```typescript
|
|
19
|
+
* class Model {
|
|
20
|
+
* @CollectionOf(String)
|
|
21
|
+
* @MinItems(10)
|
|
22
|
+
* property: string[];
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Will produce:
|
|
27
|
+
*
|
|
28
|
+
* ```json
|
|
29
|
+
* {
|
|
30
|
+
* "type": "object",
|
|
31
|
+
* "properties": {
|
|
32
|
+
* "property": {
|
|
33
|
+
* "type": "array",
|
|
34
|
+
* "minItems": 10,
|
|
35
|
+
* "items": {
|
|
36
|
+
* "type": "string"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param {number} minItems
|
|
44
|
+
* @decorator
|
|
45
|
+
* @validation
|
|
46
|
+
* @swagger
|
|
47
|
+
* @schema
|
|
48
|
+
* @input
|
|
49
|
+
* @collections
|
|
50
|
+
* @ajv-errors
|
|
51
|
+
*/
|
|
52
|
+
export declare const MinItems: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(minItems: number) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* The value of this keyword MUST be a non-negative integer.
|
|
6
|
+
* :::
|
|
7
|
+
*
|
|
8
|
+
* ::: warning
|
|
9
|
+
* For v6 user, use @@MinProperties@@ from @tsed/schema instead of @tsed/common.
|
|
10
|
+
* :::
|
|
11
|
+
*
|
|
12
|
+
* ## Example
|
|
13
|
+
* ### On prop
|
|
14
|
+
* ```typescript
|
|
15
|
+
* class Model {
|
|
16
|
+
* @MinProperties(10)
|
|
17
|
+
* property: any;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Will produce:
|
|
22
|
+
*
|
|
23
|
+
* ```json
|
|
24
|
+
* {
|
|
25
|
+
* "type": "object",
|
|
26
|
+
* "properties": {
|
|
27
|
+
* "property": {
|
|
28
|
+
* "type": "any",
|
|
29
|
+
* "minProperties": 10
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* ### On class
|
|
36
|
+
*
|
|
37
|
+
* ```typescript
|
|
38
|
+
* @MinProperties(10)
|
|
39
|
+
* class Model {
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Will produce:
|
|
44
|
+
*
|
|
45
|
+
* ```json
|
|
46
|
+
* {
|
|
47
|
+
* "type": "object",
|
|
48
|
+
* "minProperties": 10
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* ### On Parameter
|
|
53
|
+
*
|
|
54
|
+
* ```typescript
|
|
55
|
+
*
|
|
56
|
+
* class Model {
|
|
57
|
+
* method(@Any() @MinProperties(10) obj: any){}
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param {number} minProperties The minimum properties allowed on the object.
|
|
62
|
+
* @decorator
|
|
63
|
+
* @validation
|
|
64
|
+
* @swagger
|
|
65
|
+
* @schema
|
|
66
|
+
* @input
|
|
67
|
+
* @collections
|
|
68
|
+
* @ajv-errors
|
|
69
|
+
*/
|
|
70
|
+
export declare const MinProperties: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(minProperties: number) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* For v6 user, use @@UniqueItems@@ from @tsed/schema instead of @tsed/common.
|
|
6
|
+
* :::
|
|
7
|
+
*
|
|
8
|
+
* ## Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* class Model {
|
|
12
|
+
* @UniqueItems() // default true
|
|
13
|
+
* property: number[];
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* * ```typescript
|
|
18
|
+
* class Model {
|
|
19
|
+
* @CollectionOf(String)
|
|
20
|
+
* @UniqueItems()
|
|
21
|
+
* property: string[];
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Will produce:
|
|
26
|
+
*
|
|
27
|
+
* ```json
|
|
28
|
+
* {
|
|
29
|
+
* "type": "object",
|
|
30
|
+
* "properties": {
|
|
31
|
+
* "property": {
|
|
32
|
+
* "type": "array",
|
|
33
|
+
* "uniqueItems": true,
|
|
34
|
+
* "items": {
|
|
35
|
+
* "type": "string"
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param {boolean} uniqueItems
|
|
43
|
+
* @decorator
|
|
44
|
+
* @validation
|
|
45
|
+
* @swagger
|
|
46
|
+
* @schema
|
|
47
|
+
* @input
|
|
48
|
+
* @collections
|
|
49
|
+
* @ajv-errors
|
|
50
|
+
*/
|
|
51
|
+
export declare const UniqueItems: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(uniqueItems?: boolean) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AnyJsonSchema } from "../../domain/JsonSchema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Accept unknown properties on the deserialized model.
|
|
4
|
+
*
|
|
5
|
+
* @param schema
|
|
6
|
+
* @decorator
|
|
7
|
+
* @validation
|
|
8
|
+
* @swagger
|
|
9
|
+
* @schema
|
|
10
|
+
*/
|
|
11
|
+
export declare function AdditionalProperties(schema: boolean | AnyJsonSchema): (...args: any[]) => any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AnyJsonSchema } from "../../domain/JsonSchema.js";
|
|
2
|
+
/**
|
|
3
|
+
* See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26
|
|
4
|
+
*
|
|
5
|
+
* @decorator
|
|
6
|
+
* @validation
|
|
7
|
+
* @swagger
|
|
8
|
+
* @schema
|
|
9
|
+
* @classDecorator
|
|
10
|
+
* @input
|
|
11
|
+
* @param allOf
|
|
12
|
+
*/
|
|
13
|
+
export declare function AllOf(...allOf: AnyJsonSchema[]): (...args: any[]) => any;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add allowed values when the property or parameters is required.
|
|
3
|
+
*
|
|
4
|
+
* #### Example on parameter:
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* @Post("/")
|
|
8
|
+
* async method(@Allow("") @BodyParams("field") field: string) {}
|
|
9
|
+
* ```
|
|
10
|
+
* > Required will throw a BadRequest when the given value is `null` or `undefined` but not for an empty string.
|
|
11
|
+
*
|
|
12
|
+
* #### Example on model:
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* class Model {
|
|
16
|
+
* @Allow("")
|
|
17
|
+
* field: string;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @returns {Function}
|
|
22
|
+
* @decorator
|
|
23
|
+
* @validation
|
|
24
|
+
* @swagger
|
|
25
|
+
* @schema
|
|
26
|
+
* @input
|
|
27
|
+
*/
|
|
28
|
+
export declare function Allow(...values: any[]): any;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import type { JSONSchema6TypeName } from "json-schema";
|
|
3
|
+
/**
|
|
4
|
+
* Set the type of the array items.
|
|
5
|
+
*
|
|
6
|
+
* ## Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* class Model {
|
|
10
|
+
* @Any()
|
|
11
|
+
* property: any;
|
|
12
|
+
*
|
|
13
|
+
* @Any(String, Number, Boolean)
|
|
14
|
+
* property: string | number | boolean;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Will produce:
|
|
19
|
+
*
|
|
20
|
+
* ```json
|
|
21
|
+
* {
|
|
22
|
+
* "type": "object",
|
|
23
|
+
* "properties": {
|
|
24
|
+
* "property": {
|
|
25
|
+
* "type": ["integer", "number", "string", "boolean", "array", "object", "null"]
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @returns {Function}
|
|
32
|
+
* @decorator
|
|
33
|
+
* @validation
|
|
34
|
+
* @swagger
|
|
35
|
+
* @schema
|
|
36
|
+
* @input
|
|
37
|
+
*/
|
|
38
|
+
export declare function Any(...types: (JSONSchema6TypeName | Type<any> | any)[]): (...args: any[]) => any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnyJsonSchema } from "../../domain/JsonSchema.js";
|
|
2
|
+
/**
|
|
3
|
+
* See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27
|
|
4
|
+
*
|
|
5
|
+
* ::: warning
|
|
6
|
+
* AnyOf isn't supported by OS2
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* @decorator
|
|
10
|
+
* @validation
|
|
11
|
+
* @swagger
|
|
12
|
+
* @schema
|
|
13
|
+
* @classDecorator
|
|
14
|
+
* @input
|
|
15
|
+
* @param anyOf
|
|
16
|
+
*/
|
|
17
|
+
export declare function AnyOf(...anyOf: AnyJsonSchema[]): (...args: any[]) => any;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { JSONSchema6Type } from "json-schema";
|
|
2
|
+
/**
|
|
3
|
+
* The const keyword is used to restrict a value to a fixed value.
|
|
4
|
+
*
|
|
5
|
+
* ::: warning
|
|
6
|
+
* For v6 user, use @@Const@@ from @tsed/schema instead of @tsed/common.
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* ## Example
|
|
10
|
+
* ### With a string
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* class Model {
|
|
14
|
+
* @Const("value1")
|
|
15
|
+
* property: "value1";
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Will produce:
|
|
20
|
+
*
|
|
21
|
+
* ```json
|
|
22
|
+
* {
|
|
23
|
+
* "type": "object",
|
|
24
|
+
* "properties": {
|
|
25
|
+
* "property": {
|
|
26
|
+
* "type": "string",
|
|
27
|
+
* "const": "value1"
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
* * ### With a boolean
|
|
33
|
+
*
|
|
34
|
+
* ```typescript
|
|
35
|
+
* class Model {
|
|
36
|
+
* @Const(true)
|
|
37
|
+
* property: boolean;
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Will produce:
|
|
42
|
+
*
|
|
43
|
+
* ```json
|
|
44
|
+
* {
|
|
45
|
+
* "type": "object",
|
|
46
|
+
* "properties": {
|
|
47
|
+
* "property": {
|
|
48
|
+
* "type": "boolean",
|
|
49
|
+
* "const": true
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @param {string | number | boolean } constValue
|
|
56
|
+
* @decorator
|
|
57
|
+
* @validation
|
|
58
|
+
* @swagger
|
|
59
|
+
* @schema
|
|
60
|
+
*/
|
|
61
|
+
export declare function Const(constValue: JSONSchema6Type | any): (...args: any[]) => any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set a custom key on JsonSchema that is not a part of the official spec.
|
|
3
|
+
*
|
|
4
|
+
* This custom key can only be displayed if the @@getJsonSchema@@ is called with `{customKeys: true}`.
|
|
5
|
+
*
|
|
6
|
+
* @returns {Function}
|
|
7
|
+
* @decorator
|
|
8
|
+
* @validation
|
|
9
|
+
* @property
|
|
10
|
+
* @parameter
|
|
11
|
+
* @schema
|
|
12
|
+
*/
|
|
13
|
+
export declare function CustomKey(key: string, value: any): (...args: any[]) => any;
|
|
14
|
+
/**
|
|
15
|
+
* Set a group of custom keys on JsonSchema that is not a part of the official spec.
|
|
16
|
+
*
|
|
17
|
+
* This custom key can only be displayed if the @@getJsonSchema@@ is called with `{customKeys: true}`.
|
|
18
|
+
*
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @validation
|
|
22
|
+
* @property
|
|
23
|
+
* @parameter
|
|
24
|
+
* @schema
|
|
25
|
+
*/
|
|
26
|
+
export declare function CustomKeys(obj: Record<string, any>): (...args: any[]) => any;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* There are no restrictions placed on the value of this keyword.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* For v6 user, use @@Default@@ from @tsed/schema instead of @tsed/common.
|
|
6
|
+
* :::
|
|
7
|
+
*
|
|
8
|
+
* This keyword can be used to supply a default JSON value associated with a particular schema.
|
|
9
|
+
* It is RECOMMENDED that a default value be valid against the associated schema.
|
|
10
|
+
*
|
|
11
|
+
* ## Example
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* class Model {
|
|
15
|
+
* @Default("10")
|
|
16
|
+
* property: string = "10";
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Will produce:
|
|
21
|
+
*
|
|
22
|
+
* ```json
|
|
23
|
+
* {
|
|
24
|
+
* "type": "object",
|
|
25
|
+
* "properties": {
|
|
26
|
+
* "property": {
|
|
27
|
+
* "type": "string",
|
|
28
|
+
* "default": "10"
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param {string | number | boolean | {}} defaultValue
|
|
35
|
+
* @decorator
|
|
36
|
+
* @validation
|
|
37
|
+
* @swagger
|
|
38
|
+
* @schema
|
|
39
|
+
* @input
|
|
40
|
+
*/
|
|
41
|
+
export declare function Default(defaultValue: string | number | boolean | {}): (...args: any[]) => any;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set default error message.
|
|
3
|
+
*
|
|
4
|
+
* ## Example
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* @DefaultMsg("foo should be a string")
|
|
8
|
+
* class Model {
|
|
9
|
+
* property: number;
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Will produce:
|
|
14
|
+
*
|
|
15
|
+
* ```json
|
|
16
|
+
* {
|
|
17
|
+
* "type": "object",
|
|
18
|
+
* "properties": {
|
|
19
|
+
* "property": "number"
|
|
20
|
+
* }
|
|
21
|
+
* "errorMessage": {
|
|
22
|
+
* "_": "foo should be a string"
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @decorator
|
|
28
|
+
* @validation
|
|
29
|
+
* @swagger
|
|
30
|
+
* @schema
|
|
31
|
+
*/
|
|
32
|
+
export declare function DefaultMsg(message: string): ClassDecorator;
|