@tsed/schema 8.13.5 → 8.14.0-rc.1
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/esm/components/default/anyMapper.js +1 -2
- package/lib/esm/components/default/classMapper.js +2 -22
- package/lib/esm/components/default/genericsMapper.js +62 -48
- package/lib/esm/components/default/lazyRefMapper.js +1 -2
- package/lib/esm/components/default/mapMapper.js +0 -2
- package/lib/esm/components/default/nextMapper.js +74 -0
- package/lib/esm/components/default/objectMapper.js +8 -3
- package/lib/esm/components/default/ofMapper.js +2 -5
- package/lib/esm/components/default/requiredMapper.js +2 -2
- package/lib/esm/components/default/schemaMapper.js +6 -7
- package/lib/esm/components/index.js +1 -7
- package/lib/esm/components/open-spec/nullableMapper.js +5 -1
- package/lib/esm/components/open-spec/operationInParameterMapper.js +3 -7
- package/lib/esm/components/open-spec/operationInQueryMapper.js +22 -17
- package/lib/esm/components/open-spec/operationMediaMapper.js +5 -2
- package/lib/esm/components/open-spec/operationRequestBodyMapper.js +2 -2
- package/lib/esm/constants/VendorKeys.js +11 -0
- package/lib/esm/decorators/collections/collectionOf.js +14 -3
- package/lib/esm/decorators/common/description.js +9 -12
- package/lib/esm/decorators/common/discriminatorKey.js +1 -1
- package/lib/esm/decorators/common/forwardGroups.js +1 -1
- package/lib/esm/decorators/common/groups.js +15 -26
- package/lib/esm/decorators/common/oneOf.js +1 -1
- package/lib/esm/decorators/generics/genericOf.js +8 -17
- package/lib/esm/decorators/generics/generics.js +3 -3
- package/lib/esm/decorators/operations/redirect.js +1 -1
- package/lib/esm/decorators/operations/returns.js +40 -63
- package/lib/esm/domain/JsonEntityStore.js +40 -41
- package/lib/esm/domain/JsonMedia.js +27 -6
- package/lib/esm/domain/JsonMethodStore.js +28 -9
- package/lib/esm/domain/JsonOperation.js +15 -0
- package/lib/esm/domain/JsonParameter.js +11 -10
- package/lib/esm/domain/JsonParameterStore.js +3 -9
- package/lib/esm/domain/JsonPropertyStore.js +14 -45
- package/lib/esm/domain/JsonSchema.js +287 -80
- package/lib/esm/fn/email.js +2 -2
- package/lib/esm/fn/uri.js +2 -2
- package/lib/esm/fn/url.js +2 -2
- package/lib/esm/index.js +3 -8
- package/lib/esm/utils/generics.js +3 -32
- package/lib/esm/utils/getJsonSchema.js +24 -17
- package/lib/esm/utils/mergeSchema.js +98 -0
- package/lib/esm/utils/ref.js +14 -13
- package/lib/types/components/default/classMapper.d.ts +1 -1
- package/lib/types/components/default/genericsMapper.d.ts +9 -2
- package/lib/types/components/default/lazyRefMapper.d.ts +1 -1
- package/lib/types/components/default/nextMapper.d.ts +5 -0
- package/lib/types/components/default/ofMapper.d.ts +1 -1
- package/lib/types/components/index.d.ts +1 -7
- package/lib/types/components/open-spec/nullableMapper.d.ts +2 -1
- package/lib/types/components/open-spec/operationInQueryMapper.d.ts +1 -1
- package/lib/types/constants/VendorKeys.d.ts +10 -0
- package/lib/types/decorators/collections/collectionOf.d.ts +1 -1
- package/lib/types/decorators/generics/genericOf.d.ts +3 -0
- package/lib/types/decorators/generics/generics.d.ts +2 -2
- package/lib/types/decorators/operations/returns.d.ts +11 -9
- package/lib/types/domain/JsonEntityStore.d.ts +20 -18
- package/lib/types/domain/JsonMedia.d.ts +4 -5
- package/lib/types/domain/JsonMethodStore.d.ts +9 -2
- package/lib/types/domain/JsonOperation.d.ts +1 -0
- package/lib/types/domain/JsonParameter.d.ts +2 -7
- package/lib/types/domain/JsonParameterStore.d.ts +0 -2
- package/lib/types/domain/JsonPropertyStore.d.ts +1 -20
- package/lib/types/domain/JsonSchema.d.ts +82 -39
- package/lib/types/index.d.ts +3 -8
- package/lib/types/interfaces/JsonSchemaOptions.d.ts +16 -2
- package/lib/types/utils/generics.d.ts +7 -48
- package/lib/types/utils/getJsonSchema.d.ts +2 -1
- package/lib/types/utils/mergeSchema.d.ts +2 -0
- package/lib/types/utils/ref.d.ts +4 -2
- package/package.json +11 -8
- package/lib/esm/components/async-api/channelsMapper.js +0 -57
- package/lib/esm/components/async-api/generate.js +0 -17
- package/lib/esm/components/async-api/messageMapper.js +0 -39
- package/lib/esm/components/async-api/payloadMapper.js +0 -47
- package/lib/esm/components/async-api/responseMapper.js +0 -53
- package/lib/esm/components/default/itemMapper.js +0 -5
- package/lib/esm/components/default/propertiesMapper.js +0 -20
- package/lib/esm/utils/somethingOf.js +0 -11
- package/lib/types/components/async-api/channelsMapper.d.ts +0 -2
- package/lib/types/components/async-api/generate.d.ts +0 -1
- package/lib/types/components/async-api/messageMapper.d.ts +0 -6
- package/lib/types/components/async-api/payloadMapper.d.ts +0 -4
- package/lib/types/components/async-api/responseMapper.d.ts +0 -6
- package/lib/types/components/default/itemMapper.d.ts +0 -2
- package/lib/types/components/default/propertiesMapper.d.ts +0 -3
- package/lib/types/utils/somethingOf.d.ts +0 -1
package/lib/esm/fn/url.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { JsonFormatTypes } from "../domain/JsonFormatTypes.js";
|
|
2
|
-
import {
|
|
2
|
+
import { string } from "./string.js";
|
|
3
3
|
/**
|
|
4
4
|
* Declare a new string model with `format: url`.
|
|
5
5
|
*
|
|
6
6
|
* See @@JsonSchema@@ to discover available methods.
|
|
7
7
|
*/
|
|
8
8
|
export function url() {
|
|
9
|
-
return
|
|
9
|
+
return string().format(JsonFormatTypes.URL);
|
|
10
10
|
}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Automatically generated by @tsed/barrels.
|
|
3
3
|
*/
|
|
4
|
-
export * from "./components/async-api/channelsMapper.js";
|
|
5
|
-
export * from "./components/async-api/generate.js";
|
|
6
|
-
export * from "./components/async-api/messageMapper.js";
|
|
7
|
-
export * from "./components/async-api/payloadMapper.js";
|
|
8
|
-
export * from "./components/async-api/responseMapper.js";
|
|
9
4
|
export * from "./components/default/anyMapper.js";
|
|
10
5
|
export * from "./components/default/classMapper.js";
|
|
11
6
|
export * from "./components/default/discriminatorMappingMapper.js";
|
|
12
7
|
export * from "./components/default/enumsMapper.js";
|
|
13
8
|
export * from "./components/default/genericsMapper.js";
|
|
14
9
|
export * from "./components/default/inheritedClassMapper.js";
|
|
15
|
-
export * from "./components/default/itemMapper.js";
|
|
16
10
|
export * from "./components/default/lazyRefMapper.js";
|
|
17
11
|
export * from "./components/default/mapMapper.js";
|
|
12
|
+
export * from "./components/default/nextMapper.js";
|
|
18
13
|
export * from "./components/default/nullableMapper.js";
|
|
19
14
|
export * from "./components/default/objectMapper.js";
|
|
20
15
|
export * from "./components/default/ofMapper.js";
|
|
21
|
-
export * from "./components/default/propertiesMapper.js";
|
|
22
16
|
export * from "./components/default/requiredMapper.js";
|
|
23
17
|
export * from "./components/default/schemaMapper.js";
|
|
24
18
|
export * from "./components/index.js";
|
|
@@ -38,6 +32,7 @@ export * from "./components/open-spec/pathsMapper.js";
|
|
|
38
32
|
export * from "./constants/httpStatusMessages.js";
|
|
39
33
|
export * from "./constants/jsonSchemaProperties.js";
|
|
40
34
|
export * from "./constants/OperationVerbs.js";
|
|
35
|
+
export * from "./constants/VendorKeys.js";
|
|
41
36
|
export * from "./decorators/class/children.js";
|
|
42
37
|
export * from "./decorators/class/discriminatorValue.js";
|
|
43
38
|
export * from "./decorators/collections/collectionContains.js";
|
|
@@ -190,12 +185,12 @@ export * from "./utils/mapOpenSpec3.js";
|
|
|
190
185
|
export * from "./utils/mapOpenSpecInfo.js";
|
|
191
186
|
export * from "./utils/mapOperationOptions.js";
|
|
192
187
|
export * from "./utils/matchGroups.js";
|
|
188
|
+
export * from "./utils/mergeSchema.js";
|
|
193
189
|
export * from "./utils/mergeSpec.js";
|
|
194
190
|
export * from "./utils/operationIdFormatter.js";
|
|
195
191
|
export * from "./utils/ref.js";
|
|
196
192
|
export * from "./utils/removeHiddenOperation.js";
|
|
197
193
|
export * from "./utils/serializeEnumValues.js";
|
|
198
|
-
export * from "./utils/somethingOf.js";
|
|
199
194
|
export * from "./utils/toJsonMapCollection.js";
|
|
200
195
|
export * from "./utils/toJsonRegex.js";
|
|
201
196
|
export * from "./utils/transformToOS2.js";
|
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @param genericTypes
|
|
5
|
-
*/
|
|
6
|
-
export function getGenericsMap(genericLabels, genericTypes) {
|
|
7
|
-
return genericLabels.reduce((map, item, index) => map.set(item, genericTypes[index]), new Map());
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* @ignore
|
|
11
|
-
* @param options
|
|
12
|
-
*/
|
|
13
|
-
export function mapGenericsOptions(options) {
|
|
14
|
-
if (options.genericLabels && options.genericTypes) {
|
|
15
|
-
const { genericLabels, genericTypes, ...ops } = options;
|
|
16
|
-
return {
|
|
17
|
-
...ops,
|
|
18
|
-
generics: getGenericsMap(genericLabels, genericTypes)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return options;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @ignore
|
|
25
|
-
* @param value
|
|
26
|
-
*/
|
|
27
|
-
export function popGenerics(value) {
|
|
28
|
-
const [genericTypes, ...out] = value.nestedGenerics;
|
|
29
|
-
return {
|
|
30
|
-
genericTypes,
|
|
31
|
-
nestedGenerics: out
|
|
32
|
-
};
|
|
1
|
+
export function getGenericsOptions(value, options) {
|
|
2
|
+
const generics = value.getGenericOf();
|
|
3
|
+
return { generics: generics || options.generics, mapper: generics ? "schema" : "class" };
|
|
33
4
|
}
|
|
@@ -1,36 +1,51 @@
|
|
|
1
1
|
import "../components/index.js";
|
|
2
|
-
import { getValue } from "@tsed/core";
|
|
2
|
+
import { getValue, isClass, isPlainObject, nameOf } from "@tsed/core";
|
|
3
|
+
import { JsonParameterStore } from "../domain/JsonParameterStore.js";
|
|
3
4
|
import { SpecTypes } from "../domain/SpecTypes.js";
|
|
4
5
|
import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
5
6
|
import { getJsonEntityStore } from "./getJsonEntityStore.js";
|
|
6
7
|
/**
|
|
7
8
|
* @ignore
|
|
8
9
|
*/
|
|
9
|
-
const
|
|
10
|
+
const CACHES = new Map();
|
|
10
11
|
/**
|
|
11
12
|
* @ignore
|
|
12
13
|
*/
|
|
13
14
|
function getKey(options) {
|
|
14
|
-
return JSON.stringify(options)
|
|
15
|
+
return JSON.stringify(options, (key, value) => {
|
|
16
|
+
if (value && !isPlainObject(value) && isClass(value)) {
|
|
17
|
+
return nameOf(value);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
});
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
23
|
* @ignore
|
|
18
24
|
*/
|
|
19
|
-
function get(
|
|
20
|
-
const cache =
|
|
25
|
+
function get(model, options) {
|
|
26
|
+
const cache = CACHES.get(model) || new Map();
|
|
27
|
+
CACHES.set(model, cache);
|
|
21
28
|
const key = getKey(options);
|
|
22
29
|
if (!cache.has(key)) {
|
|
23
|
-
const
|
|
30
|
+
const entity = getJsonEntityStore(model);
|
|
31
|
+
let mapper = "schema";
|
|
32
|
+
if (entity instanceof JsonParameterStore) {
|
|
33
|
+
options = {
|
|
34
|
+
...options,
|
|
35
|
+
root: true,
|
|
36
|
+
groups: entity.schema.getGroups()
|
|
37
|
+
};
|
|
38
|
+
mapper = "item";
|
|
39
|
+
}
|
|
40
|
+
const schema = execMapper(mapper, [entity.schema], options);
|
|
24
41
|
if (Object.keys(getValue(options, "components.schemas", {})).length) {
|
|
25
42
|
schema.definitions = options.components.schemas;
|
|
26
43
|
}
|
|
27
44
|
cache.set(key, schema);
|
|
28
45
|
}
|
|
29
|
-
entity.store.set(CACHE_KEY, cache);
|
|
30
46
|
return cache.get(key);
|
|
31
47
|
}
|
|
32
48
|
export function getJsonSchema(model, options = {}) {
|
|
33
|
-
const entity = getJsonEntityStore(model);
|
|
34
49
|
const specType = options.specType || SpecTypes.JSON;
|
|
35
50
|
options = {
|
|
36
51
|
endpoint: true,
|
|
@@ -42,13 +57,5 @@ export function getJsonSchema(model, options = {}) {
|
|
|
42
57
|
schemas: {}
|
|
43
58
|
}
|
|
44
59
|
};
|
|
45
|
-
|
|
46
|
-
options = {
|
|
47
|
-
...options,
|
|
48
|
-
genericTypes: entity.nestedGenerics[0],
|
|
49
|
-
nestedGenerics: entity.nestedGenerics,
|
|
50
|
-
groups: entity.parameter?.groups
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return get(entity, options);
|
|
60
|
+
return get(model, options);
|
|
54
61
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isObject, uniq } from "@tsed/core";
|
|
2
|
+
function mergeProps(properties1, properties2) {
|
|
3
|
+
if (!properties1 || !properties2) {
|
|
4
|
+
return properties1 || properties2 || {};
|
|
5
|
+
}
|
|
6
|
+
const keys = [...new Set(Object.keys(properties1 || []).concat(Object.keys(properties2 || [])))];
|
|
7
|
+
return keys.reduce((acc, key) => {
|
|
8
|
+
if (properties1?.[key] && properties2?.[key]) {
|
|
9
|
+
acc[key] = mergeSchema(properties1[key], properties2[key]);
|
|
10
|
+
}
|
|
11
|
+
else if (properties1?.[key]) {
|
|
12
|
+
acc[key] = properties1[key];
|
|
13
|
+
}
|
|
14
|
+
else if (properties2?.[key]) {
|
|
15
|
+
acc[key] = properties2[key];
|
|
16
|
+
}
|
|
17
|
+
return acc;
|
|
18
|
+
}, {});
|
|
19
|
+
}
|
|
20
|
+
function mergeManyOf(kind, schema1, schema2) {
|
|
21
|
+
const refs = new Set();
|
|
22
|
+
if (schema1.$ref && schema2.type && (schema2.readOnly || schema2.writeOnly) && kind === "allOf") {
|
|
23
|
+
const { type, ...rest } = schema2;
|
|
24
|
+
schema2 = rest;
|
|
25
|
+
}
|
|
26
|
+
let of = [...(schema1[kind] || [schema1]), ...(schema2[kind] || [schema2])].filter((schema) => {
|
|
27
|
+
if ("$ref" in schema) {
|
|
28
|
+
if (refs.has(schema.$ref)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
refs.add(schema.$ref);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return Object.keys(schema).length > 0;
|
|
35
|
+
});
|
|
36
|
+
if (of.length > 2) {
|
|
37
|
+
of = of.reduce((current, item, index) => {
|
|
38
|
+
if (item.$ref) {
|
|
39
|
+
return current.concat(item);
|
|
40
|
+
}
|
|
41
|
+
if (current.at(-1)?.type === item.type && item.type !== "array") {
|
|
42
|
+
current[current.length - 1] = mergeSchema(current.at(-1), item);
|
|
43
|
+
return current;
|
|
44
|
+
}
|
|
45
|
+
return current.concat(item);
|
|
46
|
+
}, []);
|
|
47
|
+
}
|
|
48
|
+
return of.length > 1
|
|
49
|
+
? {
|
|
50
|
+
[kind]: of,
|
|
51
|
+
...(schema1.nullable || schema2.nullable ? { nullable: true } : {})
|
|
52
|
+
}
|
|
53
|
+
: of[0];
|
|
54
|
+
}
|
|
55
|
+
export function mergeSchema(schema1, schema2) {
|
|
56
|
+
if (schema1.$ref && schema2.$ref && schema1.$ref === schema2.$ref) {
|
|
57
|
+
return schema1; // If both refs are the same, return one of them
|
|
58
|
+
}
|
|
59
|
+
// Handle allOf, oneOf, anyOf
|
|
60
|
+
if (schema1.allOf || schema2.allOf) {
|
|
61
|
+
return mergeManyOf("allOf", schema1, schema2);
|
|
62
|
+
}
|
|
63
|
+
if (schema1.oneOf || schema2.oneOf) {
|
|
64
|
+
const schema = mergeManyOf("oneOf", schema1, schema2);
|
|
65
|
+
if ("discriminator" in schema1 || "discriminator" in schema2) {
|
|
66
|
+
// If either schema has a discriminator, we should not merge oneOf
|
|
67
|
+
return {
|
|
68
|
+
...schema,
|
|
69
|
+
discriminator: schema1.discriminator || schema2.discriminator,
|
|
70
|
+
required: uniq([...(schema1.required || []), ...(schema2.required || [])])
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return schema;
|
|
74
|
+
}
|
|
75
|
+
if (schema1.anyOf || schema2.anyOf) {
|
|
76
|
+
return mergeManyOf("anyOf", schema1, schema2);
|
|
77
|
+
}
|
|
78
|
+
if (schema1.$ref || schema2.$ref) {
|
|
79
|
+
return mergeManyOf("allOf", schema1, schema2);
|
|
80
|
+
}
|
|
81
|
+
const mergedSchema = { ...schema1, ...schema2 };
|
|
82
|
+
if (schema1.properties || schema2.properties) {
|
|
83
|
+
// Handle properties
|
|
84
|
+
mergedSchema.properties = mergeProps(schema1.properties, schema2.properties);
|
|
85
|
+
}
|
|
86
|
+
if (isObject(schema1.additionalProperties) && isObject(schema2.additionalProperties)) {
|
|
87
|
+
// Right now we only merge additionalProperties if both schemas have it as an object
|
|
88
|
+
mergedSchema.additionalProperties = {
|
|
89
|
+
...schema1.additionalProperties,
|
|
90
|
+
...schema2.additionalProperties
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (schema1.required || schema2.required) {
|
|
94
|
+
// Handle required fields
|
|
95
|
+
mergedSchema.required = uniq([...(schema1.required || []), ...(schema2.required || [])]);
|
|
96
|
+
}
|
|
97
|
+
return mergedSchema;
|
|
98
|
+
}
|
package/lib/esm/utils/ref.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setValue } from "@tsed/core";
|
|
2
2
|
import { pascalCase } from "change-case";
|
|
3
3
|
import { SpecTypes } from "../domain/SpecTypes.js";
|
|
4
|
+
import { mergeSchema } from "./mergeSchema.js";
|
|
5
|
+
export function getSchemaFromRef($ref, options) {
|
|
6
|
+
const { components } = options;
|
|
7
|
+
if (components?.schemas && $ref) {
|
|
8
|
+
const host = getHost(options);
|
|
9
|
+
const refName = $ref.replace(`${host}/`, "");
|
|
10
|
+
return components.schemas[refName];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* ignore
|
|
6
15
|
* @param options
|
|
@@ -23,19 +32,11 @@ export function createRefName(name, options) {
|
|
|
23
32
|
*/
|
|
24
33
|
export function createRef(name, schema, options) {
|
|
25
34
|
const host = getHost(options);
|
|
26
|
-
|
|
35
|
+
return mergeSchema({
|
|
27
36
|
$ref: `${host}/${name}`
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return cleanObject({
|
|
32
|
-
readOnly: readOnly ? true : undefined,
|
|
33
|
-
writeOnly: writeOnly ? true : undefined,
|
|
34
|
-
...(readOnly || writeOnly
|
|
35
|
-
? {
|
|
36
|
-
anyOf: [ref]
|
|
37
|
-
}
|
|
38
|
-
: ref)
|
|
37
|
+
}, {
|
|
38
|
+
...(schema.isReadOnly ? { readOnly: true } : {}),
|
|
39
|
+
...(schema.isWriteOnly ? { writeOnly: true } : {})
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
2
2
|
import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
3
|
-
export declare function classMapper(value: JsonSchema, options: JsonSchemaOptions):
|
|
3
|
+
export declare function classMapper(value: JsonSchema, options: JsonSchemaOptions): import("json-schema").JSONSchema7;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { JSONSchema7 } from "json-schema";
|
|
2
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
3
|
+
import type { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
2
4
|
/**
|
|
3
5
|
* @ignore
|
|
4
6
|
*/
|
|
5
|
-
export declare function genericsMapper(
|
|
7
|
+
export declare function genericsMapper(baseObj: JSONSchema7, schema: JsonSchema, options: JsonSchemaOptions): JSONSchema7 | {
|
|
8
|
+
allOf: (JSONSchema7 | {
|
|
9
|
+
properties: JSONSchema7;
|
|
10
|
+
type: string;
|
|
11
|
+
})[];
|
|
12
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonLazyRef } from "../../domain/JsonLazyRef.js";
|
|
2
2
|
import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
3
|
-
export declare function lazyRefMapper(jsonLazyRef: JsonLazyRef, options: JsonSchemaOptions):
|
|
3
|
+
export declare function lazyRefMapper(jsonLazyRef: JsonLazyRef, options: JsonSchemaOptions): import("json-schema").JSONSchema7;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Type } from "@tsed/core";
|
|
2
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
3
|
+
import type { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
4
|
+
export declare function itemMapper(input: JsonSchema | Type, options: JsonSchemaOptions): any;
|
|
5
|
+
export declare function nextMapper(input: JsonSchema | Type | any, options: JsonSchemaOptions): any;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { JsonSchema } from "../../domain/JsonSchema.js";
|
|
2
2
|
import type { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
3
|
-
export declare function ofMapper(input: (any | JsonSchema)[], options: JsonSchemaOptions
|
|
3
|
+
export declare function ofMapper(input: (any | JsonSchema)[], options: JsonSchemaOptions): any[];
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Automatically generated by @tsed/barrels.
|
|
3
3
|
*/
|
|
4
|
-
export * from "./async-api/channelsMapper.js";
|
|
5
|
-
export * from "./async-api/generate.js";
|
|
6
|
-
export * from "./async-api/messageMapper.js";
|
|
7
|
-
export * from "./async-api/payloadMapper.js";
|
|
8
|
-
export * from "./async-api/responseMapper.js";
|
|
9
4
|
export * from "./default/anyMapper.js";
|
|
10
5
|
export * from "./default/classMapper.js";
|
|
11
6
|
export * from "./default/discriminatorMappingMapper.js";
|
|
12
7
|
export * from "./default/enumsMapper.js";
|
|
13
8
|
export * from "./default/genericsMapper.js";
|
|
14
9
|
export * from "./default/inheritedClassMapper.js";
|
|
15
|
-
export * from "./default/itemMapper.js";
|
|
16
10
|
export * from "./default/lazyRefMapper.js";
|
|
17
11
|
export * from "./default/mapMapper.js";
|
|
12
|
+
export * from "./default/nextMapper.js";
|
|
18
13
|
export * from "./default/nullableMapper.js";
|
|
19
14
|
export * from "./default/objectMapper.js";
|
|
20
15
|
export * from "./default/ofMapper.js";
|
|
21
|
-
export * from "./default/propertiesMapper.js";
|
|
22
16
|
export * from "./default/requiredMapper.js";
|
|
23
17
|
export * from "./default/schemaMapper.js";
|
|
24
18
|
export * from "./open-spec/discriminatorMappingMapper.js";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { JsonSchema } from "../../domain/JsonSchema.js";
|
|
2
|
-
|
|
2
|
+
import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
3
|
+
export declare function nullableMapperOpenApi(obj: any, schema: JsonSchema | null, options: JsonSchemaOptions): any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { JsonParameterOptions } from "./operationInParameterMapper.js";
|
|
2
|
-
export declare function operationInQueryMapper(parameter: any, { jsonSchema,
|
|
2
|
+
export declare function operationInQueryMapper(parameter: any, { jsonSchema, ...options }: JsonParameterOptions): any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum VendorKeys {
|
|
2
|
+
GENERIC_LABELS = "genericLabels",
|
|
3
|
+
GENERIC_LABEL = "genericLabel",
|
|
4
|
+
GENERIC_OF = "genericOf",
|
|
5
|
+
NULLABLE = "nullable",
|
|
6
|
+
FORWARD_GROUPS = "forwardGroups",
|
|
7
|
+
GROUPS = "groups",
|
|
8
|
+
GROUPS_NAME = "groupsName",
|
|
9
|
+
ALLOWED_GROUPS = "allowedGroups"
|
|
10
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface ArrayOfChainedDecorators {
|
|
2
2
|
(...args: any): any;
|
|
3
|
+
Nested(...generics: any[]): this;
|
|
3
4
|
/**
|
|
4
5
|
* An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.
|
|
5
6
|
*
|
|
@@ -28,7 +29,6 @@ export interface ArrayOfChainedDecorators {
|
|
|
28
29
|
* Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
|
|
29
30
|
*
|
|
30
31
|
* 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.
|
|
32
32
|
*/
|
|
33
33
|
Contains(): this;
|
|
34
34
|
/**
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* See @@GenericOf@@ decorator for more details.
|
|
5
5
|
*
|
|
6
|
-
* @param generics
|
|
7
6
|
* @decorator
|
|
8
7
|
* @validation
|
|
9
8
|
* @swagger
|
|
10
9
|
* @schema
|
|
11
10
|
* @input
|
|
12
11
|
* @generics
|
|
12
|
+
* @param genericLabels
|
|
13
13
|
*/
|
|
14
|
-
export declare function Generics(...
|
|
14
|
+
export declare function Generics(...genericLabels: string[]): ClassDecorator;
|
|
@@ -88,8 +88,10 @@ export interface ReturnsChainedDecorators {
|
|
|
88
88
|
/**
|
|
89
89
|
* Add an inline title for the return model.
|
|
90
90
|
* @param title
|
|
91
|
+
* @deprecated use Label instead
|
|
91
92
|
*/
|
|
92
93
|
Title(title: string): this;
|
|
94
|
+
Label(label: string): this;
|
|
93
95
|
/**
|
|
94
96
|
* Use group to filter model
|
|
95
97
|
* @param groups
|
|
@@ -170,7 +172,7 @@ export interface ReturnsChainedDecorators {
|
|
|
170
172
|
*
|
|
171
173
|
* Deprecated version:
|
|
172
174
|
*
|
|
173
|
-
* ```
|
|
175
|
+
* ```ts
|
|
174
176
|
* import {ReturnsArray} from "@tsed/platform-http";
|
|
175
177
|
* import {Returns} from "@tsed/schema";
|
|
176
178
|
*
|
|
@@ -183,14 +185,14 @@ export interface ReturnsChainedDecorators {
|
|
|
183
185
|
*
|
|
184
186
|
* ### Declaring a generic model <Badge text="6+"/>
|
|
185
187
|
*
|
|
186
|
-
*
|
|
188
|
+
* Sometimes, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to
|
|
187
189
|
* declare explicitly the generic models with the decorators.
|
|
188
190
|
*
|
|
189
|
-
* One of the generic's usage
|
|
191
|
+
* One of the generic's usage can be a paginated list. With Returns decorator it's now possible to declare a generic type and generate the appropriate OpenSpec documentation.
|
|
190
192
|
*
|
|
191
193
|
* Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:
|
|
192
194
|
*
|
|
193
|
-
* ```
|
|
195
|
+
* ```ts
|
|
194
196
|
* @Generics("T")
|
|
195
197
|
* class Pagination<T> {
|
|
196
198
|
* @CollectionOf("T")
|
|
@@ -213,7 +215,7 @@ export interface ReturnsChainedDecorators {
|
|
|
213
215
|
* }
|
|
214
216
|
* ```
|
|
215
217
|
*
|
|
216
|
-
* Finally, we can use our models on a method as
|
|
218
|
+
* Finally, we can use our models on a method as follows:
|
|
217
219
|
*
|
|
218
220
|
* ```typescript
|
|
219
221
|
* class Controller {
|
|
@@ -225,11 +227,11 @@ export interface ReturnsChainedDecorators {
|
|
|
225
227
|
* }
|
|
226
228
|
* ```
|
|
227
229
|
*
|
|
228
|
-
* ### Declaring
|
|
230
|
+
* ### Declaring nested generics models <Badge text="6+"/>
|
|
229
231
|
*
|
|
230
|
-
* It's also possible to declare a nested generics
|
|
232
|
+
* It's also possible to declare a nested generics model to have this type `Pagination<Submission<Product>>`:
|
|
231
233
|
*
|
|
232
|
-
* ```
|
|
234
|
+
* ```ts
|
|
233
235
|
* import {Post, Generics, Property, Returns} from "@tsed/schema";
|
|
234
236
|
*
|
|
235
237
|
* class Controller {
|
|
@@ -243,7 +245,7 @@ export interface ReturnsChainedDecorators {
|
|
|
243
245
|
*
|
|
244
246
|
* And here is the Submission model:
|
|
245
247
|
*
|
|
246
|
-
* ```
|
|
248
|
+
* ```ts
|
|
247
249
|
* import {Generics, Property} from "@tsed/schema";
|
|
248
250
|
*
|
|
249
251
|
* @Generics("T")
|
|
@@ -51,16 +51,26 @@ export declare abstract class JsonEntityStore implements JsonEntityStoreOptions
|
|
|
51
51
|
readonly isStore = true;
|
|
52
52
|
readonly parent: JsonEntityStore;
|
|
53
53
|
readonly target: Type<any>;
|
|
54
|
+
constructor(options: JsonEntityStoreOptions);
|
|
54
55
|
/**
|
|
55
56
|
*
|
|
56
57
|
*/
|
|
57
58
|
protected _type: Type<any>;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
get type(): Type<any> | any;
|
|
61
|
+
/**
|
|
62
|
+
* Get original type without transformation
|
|
63
|
+
* @param value
|
|
64
|
+
*/
|
|
65
|
+
set type(value: Type<any> | any);
|
|
58
66
|
/**
|
|
59
67
|
* Ref to JsonSchema
|
|
60
68
|
*/
|
|
61
69
|
protected _schema: JsonSchema;
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Return the JsonSchema
|
|
72
|
+
*/
|
|
73
|
+
get schema(): JsonSchema;
|
|
64
74
|
/**
|
|
65
75
|
* Return the class name of the entity.
|
|
66
76
|
* @returns {string}
|
|
@@ -73,26 +83,16 @@ export declare abstract class JsonEntityStore implements JsonEntityStoreOptions
|
|
|
73
83
|
get isDate(): boolean;
|
|
74
84
|
get isObject(): boolean;
|
|
75
85
|
get isClass(): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Return the JsonSchema
|
|
78
|
-
*/
|
|
79
|
-
get schema(): JsonSchema;
|
|
80
|
-
get nestedGenerics(): Type<any>[][];
|
|
81
|
-
set nestedGenerics(nestedGenerics: Type<any>[][]);
|
|
82
|
-
get type(): Type<any> | any;
|
|
83
|
-
/**
|
|
84
|
-
* Get original type without transformation
|
|
85
|
-
* @param value
|
|
86
|
-
*/
|
|
87
|
-
set type(value: Type<any> | any);
|
|
88
86
|
/**
|
|
89
87
|
* Return the itemSchema computed type. if the type is a function used for recursive model, the function will be called to
|
|
90
88
|
* get the right type.
|
|
91
89
|
*/
|
|
92
|
-
get computedType(): any
|
|
90
|
+
get computedType(): Type<any>;
|
|
93
91
|
get itemSchema(): JsonSchema;
|
|
94
92
|
get parentSchema(): JsonSchema;
|
|
95
93
|
get isDiscriminatorChild(): boolean;
|
|
94
|
+
get path(): string;
|
|
95
|
+
set path(path: string);
|
|
96
96
|
static from<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;
|
|
97
97
|
static from<T extends JsonPropertyStore = JsonPropertyStore>(target: Type<any> | any, propertyKey: string | symbol): T;
|
|
98
98
|
static from<T extends JsonParameterStore = JsonParameterStore>(target: Type<any> | any, propertyKey: string | symbol, index: number): T;
|
|
@@ -104,9 +104,11 @@ export declare abstract class JsonEntityStore implements JsonEntityStoreOptions
|
|
|
104
104
|
get<T = any>(key: string, defaultValue?: any): T;
|
|
105
105
|
set(key: string, value?: any): Store;
|
|
106
106
|
toString(): string;
|
|
107
|
+
getBestType(): any;
|
|
108
|
+
is(input: DecoratorTypes.CLASS): this is JsonClassStore;
|
|
109
|
+
is(input: DecoratorTypes.PROP): this is JsonPropertyStore;
|
|
110
|
+
is(input: DecoratorTypes.METHOD): this is JsonMethodStore;
|
|
111
|
+
is(input: DecoratorTypes.PARAM): this is JsonParameterStore;
|
|
107
112
|
protected abstract build(): void;
|
|
108
113
|
protected buildType(type: any): void;
|
|
109
|
-
set path(path: string);
|
|
110
|
-
get path(): string;
|
|
111
|
-
getBestType(): any;
|
|
112
114
|
}
|
|
@@ -3,9 +3,8 @@ import { JsonMap } from "./JsonMap.js";
|
|
|
3
3
|
import { JsonSchema } from "./JsonSchema.js";
|
|
4
4
|
export declare class JsonMedia extends JsonMap<OS3MediaType<JsonSchema>> {
|
|
5
5
|
$kind: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
examples(examples: any): this;
|
|
6
|
+
constructor(obj?: Partial<OS3MediaType<JsonSchema>>);
|
|
7
|
+
schema(schema?: JsonSchema): JsonSchema;
|
|
8
|
+
examples(examples?: any): this;
|
|
9
|
+
type(type: any): this;
|
|
11
10
|
}
|
|
@@ -39,6 +39,12 @@ export declare class JsonMethodStore extends JsonEntityStore {
|
|
|
39
39
|
* @param descriptor
|
|
40
40
|
*/
|
|
41
41
|
static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): JsonMethodStore;
|
|
42
|
+
/**
|
|
43
|
+
* TODO must be located on JsonOperation level directly
|
|
44
|
+
* @param status
|
|
45
|
+
* @param contentType
|
|
46
|
+
* @param includes
|
|
47
|
+
*/
|
|
42
48
|
getResponseOptions(status: number, { contentType, includes }?: {
|
|
43
49
|
contentType?: string;
|
|
44
50
|
includes?: string[];
|
|
@@ -73,10 +79,11 @@ export declare class JsonMethodStore extends JsonEntityStore {
|
|
|
73
79
|
/**
|
|
74
80
|
* EndpointMetadata contains metadata about a controller and his method.
|
|
75
81
|
* Each annotation (@Get, @Body...) attached to a method are stored into endpoint.
|
|
76
|
-
* EndpointMetadata
|
|
82
|
+
* EndpointMetadata converts this metadata to an array which contain arguments to call an Express method.
|
|
77
83
|
*
|
|
78
84
|
* Example :
|
|
79
|
-
|
|
85
|
+
*
|
|
86
|
+
*```ts
|
|
80
87
|
* @Controller("/my-path")
|
|
81
88
|
* provide MyClass {
|
|
82
89
|
*
|
|
@@ -43,6 +43,7 @@ export declare class JsonOperation extends JsonMap<JsonOperationOptions> {
|
|
|
43
43
|
addSecurityScopes(name: string, scopes: string[]): this;
|
|
44
44
|
description(description: string): this;
|
|
45
45
|
deprecated(deprecated: boolean): this;
|
|
46
|
+
addAllowedGroupsParameter(allowedGroups: string[]): this;
|
|
46
47
|
parameters(parameters: JsonParameter[]): this;
|
|
47
48
|
addParameter(index: number, parameter: JsonParameter): void;
|
|
48
49
|
consumes(consumes: string[]): this;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
1
|
import { OpenSpecHash, OpenSpecRef, OS3Example, OS3Parameter } from "@tsed/openspec";
|
|
3
2
|
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions.js";
|
|
4
|
-
import { NestedGenerics } from "../utils/generics.js";
|
|
5
3
|
import { JsonMap } from "./JsonMap.js";
|
|
6
4
|
import { JsonSchema } from "./JsonSchema.js";
|
|
7
|
-
export declare class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>>
|
|
5
|
+
export declare class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> {
|
|
8
6
|
$kind: string;
|
|
9
|
-
nestedGenerics: Type<any>[][];
|
|
10
|
-
groups: string[];
|
|
11
|
-
groupsName: string;
|
|
12
|
-
$schema: JsonSchema;
|
|
13
7
|
expression: string;
|
|
8
|
+
constructor(obj?: Partial<OS3Parameter<JsonSchema>>);
|
|
14
9
|
getName(): any;
|
|
15
10
|
name(name: string): this;
|
|
16
11
|
examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>): this;
|