@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.
Files changed (87) hide show
  1. package/lib/esm/components/default/anyMapper.js +1 -2
  2. package/lib/esm/components/default/classMapper.js +2 -22
  3. package/lib/esm/components/default/genericsMapper.js +62 -48
  4. package/lib/esm/components/default/lazyRefMapper.js +1 -2
  5. package/lib/esm/components/default/mapMapper.js +0 -2
  6. package/lib/esm/components/default/nextMapper.js +74 -0
  7. package/lib/esm/components/default/objectMapper.js +8 -3
  8. package/lib/esm/components/default/ofMapper.js +2 -5
  9. package/lib/esm/components/default/requiredMapper.js +2 -2
  10. package/lib/esm/components/default/schemaMapper.js +6 -7
  11. package/lib/esm/components/index.js +1 -7
  12. package/lib/esm/components/open-spec/nullableMapper.js +5 -1
  13. package/lib/esm/components/open-spec/operationInParameterMapper.js +3 -7
  14. package/lib/esm/components/open-spec/operationInQueryMapper.js +22 -17
  15. package/lib/esm/components/open-spec/operationMediaMapper.js +5 -2
  16. package/lib/esm/components/open-spec/operationRequestBodyMapper.js +2 -2
  17. package/lib/esm/constants/VendorKeys.js +11 -0
  18. package/lib/esm/decorators/collections/collectionOf.js +14 -3
  19. package/lib/esm/decorators/common/description.js +9 -12
  20. package/lib/esm/decorators/common/discriminatorKey.js +1 -1
  21. package/lib/esm/decorators/common/forwardGroups.js +1 -1
  22. package/lib/esm/decorators/common/groups.js +15 -26
  23. package/lib/esm/decorators/common/oneOf.js +1 -1
  24. package/lib/esm/decorators/generics/genericOf.js +8 -17
  25. package/lib/esm/decorators/generics/generics.js +3 -3
  26. package/lib/esm/decorators/operations/redirect.js +1 -1
  27. package/lib/esm/decorators/operations/returns.js +40 -63
  28. package/lib/esm/domain/JsonEntityStore.js +40 -41
  29. package/lib/esm/domain/JsonMedia.js +27 -6
  30. package/lib/esm/domain/JsonMethodStore.js +28 -9
  31. package/lib/esm/domain/JsonOperation.js +15 -0
  32. package/lib/esm/domain/JsonParameter.js +11 -10
  33. package/lib/esm/domain/JsonParameterStore.js +3 -9
  34. package/lib/esm/domain/JsonPropertyStore.js +14 -45
  35. package/lib/esm/domain/JsonSchema.js +287 -80
  36. package/lib/esm/fn/email.js +2 -2
  37. package/lib/esm/fn/uri.js +2 -2
  38. package/lib/esm/fn/url.js +2 -2
  39. package/lib/esm/index.js +3 -8
  40. package/lib/esm/utils/generics.js +3 -32
  41. package/lib/esm/utils/getJsonSchema.js +24 -17
  42. package/lib/esm/utils/mergeSchema.js +98 -0
  43. package/lib/esm/utils/ref.js +14 -13
  44. package/lib/types/components/default/classMapper.d.ts +1 -1
  45. package/lib/types/components/default/genericsMapper.d.ts +9 -2
  46. package/lib/types/components/default/lazyRefMapper.d.ts +1 -1
  47. package/lib/types/components/default/nextMapper.d.ts +5 -0
  48. package/lib/types/components/default/ofMapper.d.ts +1 -1
  49. package/lib/types/components/index.d.ts +1 -7
  50. package/lib/types/components/open-spec/nullableMapper.d.ts +2 -1
  51. package/lib/types/components/open-spec/operationInQueryMapper.d.ts +1 -1
  52. package/lib/types/constants/VendorKeys.d.ts +10 -0
  53. package/lib/types/decorators/collections/collectionOf.d.ts +1 -1
  54. package/lib/types/decorators/generics/genericOf.d.ts +3 -0
  55. package/lib/types/decorators/generics/generics.d.ts +2 -2
  56. package/lib/types/decorators/operations/returns.d.ts +11 -9
  57. package/lib/types/domain/JsonEntityStore.d.ts +20 -18
  58. package/lib/types/domain/JsonMedia.d.ts +4 -5
  59. package/lib/types/domain/JsonMethodStore.d.ts +9 -2
  60. package/lib/types/domain/JsonOperation.d.ts +1 -0
  61. package/lib/types/domain/JsonParameter.d.ts +2 -7
  62. package/lib/types/domain/JsonParameterStore.d.ts +0 -2
  63. package/lib/types/domain/JsonPropertyStore.d.ts +1 -20
  64. package/lib/types/domain/JsonSchema.d.ts +82 -39
  65. package/lib/types/index.d.ts +3 -8
  66. package/lib/types/interfaces/JsonSchemaOptions.d.ts +16 -2
  67. package/lib/types/utils/generics.d.ts +7 -48
  68. package/lib/types/utils/getJsonSchema.d.ts +2 -1
  69. package/lib/types/utils/mergeSchema.d.ts +2 -0
  70. package/lib/types/utils/ref.d.ts +4 -2
  71. package/package.json +11 -8
  72. package/lib/esm/components/async-api/channelsMapper.js +0 -57
  73. package/lib/esm/components/async-api/generate.js +0 -17
  74. package/lib/esm/components/async-api/messageMapper.js +0 -39
  75. package/lib/esm/components/async-api/payloadMapper.js +0 -47
  76. package/lib/esm/components/async-api/responseMapper.js +0 -53
  77. package/lib/esm/components/default/itemMapper.js +0 -5
  78. package/lib/esm/components/default/propertiesMapper.js +0 -20
  79. package/lib/esm/utils/somethingOf.js +0 -11
  80. package/lib/types/components/async-api/channelsMapper.d.ts +0 -2
  81. package/lib/types/components/async-api/generate.d.ts +0 -1
  82. package/lib/types/components/async-api/messageMapper.d.ts +0 -6
  83. package/lib/types/components/async-api/payloadMapper.d.ts +0 -4
  84. package/lib/types/components/async-api/responseMapper.d.ts +0 -6
  85. package/lib/types/components/default/itemMapper.d.ts +0 -2
  86. package/lib/types/components/default/propertiesMapper.d.ts +0 -3
  87. 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,11 +0,0 @@
1
- export function makeOf(key, schemes) {
2
- if (schemes.length) {
3
- if (schemes.length === 1) {
4
- return schemes[0];
5
- }
6
- else {
7
- return { [key]: schemes };
8
- }
9
- }
10
- return null;
11
- }
@@ -1,2 +0,0 @@
1
- import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
2
- export declare function channelsMapper(model: any, { channels, rootPath, ...options }: JsonSchemaOptions): any;
@@ -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,2 +0,0 @@
1
- import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
2
- export declare function itemMapper(value: any, options: JsonSchemaOptions): any;
@@ -1,3 +0,0 @@
1
- import type { JsonSchema } from "../../domain/JsonSchema.js";
2
- import type { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
3
- export declare function propertiesMapper(input: any | JsonSchema, options: JsonSchemaOptions, parent: JsonSchema): any;
@@ -1 +0,0 @@
1
- export declare function makeOf(key: string, schemes: unknown[]): unknown;