@tsed/schema 8.9.1 → 8.9.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/lib/browser/schema.umd.min.js +1 -1
- package/lib/browser/schema.umd.min.js.map +1 -1
- package/lib/esm/components/open-spec/operationRequestBodyMapper.js +2 -1
- package/lib/esm/components/open-spec/operationRequestBodyMapper.js.map +1 -1
- package/lib/esm/decorators/collections/collectionOf.js +18 -0
- package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
- package/lib/esm/decorators/common/oneOf.js +0 -1
- package/lib/esm/decorators/common/oneOf.js.map +1 -1
- package/lib/esm/domain/JsonParameter.js +16 -2
- package/lib/esm/domain/JsonParameter.js.map +1 -1
- package/lib/esm/domain/JsonParameterStore.js +14 -18
- package/lib/esm/domain/JsonParameterStore.js.map +1 -1
- package/lib/types/decorators/collections/collectionOf.d.ts +6 -0
- package/lib/types/domain/JsonParameter.d.ts +2 -0
- package/lib/types/domain/JsonParameterStore.d.ts +1 -2
- package/package.json +10 -10
- package/src/components/open-spec/operationRequestBodyMapper.ts +3 -1
- package/src/decorators/collections/collectionOf.ts +24 -3
- package/src/decorators/common/oneOf.ts +0 -1
- package/src/domain/JsonParameter.ts +21 -4
- package/src/domain/JsonParameterStore.ts +14 -23
|
@@ -52,8 +52,9 @@ function buildSchemaFromBodyParameters(parameters, options) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
export function operationRequestBodyMapper(bodyParameters, { consumes, ...options }) {
|
|
55
|
-
const { schema, examples, in: _, ...props } = buildSchemaFromBodyParameters(bodyParameters, options);
|
|
55
|
+
const { schema, description, examples, in: _, ...props } = buildSchemaFromBodyParameters(bodyParameters, options);
|
|
56
56
|
const requestBody = new JsonRequestBody(props);
|
|
57
|
+
description && requestBody.description(description);
|
|
57
58
|
consumes.forEach((consume) => {
|
|
58
59
|
requestBody.addContent(consume, schema, examples);
|
|
59
60
|
});
|
|
@@ -1 +1 @@
|
|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AE,OAAO,CAAC,CAAC;IAEhH,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IAE/C,WAAW,IAAI,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAEpD,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAe,EAAE,EAAE;QACnC,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,wBAAwB,CAAC,sBAAsB,EAAE,0BAA0B,CAAC,CAAC"}
|
|
@@ -51,26 +51,44 @@ export function CollectionOf(type, collectionType) {
|
|
|
51
51
|
store.schema.delete("items");
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Since 2025-05-12. Use MinItems decorator instead.
|
|
56
|
+
*/
|
|
54
57
|
decorator.MinItems = (minItems) => {
|
|
55
58
|
schema.minItems = minItems;
|
|
56
59
|
return decorator;
|
|
57
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Since 2025-05-12. Use MaxItems decorator instead.
|
|
63
|
+
*/
|
|
58
64
|
decorator.MaxItems = (maxItems) => {
|
|
59
65
|
schema.maxItems = maxItems;
|
|
60
66
|
return decorator;
|
|
61
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Since 2025-05-12. Use MinProperties decorator instead.
|
|
70
|
+
*/
|
|
62
71
|
decorator.MinProperties = (minProperties) => {
|
|
63
72
|
schema.minProperties = minProperties;
|
|
64
73
|
return decorator;
|
|
65
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Since 2025-05-12. Use MaxProperties decorator instead.
|
|
77
|
+
*/
|
|
66
78
|
decorator.MaxProperties = (maxProperties) => {
|
|
67
79
|
schema.maxProperties = maxProperties;
|
|
68
80
|
return decorator;
|
|
69
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Since 2025-05-12. Use Contains decorator instead.
|
|
84
|
+
*/
|
|
70
85
|
decorator.Contains = () => {
|
|
71
86
|
contains = true;
|
|
72
87
|
return decorator;
|
|
73
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Since 2025-05-12. Use UniqueItems decorator instead.
|
|
91
|
+
*/
|
|
74
92
|
decorator.UniqueItems = (uniqueItems = true) => {
|
|
75
93
|
schema.uniqueItems = uniqueItems;
|
|
76
94
|
return decorator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAwEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,YAAY,CAAC,IAAS,EAAE,cAAoB;IAC1D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,iJAAiJ,CAClJ,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAS,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAE5C,IAAI,cAAc,EAAE,CAAC;YACnB,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;YACtC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACpC,CAAC;QAED,KAAK,CAAC,IAAI,GAAG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AC,WAAW,GAAG,WAAW,CAAC;QAEjC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,IAAS;IAC/B,OAAO,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,IAAS;IAC7B,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oneOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/oneOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,KAAsB;IAC7C,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"oneOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/oneOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,KAAsB;IAC7C,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
2
2
|
import { JsonMap } from "./JsonMap.js";
|
|
3
3
|
import { formatParameterType } from "./JsonParameterTypes.js";
|
|
4
|
+
import { JsonSchema } from "./JsonSchema.js";
|
|
4
5
|
export class JsonParameter extends JsonMap {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
7
8
|
this.$kind = "operationInParameter";
|
|
8
9
|
this.nestedGenerics = [];
|
|
10
|
+
this.$schema = new JsonSchema();
|
|
9
11
|
}
|
|
10
12
|
getName() {
|
|
11
13
|
const name = this.get("name");
|
|
@@ -36,8 +38,20 @@ export class JsonParameter extends JsonMap {
|
|
|
36
38
|
return this;
|
|
37
39
|
}
|
|
38
40
|
schema(schema) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
if (schema) {
|
|
42
|
+
this.$schema = schema;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
return this.$schema;
|
|
46
|
+
}
|
|
47
|
+
itemSchema(schema) {
|
|
48
|
+
if (this.$schema.isCollection) {
|
|
49
|
+
schema && this.$schema.itemSchema(schema);
|
|
50
|
+
return this.$schema.itemSchema();
|
|
51
|
+
}
|
|
52
|
+
schema && this.schema(schema);
|
|
53
|
+
// non-collection: delegate to main schema would
|
|
54
|
+
return this.schema();
|
|
41
55
|
}
|
|
42
56
|
toJSON(options) {
|
|
43
57
|
return execMapper("operationInParameter", [this], options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonParameter.js","sourceRoot":"","sources":["../../../src/domain/JsonParameter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,4CAA4C,CAAC;AAEtE,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"JsonParameter.js","sourceRoot":"","sources":["../../../src/domain/JsonParameter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,4CAA4C,CAAC;AAEtE,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CA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E,CAAC;YACX,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,UAAU,CAAC,MAAmB;QAC5B,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAE1C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9B,gDAAgD;QAChD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,OAA2B;QAChC,OAAO,UAAU,CAAC,sBAAsB,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { ancestorsOf, DecoratorTypes, isClass,
|
|
2
|
+
import { ancestorsOf, DecoratorTypes, isClass, isMethodDescriptor, Metadata, prototypeOf } from "@tsed/core";
|
|
3
3
|
import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
|
|
4
4
|
import { JsonEntityStore } from "./JsonEntityStore.js";
|
|
5
5
|
import { JsonParameter } from "./JsonParameter.js";
|
|
6
|
-
import { JsonSchema } from "./JsonSchema.js";
|
|
7
6
|
let JsonParameterStore = class JsonParameterStore extends JsonEntityStore {
|
|
8
7
|
constructor(options) {
|
|
9
8
|
super(options);
|
|
@@ -36,6 +35,9 @@ let JsonParameterStore = class JsonParameterStore extends JsonEntityStore {
|
|
|
36
35
|
get allowedRequiredValues() {
|
|
37
36
|
return this.schema.$allow;
|
|
38
37
|
}
|
|
38
|
+
get schema() {
|
|
39
|
+
return this.parameter.$schema;
|
|
40
|
+
}
|
|
39
41
|
static getParams(target, propertyKey) {
|
|
40
42
|
const params = [];
|
|
41
43
|
const klass = ancestorsOf(target)
|
|
@@ -62,28 +64,22 @@ let JsonParameterStore = class JsonParameterStore extends JsonEntityStore {
|
|
|
62
64
|
isRequired(value) {
|
|
63
65
|
return this.required && [undefined, null, ""].includes(value) && !this.allowedRequiredValues.includes(value);
|
|
64
66
|
}
|
|
65
|
-
getSchema(type) {
|
|
66
|
-
if (isCollection(type) || !isClass(type)) {
|
|
67
|
-
return JsonSchema.from({
|
|
68
|
-
type
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return JsonEntityStore.from(type).schema;
|
|
72
|
-
}
|
|
73
67
|
build() {
|
|
74
68
|
if (!this._type) {
|
|
75
69
|
const type = Metadata.getParamTypes(prototypeOf(this.target), this.propertyKey)[this.index];
|
|
76
70
|
this.buildType(type);
|
|
77
71
|
}
|
|
78
72
|
this._type = this._type || Object;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.parameter.schema(this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
this.parent.children.set(this.index, this);
|
|
74
|
+
this.parent.operation.addParameter(this.index, this.parameter);
|
|
75
|
+
if (this.collectionType) {
|
|
76
|
+
this.parameter.schema().type(this.collectionType);
|
|
77
|
+
}
|
|
78
|
+
if (isClass(this._type)) {
|
|
79
|
+
this.parameter.itemSchema(JsonEntityStore.from(this._type).schema);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.parameter.itemSchema().type(this._type);
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"JsonParameterStore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+10,7 @@ export interface ArrayOfChainedDecorators {
|
|
|
10
10
|
* ::: tip
|
|
11
11
|
* Omitting this keyword has the same behavior as a value of 0.
|
|
12
12
|
* :::
|
|
13
|
+
* @deprecated Since 2025-05-12. Use MinItems decorator instead.
|
|
13
14
|
*/
|
|
14
15
|
MinItems(minItems: number): this;
|
|
15
16
|
/**
|
|
@@ -20,16 +21,19 @@ export interface ArrayOfChainedDecorators {
|
|
|
20
21
|
* :: warning
|
|
21
22
|
* The value `maxItems` MUST be a non-negative integer.
|
|
22
23
|
* :::
|
|
24
|
+
* @deprecated Since 2025-05-12. Use MaxItems decorator instead.
|
|
23
25
|
*/
|
|
24
26
|
MaxItems(maxItems: number): this;
|
|
25
27
|
/**
|
|
26
28
|
* Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
|
|
27
29
|
*
|
|
28
30
|
* The array instance will be valid against "contains" if at least one of its elements is valid against the given schema.
|
|
31
|
+
* @deprecated Since 2025-05-12. Use Contains decorator instead.
|
|
29
32
|
*/
|
|
30
33
|
Contains(): this;
|
|
31
34
|
/**
|
|
32
35
|
* 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.
|
|
36
|
+
* @deprecated Since 2025-05-12. Use UniqueItems decorator instead.
|
|
33
37
|
*/
|
|
34
38
|
UniqueItems(uniqueItems?: boolean): this;
|
|
35
39
|
}
|
|
@@ -41,6 +45,7 @@ export interface MapOfChainedDecorators {
|
|
|
41
45
|
* ::: warning
|
|
42
46
|
* The value of this keyword MUST be a non-negative integer.
|
|
43
47
|
* :::
|
|
48
|
+
* @deprecated Since 2025-05-12. Use MinProperties decorator instead.
|
|
44
49
|
*/
|
|
45
50
|
MinProperties(minProperties: number): this;
|
|
46
51
|
/**
|
|
@@ -49,6 +54,7 @@ export interface MapOfChainedDecorators {
|
|
|
49
54
|
* ::: warning
|
|
50
55
|
* The value of this keyword MUST be a non-negative integer.
|
|
51
56
|
* :::
|
|
57
|
+
* @deprecated Since 2025-05-12. Use MaxProperties decorator instead.
|
|
52
58
|
*/
|
|
53
59
|
MaxProperties(maxProperties: number): this;
|
|
54
60
|
}
|
|
@@ -17,6 +17,8 @@ export declare class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> imp
|
|
|
17
17
|
description(description: string): this;
|
|
18
18
|
in(inType: string, expression?: string | any): this;
|
|
19
19
|
required(required: boolean): this;
|
|
20
|
+
schema(): JsonSchema;
|
|
20
21
|
schema(schema: JsonSchema): this;
|
|
22
|
+
itemSchema(schema?: JsonSchema): JsonSchema;
|
|
21
23
|
toJSON(options?: JsonSchemaOptions): any;
|
|
22
24
|
}
|
|
@@ -2,7 +2,6 @@ import { Type } from "@tsed/core";
|
|
|
2
2
|
import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore.js";
|
|
3
3
|
import type { JsonMethodStore } from "./JsonMethodStore.js";
|
|
4
4
|
import { JsonParameter } from "./JsonParameter.js";
|
|
5
|
-
import { JsonSchema } from "./JsonSchema.js";
|
|
6
5
|
export interface JsonParameterStoreOptions extends JsonEntityStoreOptions {
|
|
7
6
|
dataPath?: string;
|
|
8
7
|
paramType?: string;
|
|
@@ -34,6 +33,7 @@ export declare class JsonParameterStore extends JsonEntityStore {
|
|
|
34
33
|
get required(): boolean;
|
|
35
34
|
set required(value: boolean);
|
|
36
35
|
get allowedRequiredValues(): any[];
|
|
36
|
+
get schema(): import("./JsonSchema.js").JsonSchema;
|
|
37
37
|
static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[];
|
|
38
38
|
static get(target: Type<any>, propertyKey: string | symbol, index: number): JsonParameterStore;
|
|
39
39
|
/**
|
|
@@ -42,7 +42,6 @@ export declare class JsonParameterStore extends JsonEntityStore {
|
|
|
42
42
|
* @returns {boolean}
|
|
43
43
|
*/
|
|
44
44
|
isRequired(value: any): boolean;
|
|
45
|
-
protected getSchema(type: any): JsonSchema;
|
|
46
45
|
protected build(): void;
|
|
47
46
|
}
|
|
48
47
|
/**
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/schema",
|
|
3
3
|
"description": "JsonSchema module for Ts.ED Framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.9.
|
|
5
|
+
"version": "8.9.3",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"tsed"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@tsed/openspec": "8.9.
|
|
40
|
+
"@tsed/openspec": "8.9.3",
|
|
41
41
|
"change-case": "^5.4.4",
|
|
42
42
|
"json-schema": "0.4.0",
|
|
43
43
|
"picomatch": "4.0.2",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@apidevtools/swagger-parser": "10.1.0",
|
|
49
|
-
"@tsed/barrels": "8.9.
|
|
50
|
-
"@tsed/core": "8.9.
|
|
51
|
-
"@tsed/hooks": "8.9.
|
|
52
|
-
"@tsed/openspec": "8.9.
|
|
53
|
-
"@tsed/typescript": "8.9.
|
|
49
|
+
"@tsed/barrels": "8.9.3",
|
|
50
|
+
"@tsed/core": "8.9.3",
|
|
51
|
+
"@tsed/hooks": "8.9.3",
|
|
52
|
+
"@tsed/openspec": "8.9.3",
|
|
53
|
+
"@tsed/typescript": "8.9.3",
|
|
54
54
|
"@types/fs-extra": "11.0.4",
|
|
55
55
|
"@types/json-schema": "7.0.15",
|
|
56
56
|
"@types/picomatch": "3.0.2",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"webpack": "^5.75.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@tsed/core": ">=8.9.
|
|
66
|
-
"@tsed/hooks": ">=8.9.
|
|
67
|
-
"@tsed/openspec": ">=8.9.
|
|
65
|
+
"@tsed/core": ">=8.9.3",
|
|
66
|
+
"@tsed/hooks": ">=8.9.3",
|
|
67
|
+
"@tsed/openspec": ">=8.9.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@tsed/core": {
|
|
@@ -68,10 +68,12 @@ function buildSchemaFromBodyParameters(parameters: JsonParameter[], options: Jso
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export function operationRequestBodyMapper(bodyParameters: JsonParameter[], {consumes, ...options}: JsonSchemaOptions) {
|
|
71
|
-
const {schema, examples, in: _, ...props} = buildSchemaFromBodyParameters(bodyParameters, options);
|
|
71
|
+
const {schema, description, examples, in: _, ...props} = buildSchemaFromBodyParameters(bodyParameters, options);
|
|
72
72
|
|
|
73
73
|
const requestBody = new JsonRequestBody(props);
|
|
74
74
|
|
|
75
|
+
description && requestBody.description(description);
|
|
76
|
+
|
|
75
77
|
consumes.forEach((consume: string) => {
|
|
76
78
|
requestBody.addContent(consume, schema, examples);
|
|
77
79
|
});
|
|
@@ -13,6 +13,7 @@ export interface ArrayOfChainedDecorators {
|
|
|
13
13
|
* ::: tip
|
|
14
14
|
* Omitting this keyword has the same behavior as a value of 0.
|
|
15
15
|
* :::
|
|
16
|
+
* @deprecated Since 2025-05-12. Use MinItems decorator instead.
|
|
16
17
|
*/
|
|
17
18
|
MinItems(minItems: number): this;
|
|
18
19
|
|
|
@@ -24,6 +25,7 @@ export interface ArrayOfChainedDecorators {
|
|
|
24
25
|
* :: warning
|
|
25
26
|
* The value `maxItems` MUST be a non-negative integer.
|
|
26
27
|
* :::
|
|
28
|
+
* @deprecated Since 2025-05-12. Use MaxItems decorator instead.
|
|
27
29
|
*/
|
|
28
30
|
MaxItems(maxItems: number): this;
|
|
29
31
|
|
|
@@ -31,11 +33,13 @@ export interface ArrayOfChainedDecorators {
|
|
|
31
33
|
* Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
|
|
32
34
|
*
|
|
33
35
|
* The array instance will be valid against "contains" if at least one of its elements is valid against the given schema.
|
|
36
|
+
* @deprecated Since 2025-05-12. Use Contains decorator instead.
|
|
34
37
|
*/
|
|
35
38
|
Contains(): this;
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
41
|
* 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.
|
|
42
|
+
* @deprecated Since 2025-05-12. Use UniqueItems decorator instead.
|
|
39
43
|
*/
|
|
40
44
|
UniqueItems(uniqueItems?: boolean): this;
|
|
41
45
|
}
|
|
@@ -49,6 +53,7 @@ export interface MapOfChainedDecorators {
|
|
|
49
53
|
* ::: warning
|
|
50
54
|
* The value of this keyword MUST be a non-negative integer.
|
|
51
55
|
* :::
|
|
56
|
+
* @deprecated Since 2025-05-12. Use MinProperties decorator instead.
|
|
52
57
|
*/
|
|
53
58
|
MinProperties(minProperties: number): this;
|
|
54
59
|
|
|
@@ -58,6 +63,7 @@ export interface MapOfChainedDecorators {
|
|
|
58
63
|
* ::: warning
|
|
59
64
|
* The value of this keyword MUST be a non-negative integer.
|
|
60
65
|
* :::
|
|
66
|
+
* @deprecated Since 2025-05-12. Use MaxProperties decorator instead.
|
|
61
67
|
*/
|
|
62
68
|
MaxProperties(maxProperties: number): this;
|
|
63
69
|
}
|
|
@@ -124,36 +130,51 @@ export function CollectionOf(type: any, collectionType?: any): CollectionOfChain
|
|
|
124
130
|
store.schema.delete("items");
|
|
125
131
|
}
|
|
126
132
|
};
|
|
127
|
-
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Since 2025-05-12. Use MinItems decorator instead.
|
|
135
|
+
*/
|
|
128
136
|
decorator.MinItems = (minItems: number) => {
|
|
129
137
|
schema.minItems = minItems;
|
|
130
138
|
|
|
131
139
|
return decorator;
|
|
132
140
|
};
|
|
133
|
-
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Since 2025-05-12. Use MaxItems decorator instead.
|
|
143
|
+
*/
|
|
134
144
|
decorator.MaxItems = (maxItems: number) => {
|
|
135
145
|
schema.maxItems = maxItems;
|
|
136
146
|
|
|
137
147
|
return decorator;
|
|
138
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated Since 2025-05-12. Use MinProperties decorator instead.
|
|
151
|
+
*/
|
|
139
152
|
decorator.MinProperties = (minProperties: number) => {
|
|
140
153
|
schema.minProperties = minProperties;
|
|
141
154
|
|
|
142
155
|
return decorator;
|
|
143
156
|
};
|
|
144
|
-
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated Since 2025-05-12. Use MaxProperties decorator instead.
|
|
159
|
+
*/
|
|
145
160
|
decorator.MaxProperties = (maxProperties: number) => {
|
|
146
161
|
schema.maxProperties = maxProperties;
|
|
147
162
|
|
|
148
163
|
return decorator;
|
|
149
164
|
};
|
|
150
165
|
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Since 2025-05-12. Use Contains decorator instead.
|
|
168
|
+
*/
|
|
151
169
|
decorator.Contains = () => {
|
|
152
170
|
contains = true;
|
|
153
171
|
|
|
154
172
|
return decorator;
|
|
155
173
|
};
|
|
156
174
|
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated Since 2025-05-12. Use UniqueItems decorator instead.
|
|
177
|
+
*/
|
|
157
178
|
decorator.UniqueItems = (uniqueItems = true) => {
|
|
158
179
|
schema.uniqueItems = uniqueItems;
|
|
159
180
|
|
|
@@ -14,7 +14,7 @@ export class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements
|
|
|
14
14
|
nestedGenerics: Type<any>[][] = [];
|
|
15
15
|
groups: string[];
|
|
16
16
|
groupsName: string;
|
|
17
|
-
$schema: JsonSchema;
|
|
17
|
+
$schema: JsonSchema = new JsonSchema();
|
|
18
18
|
expression: string;
|
|
19
19
|
|
|
20
20
|
getName() {
|
|
@@ -58,10 +58,27 @@ export class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements
|
|
|
58
58
|
return this;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
schema(
|
|
62
|
-
|
|
61
|
+
public schema(): JsonSchema;
|
|
62
|
+
public schema(schema: JsonSchema): this;
|
|
63
|
+
public schema(schema?: JsonSchema): JsonSchema | this {
|
|
64
|
+
if (schema) {
|
|
65
|
+
this.$schema = schema;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
63
68
|
|
|
64
|
-
return this;
|
|
69
|
+
return this.$schema;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
itemSchema(schema?: JsonSchema) {
|
|
73
|
+
if (this.$schema.isCollection) {
|
|
74
|
+
schema && this.$schema.itemSchema(schema);
|
|
75
|
+
|
|
76
|
+
return this.$schema.itemSchema();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
schema && this.schema(schema);
|
|
80
|
+
// non-collection: delegate to main schema would
|
|
81
|
+
return this.schema();
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
toJSON(options?: JsonSchemaOptions) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {ancestorsOf, DecoratorTypes, isClass,
|
|
1
|
+
import {ancestorsOf, DecoratorTypes, isClass, isMethodDescriptor, Metadata, prototypeOf, Type} from "@tsed/core";
|
|
2
2
|
|
|
3
3
|
import {JsonEntityComponent} from "../decorators/config/jsonEntityComponent.js";
|
|
4
4
|
import {JsonEntityStore, JsonEntityStoreOptions} from "./JsonEntityStore.js";
|
|
5
5
|
import type {JsonMethodStore} from "./JsonMethodStore.js";
|
|
6
6
|
import {JsonParameter} from "./JsonParameter.js";
|
|
7
|
-
import {JsonSchema} from "./JsonSchema.js";
|
|
8
7
|
|
|
9
8
|
export interface JsonParameterStoreOptions extends JsonEntityStoreOptions {
|
|
10
9
|
dataPath?: string;
|
|
@@ -63,6 +62,10 @@ export class JsonParameterStore extends JsonEntityStore {
|
|
|
63
62
|
return this.schema.$allow;
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
get schema() {
|
|
66
|
+
return this.parameter.$schema;
|
|
67
|
+
}
|
|
68
|
+
|
|
66
69
|
static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[] {
|
|
67
70
|
const params: T[] = [];
|
|
68
71
|
|
|
@@ -96,16 +99,6 @@ export class JsonParameterStore extends JsonEntityStore {
|
|
|
96
99
|
return this.required && [undefined, null, ""].includes(value) && !this.allowedRequiredValues.includes(value);
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
protected getSchema(type: any) {
|
|
100
|
-
if (isCollection(type) || !isClass(type)) {
|
|
101
|
-
return JsonSchema.from({
|
|
102
|
-
type
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return JsonEntityStore.from(type).schema;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
102
|
protected build() {
|
|
110
103
|
if (!this._type) {
|
|
111
104
|
const type: any = Metadata.getParamTypes(prototypeOf(this.target), this.propertyKey)[this.index!];
|
|
@@ -114,19 +107,17 @@ export class JsonParameterStore extends JsonEntityStore {
|
|
|
114
107
|
}
|
|
115
108
|
|
|
116
109
|
this._type = this._type || Object;
|
|
110
|
+
this.parent.children.set(this.index!, this);
|
|
111
|
+
this.parent.operation.addParameter(this.index as number, this.parameter);
|
|
117
112
|
|
|
118
|
-
if (
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
this._schema = this.getSchema(this.collectionType || this.type);
|
|
122
|
-
|
|
123
|
-
this.parameter.schema(this._schema);
|
|
124
|
-
|
|
125
|
-
if (this.collectionType) {
|
|
126
|
-
this._schema.itemSchema(this.getSchema(this.type));
|
|
127
|
-
}
|
|
113
|
+
if (this.collectionType) {
|
|
114
|
+
this.parameter.schema().type(this.collectionType);
|
|
115
|
+
}
|
|
128
116
|
|
|
129
|
-
|
|
117
|
+
if (isClass(this._type)) {
|
|
118
|
+
this.parameter.itemSchema(JsonEntityStore.from(this._type).schema);
|
|
119
|
+
} else {
|
|
120
|
+
this.parameter.itemSchema().type(this._type);
|
|
130
121
|
}
|
|
131
122
|
}
|
|
132
123
|
}
|