@tsed/schema 8.13.5 → 8.14.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/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 +7 -7
- 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
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { setValue } from "@tsed/core";
|
|
2
|
-
import { pascalCase } from "change-case";
|
|
3
|
-
import { SpecTypes } from "../../domain/SpecTypes.js";
|
|
4
|
-
import { execMapper, registerJsonSchemaMapper } from "../../registries/JsonSchemaMapperContainer.js";
|
|
5
|
-
import { makeOf } from "../../utils/somethingOf.js";
|
|
6
|
-
export function responsePayloadMapper(jsonOperationStore, operationPath, options) {
|
|
7
|
-
const responses = jsonOperationStore.operation.getResponses();
|
|
8
|
-
const statuses = [];
|
|
9
|
-
const statusesTexts = [];
|
|
10
|
-
const successSchemes = [];
|
|
11
|
-
const errorSchemes = [];
|
|
12
|
-
[...responses.entries()].forEach(([status, jsonResponse]) => {
|
|
13
|
-
const response = execMapper("map", [jsonResponse], options);
|
|
14
|
-
statuses.push(+status);
|
|
15
|
-
statusesTexts.push(response.description);
|
|
16
|
-
if (+status !== 204) {
|
|
17
|
-
const { content } = response;
|
|
18
|
-
const schema = content[Object.keys(content)[0]];
|
|
19
|
-
if (+status >= 200 && +status < 400) {
|
|
20
|
-
successSchemes.push(schema);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
successSchemes.push(schema);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const responsePayloadName = pascalCase([operationPath.path, operationPath.method, "Response"].join(" "));
|
|
28
|
-
const responsePayload = {
|
|
29
|
-
type: "object",
|
|
30
|
-
properties: {
|
|
31
|
-
status: {
|
|
32
|
-
type: "number",
|
|
33
|
-
enum: statuses
|
|
34
|
-
},
|
|
35
|
-
statusText: {
|
|
36
|
-
type: "string",
|
|
37
|
-
enum: statusesTexts
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
required: ["status"]
|
|
41
|
-
};
|
|
42
|
-
const dataSchema = makeOf("oneOf", successSchemes);
|
|
43
|
-
if (dataSchema) {
|
|
44
|
-
setValue(responsePayload, "properties.data", dataSchema);
|
|
45
|
-
}
|
|
46
|
-
const errorSchema = makeOf("oneOf", errorSchemes);
|
|
47
|
-
if (errorSchemes.length) {
|
|
48
|
-
setValue(responsePayload, "properties.error", errorSchema);
|
|
49
|
-
}
|
|
50
|
-
setValue(options, `components.schemas.${responsePayloadName}`, responsePayload);
|
|
51
|
-
return { $ref: `#/components/schemas/${responsePayloadName}` };
|
|
52
|
-
}
|
|
53
|
-
registerJsonSchemaMapper("response", responsePayloadMapper, SpecTypes.ASYNCAPI);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { execMapper, registerJsonSchemaMapper } from "../../registries/JsonSchemaMapperContainer.js";
|
|
2
|
-
export function itemMapper(value, options) {
|
|
3
|
-
return value && value.isClass ? execMapper("class", [value], options) : execMapper("any", [value], options);
|
|
4
|
-
}
|
|
5
|
-
registerJsonSchemaMapper("item", itemMapper);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { execMapper, registerJsonSchemaMapper } from "../../registries/JsonSchemaMapperContainer.js";
|
|
2
|
-
export function propertiesMapper(input, options, parent) {
|
|
3
|
-
if (input.isClass) {
|
|
4
|
-
return execMapper("class", [input], options);
|
|
5
|
-
}
|
|
6
|
-
return execMapper("any", [input], {
|
|
7
|
-
...options,
|
|
8
|
-
genericLabels: parent.genericLabels
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
registerJsonSchemaMapper("properties", propertiesMapper);
|
|
12
|
-
registerJsonSchemaMapper("items", propertiesMapper);
|
|
13
|
-
registerJsonSchemaMapper("additionalProperties", propertiesMapper);
|
|
14
|
-
registerJsonSchemaMapper("propertyNames", propertiesMapper);
|
|
15
|
-
registerJsonSchemaMapper("contains", propertiesMapper);
|
|
16
|
-
registerJsonSchemaMapper("dependencies", propertiesMapper);
|
|
17
|
-
registerJsonSchemaMapper("patternProperties", propertiesMapper);
|
|
18
|
-
registerJsonSchemaMapper("additionalItems", propertiesMapper);
|
|
19
|
-
registerJsonSchemaMapper("not", propertiesMapper);
|
|
20
|
-
registerJsonSchemaMapper("definitions", propertiesMapper);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { JsonMethodStore } from "../../domain/JsonMethodStore.js";
|
|
2
|
-
import { JsonMethodPath } from "../../domain/JsonOperation.js";
|
|
3
|
-
import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
4
|
-
export declare function messageMapper(jsonOperationStore: JsonMethodStore, operationPath: JsonMethodPath, { tags, defaultTags, ...options }?: JsonSchemaOptions): {
|
|
5
|
-
$ref: string;
|
|
6
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { JsonMethodStore } from "../../domain/JsonMethodStore.js";
|
|
2
|
-
import { JsonMethodPath } from "../../domain/JsonOperation.js";
|
|
3
|
-
import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
4
|
-
export declare function payloadMapper(jsonOperationStore: JsonMethodStore, operationPath: JsonMethodPath, options: JsonSchemaOptions): unknown;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { JsonMethodStore } from "../../domain/JsonMethodStore.js";
|
|
2
|
-
import { JsonMethodPath } from "../../domain/JsonOperation.js";
|
|
3
|
-
import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
|
|
4
|
-
export declare function responsePayloadMapper(jsonOperationStore: JsonMethodStore, operationPath: JsonMethodPath, options: JsonSchemaOptions): {
|
|
5
|
-
$ref: string;
|
|
6
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function makeOf(key: string, schemes: unknown[]): unknown;
|