@tsed/schema 6.91.0 → 6.94.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.
Files changed (115) hide show
  1. package/.mocharc.js +5 -0
  2. package/.nycrc +27 -0
  3. package/lib/cjs/components/anyMapper.js +0 -1
  4. package/lib/cjs/components/anyMapper.js.map +1 -1
  5. package/lib/cjs/components/classMapper.d.ts +1 -1
  6. package/lib/cjs/components/classMapper.js +1 -1
  7. package/lib/cjs/components/classMapper.js.map +1 -1
  8. package/lib/cjs/components/index.d.ts +2 -0
  9. package/lib/cjs/components/index.js +2 -0
  10. package/lib/cjs/components/index.js.map +1 -1
  11. package/lib/cjs/components/inheritedClassMapper.d.ts +1 -1
  12. package/lib/cjs/components/inheritedClassMapper.js +1 -1
  13. package/lib/cjs/components/inheritedClassMapper.js.map +1 -1
  14. package/lib/cjs/components/mapMapper.d.ts +1 -1
  15. package/lib/cjs/components/mapMapper.js +1 -1
  16. package/lib/cjs/components/mapMapper.js.map +1 -1
  17. package/lib/cjs/components/objectMapper.js +4 -1
  18. package/lib/cjs/components/objectMapper.js.map +1 -1
  19. package/lib/cjs/components/ofMapper.d.ts +3 -0
  20. package/lib/cjs/components/ofMapper.js +17 -0
  21. package/lib/cjs/components/ofMapper.js.map +1 -0
  22. package/lib/cjs/components/propertiesMapper.d.ts +3 -0
  23. package/lib/cjs/components/propertiesMapper.js +25 -0
  24. package/lib/cjs/components/propertiesMapper.js.map +1 -0
  25. package/lib/cjs/components/schemaMapper.d.ts +1 -1
  26. package/lib/cjs/components/schemaMapper.js +29 -31
  27. package/lib/cjs/components/schemaMapper.js.map +1 -1
  28. package/lib/cjs/decorators/common/requiredGroups.d.ts +1 -1
  29. package/lib/cjs/decorators/common/requiredGroups.js +6 -9
  30. package/lib/cjs/decorators/common/requiredGroups.js.map +1 -1
  31. package/lib/cjs/decorators/index.d.ts +1 -0
  32. package/lib/cjs/decorators/index.js +1 -0
  33. package/lib/cjs/decorators/index.js.map +1 -1
  34. package/lib/cjs/decorators/operations/inFile.d.ts +25 -0
  35. package/lib/cjs/decorators/operations/inFile.js +45 -0
  36. package/lib/cjs/decorators/operations/inFile.js.map +1 -0
  37. package/lib/cjs/decorators/operations/returns.d.ts +16 -1
  38. package/lib/cjs/decorators/operations/returns.js +38 -1
  39. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  40. package/lib/cjs/decorators/operations/route.d.ts +3 -0
  41. package/lib/cjs/decorators/operations/route.js +10 -8
  42. package/lib/cjs/decorators/operations/route.js.map +1 -1
  43. package/lib/cjs/domain/JsonEntityStore.d.ts +3 -0
  44. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  45. package/lib/cjs/domain/JsonMethodStore.d.ts +22 -1
  46. package/lib/cjs/domain/JsonMethodStore.js +42 -5
  47. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  48. package/lib/cjs/registries/JsonSchemaMapperContainer.d.ts +3 -2
  49. package/lib/cjs/registries/JsonSchemaMapperContainer.js +7 -3
  50. package/lib/cjs/registries/JsonSchemaMapperContainer.js.map +1 -1
  51. package/lib/cjs/utils/getJsonEntityStore.d.ts +0 -4
  52. package/lib/cjs/utils/getJsonEntityStore.js +1 -8
  53. package/lib/cjs/utils/getJsonEntityStore.js.map +1 -1
  54. package/lib/cjs/utils/getRequiredProperties.js +1 -2
  55. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  56. package/lib/cjs/utils/mapRouteOptions.d.ts +1 -1
  57. package/lib/cjs/utils/mapRouteOptions.js +1 -1
  58. package/lib/cjs/utils/mapRouteOptions.js.map +1 -1
  59. package/lib/esm/components/anyMapper.js +0 -1
  60. package/lib/esm/components/anyMapper.js.map +1 -1
  61. package/lib/esm/components/classMapper.js +1 -1
  62. package/lib/esm/components/classMapper.js.map +1 -1
  63. package/lib/esm/components/index.js +2 -0
  64. package/lib/esm/components/index.js.map +1 -1
  65. package/lib/esm/components/inheritedClassMapper.js +1 -1
  66. package/lib/esm/components/inheritedClassMapper.js.map +1 -1
  67. package/lib/esm/components/mapMapper.js +1 -1
  68. package/lib/esm/components/mapMapper.js.map +1 -1
  69. package/lib/esm/components/objectMapper.js +4 -1
  70. package/lib/esm/components/objectMapper.js.map +1 -1
  71. package/lib/esm/components/ofMapper.js +13 -0
  72. package/lib/esm/components/ofMapper.js.map +1 -0
  73. package/lib/esm/components/propertiesMapper.js +21 -0
  74. package/lib/esm/components/propertiesMapper.js.map +1 -0
  75. package/lib/esm/components/schemaMapper.js +30 -32
  76. package/lib/esm/components/schemaMapper.js.map +1 -1
  77. package/lib/esm/decorators/common/requiredGroups.js +6 -9
  78. package/lib/esm/decorators/common/requiredGroups.js.map +1 -1
  79. package/lib/esm/decorators/index.js +1 -0
  80. package/lib/esm/decorators/index.js.map +1 -1
  81. package/lib/esm/decorators/operations/inFile.js +41 -0
  82. package/lib/esm/decorators/operations/inFile.js.map +1 -0
  83. package/lib/esm/decorators/operations/returns.js +39 -2
  84. package/lib/esm/decorators/operations/returns.js.map +1 -1
  85. package/lib/esm/decorators/operations/route.js +10 -8
  86. package/lib/esm/decorators/operations/route.js.map +1 -1
  87. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  88. package/lib/esm/domain/JsonMethodStore.js +44 -7
  89. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  90. package/lib/esm/registries/JsonSchemaMapperContainer.js +5 -2
  91. package/lib/esm/registries/JsonSchemaMapperContainer.js.map +1 -1
  92. package/lib/esm/utils/getJsonEntityStore.js +0 -6
  93. package/lib/esm/utils/getJsonEntityStore.js.map +1 -1
  94. package/lib/esm/utils/getRequiredProperties.js +1 -2
  95. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  96. package/lib/esm/utils/mapRouteOptions.js +1 -1
  97. package/lib/esm/utils/mapRouteOptions.js.map +1 -1
  98. package/lib/types/components/classMapper.d.ts +1 -1
  99. package/lib/types/components/index.d.ts +2 -0
  100. package/lib/types/components/inheritedClassMapper.d.ts +1 -1
  101. package/lib/types/components/mapMapper.d.ts +1 -1
  102. package/lib/types/components/ofMapper.d.ts +3 -0
  103. package/lib/types/components/propertiesMapper.d.ts +3 -0
  104. package/lib/types/components/schemaMapper.d.ts +1 -1
  105. package/lib/types/decorators/common/requiredGroups.d.ts +1 -1
  106. package/lib/types/decorators/index.d.ts +1 -0
  107. package/lib/types/decorators/operations/inFile.d.ts +25 -0
  108. package/lib/types/decorators/operations/returns.d.ts +16 -1
  109. package/lib/types/decorators/operations/route.d.ts +3 -0
  110. package/lib/types/domain/JsonEntityStore.d.ts +3 -0
  111. package/lib/types/domain/JsonMethodStore.d.ts +22 -1
  112. package/lib/types/registries/JsonSchemaMapperContainer.d.ts +3 -2
  113. package/lib/types/utils/getJsonEntityStore.d.ts +0 -4
  114. package/lib/types/utils/mapRouteOptions.d.ts +1 -1
  115. package/package.json +7 -6
@@ -1 +1 @@
1
- {"version":3,"file":"getRequiredProperties.js","sourceRoot":"","sources":["../../../src/utils/getRequiredProperties.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAEhC,sEAAiE;AAGjE,SAAS,eAAe,CAAC,GAAQ,EAAE,UAAsB;IACvD,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA,EAAE;QACpC,IAAK,EAAe,CAAC,MAAM,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACvE,MAAM,SAAS,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,CAAC;YACjC,wBAAwB;YACxB,IAAI,SAAS,KAAK,SAAS,EAAE;gBAC3B,OAAO;oBACL,GAAG,GAAG;oBACN,SAAS,EAAE,CAAC;iBACb,CAAC;aACH;SACF;KACF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAQ,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AClG,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE;gBAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;aACtF;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,EAAE,QAAQ,CAAC,CAAC;KACd;IAED,OAAO,IAAA,yCAAmB,EAAC,IAAA,WAAI,EAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,GAAQ,EAAE,MAAkB,EAAE,OAA0B;IAC5F,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACxD,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE1D,QAAQ,GAAG,IAAA,WAAI,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAE7E,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,OAAO;YACL,GAAG,GAAG;YACN,QAAQ;SACT,CAAC;KACH;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAjBD,sDAiBC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterRequiredGroups} from \"../hooks/alterRequiredGroups\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction applyStringRule(obj: any, propSchema: JsonSchema) {\n if (!propSchema?.$allow.includes(\"\")) {\n if (([] as string[]).concat(propSchema?.get(\"type\")).includes(\"string\")) {\n const minLength = obj?.minLength;\n // Disallow empty string\n if (minLength === undefined) {\n return {\n ...obj,\n minLength: 1\n };\n }\n }\n }\n\n return obj;\n}\n\nfunction mapRequiredProps(obj: any, schema: JsonSchema, options: JsonSchemaOptions = {}) {\n const {useAlias} = options;\n const props = Object.keys(obj.properties || {});\n\n return (keys: string[], key: string) => {\n const aliasedKey = useAlias ? (schema.alias.get(key) as string) || key : key;\n\n if (props.includes(aliasedKey)) {\n const propSchema = schema.get(\"properties\")[key];\n const serializeSchema = obj.properties[aliasedKey];\n\n obj.properties[aliasedKey] = applyStringRule(serializeSchema, propSchema); // applyNullRule(applyStringRule(serializeSchema, propSchema), propSchema);\n // obj.properties[aliasedKey] = mapNullableType(obj.properties[aliasedKey]);\n\n return keys.concat(aliasedKey);\n }\n\n return keys;\n };\n}\n\nfunction extractRequiredProps(obj: any, schema: JsonSchema, options: JsonSchemaOptions): string[] {\n let required: string[] = obj.required || [];\n\n required = [...required, ...schema.$required];\n\n if (schema.get(\"properties\")) {\n required = Object.entries(schema.get(\"properties\")).reduce((required, [key, prop]: [string, any]) => {\n if (prop && prop.$selfRequired !== undefined) {\n return prop.$selfRequired ? required.concat(key) : required.filter((k) => k === key);\n }\n\n return required;\n }, required);\n }\n\n return alterRequiredGroups(uniq(required), schema, options);\n}\n\n/**\n * @ignore\n */\nexport function getRequiredProperties(obj: any, schema: JsonSchema, options: JsonSchemaOptions) {\n if (options.groups && options.groups.includes(\"partial\")) {\n return obj;\n }\n\n let required = extractRequiredProps(obj, schema, options);\n\n required = uniq(required).reduce(mapRequiredProps(obj, schema, options), []);\n\n if (required.length) {\n return {\n ...obj,\n required\n };\n }\n\n return obj;\n}\n"]}
1
+ {"version":3,"file":"getRequiredProperties.js","sourceRoot":"","sources":["../../../src/utils/getRequiredProperties.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAEhC,sEAAiE;AAGjE,SAAS,eAAe,CAAC,GAAQ,EAAE,UA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AAA,WAAI,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IAE7E,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,OAAO;YACL,GAAG,GAAG;YACN,QAAQ;SACT,CAAC;KACH;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAjBD,sDAiBC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterRequiredGroups} from \"../hooks/alterRequiredGroups\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction applyStringRule(obj: any, propSchema: JsonSchema) {\n if (!propSchema?.$allow.includes(\"\")) {\n if (([] as string[]).concat(propSchema?.get(\"type\")).includes(\"string\")) {\n const minLength = obj?.minLength;\n // Disallow empty string\n if (minLength === undefined) {\n return {\n ...obj,\n minLength: 1\n };\n }\n }\n }\n\n return obj;\n}\n\nfunction mapRequiredProps(obj: any, schema: JsonSchema, options: JsonSchemaOptions = {}) {\n const {useAlias} = options;\n const props = Object.keys(obj.properties || {});\n\n return (keys: string[], key: string) => {\n const aliasedKey = useAlias ? (schema.alias.get(key) as string) || key : key;\n\n if (props.includes(aliasedKey)) {\n const propSchema = schema.get(\"properties\")[key];\n const serializeSchema = obj.properties[aliasedKey];\n\n obj.properties[aliasedKey] = applyStringRule(serializeSchema, propSchema);\n\n return keys.concat(aliasedKey);\n }\n\n return keys;\n };\n}\n\nfunction extractRequiredProps(obj: any, schema: JsonSchema, options: JsonSchemaOptions): string[] {\n let required: string[] = obj.required || [];\n\n required = [...required, ...schema.$required];\n\n if (schema.get(\"properties\")) {\n required = Object.entries(schema.get(\"properties\")).reduce((required, [key, prop]: [string, any]) => {\n if (prop && prop.$selfRequired !== undefined) {\n return prop.$selfRequired ? required.concat(key) : required.filter((k) => k === key);\n }\n\n return required;\n }, required);\n }\n\n return alterRequiredGroups(uniq(required), schema, options);\n}\n\n/**\n * @ignore\n */\nexport function getRequiredProperties(obj: any, schema: JsonSchema, options: JsonSchemaOptions) {\n if (options.groups && options.groups.includes(\"partial\")) {\n return obj;\n }\n\n let required = extractRequiredProps(obj, schema, options);\n\n required = uniq(required).reduce(mapRequiredProps(obj, schema, options), []);\n\n if (required.length) {\n return {\n ...obj,\n required\n };\n }\n\n return obj;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export declare function mapRouteOptions(args: any[]): {
2
2
  path: undefined;
3
3
  method: undefined;
4
- handlers: any[];
4
+ use: any[];
5
5
  };
@@ -19,7 +19,7 @@ function mapRouteOptions(args) {
19
19
  return {
20
20
  path,
21
21
  method,
22
- handlers
22
+ use: handlers
23
23
  };
24
24
  }
25
25
  exports.mapRouteOptions = mapRouteOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"mapRouteOptions.js","sourceRoot":"","sources":["../../../src/utils/mapRouteOptions.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AAEtD,SAAgB,eAAe,CAAC,IAAW;IACzC,IAAI,MAAM,GAAuB,SAAS,CAAC;IAC3C,IAAI,IAAI,GAAgC,SAAS,CAAC;IAElD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,EAAE;QACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,0BAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE;YACvE,MAAM,GAAG,GAAG,CAAC,iBAAiB,EAAE,CAAC;YAEjC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,MAAM,EAAE;YACpD,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;YAElB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,CAAC,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI;QACJ,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AAzBD,0CAyBC","sourcesContent":["import {HTTP_METHODS} from \"../constants/httpMethods\";\n\nexport function mapRouteOptions(args: any[]) {\n let method: string | undefined = undefined;\n let path: string | RegExp | undefined = undefined;\n\n const handlers = args.filter((arg: any) => {\n if (typeof arg === \"string\" && HTTP_METHODS.includes(arg.toLowerCase())) {\n method = arg.toLocaleUpperCase();\n\n return false;\n }\n\n if (typeof arg === \"string\" || arg instanceof RegExp) {\n path = arg || \"/\";\n\n return false;\n }\n\n return !!arg;\n });\n\n return {\n path,\n method,\n handlers\n };\n}\n"]}
1
+ {"version":3,"file":"mapRouteOptions.js","sourceRoot":"","sources":["../../../src/utils/mapRouteOptions.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AAEtD,SAAgB,eAAe,CAAC,IAAW;IACzC,IAAI,MAAM,GAAuB,SAAS,CAAC;IAC3C,IAAI,IAAI,GAAgC,SAAS,CAAC;IAElD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,EAAE;QACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,0BAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE;YACvE,MAAM,GAAG,GAAG,CAAC,iBAAiB,EAAE,CAAC;YAEjC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,MAAM,EAAE;YACpD,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;YAElB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,CAAC,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI;QACJ,MAAM;QACN,GAAG,EAAE,QAAQ;KACd,CAAC;AACJ,CAAC;AAzBD,0CAyBC","sourcesContent":["import {HTTP_METHODS} from \"../constants/httpMethods\";\n\nexport function mapRouteOptions(args: any[]) {\n let method: string | undefined = undefined;\n let path: string | RegExp | undefined = undefined;\n\n const handlers = args.filter((arg: any) => {\n if (typeof arg === \"string\" && HTTP_METHODS.includes(arg.toLowerCase())) {\n method = arg.toLocaleUpperCase();\n\n return false;\n }\n\n if (typeof arg === \"string\" || arg instanceof RegExp) {\n path = arg || \"/\";\n\n return false;\n }\n\n return !!arg;\n });\n\n return {\n path,\n method,\n use: handlers\n };\n}\n"]}
@@ -3,7 +3,6 @@ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMa
3
3
  import { mapGenericsOptions } from "../utils/generics";
4
4
  import { toRef } from "../utils/ref";
5
5
  export function anyMapper(input, options = {}) {
6
- options.schemas = options.schemas || {};
7
6
  if (typeof input !== "object" || input === null) {
8
7
  return input;
9
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"anyMapper.js","sourceRoot":"","sources":["../../../src/components/anyMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAEnC,MAAM,UAAU,SAAS,CAAC,KAAU,EAAE,UAA6B,EAAE;IACnE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IAExC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;QAC/C,OAAO,KAAK,CAAC;KACd;IAED,IAAI,KAAK,YAAY,WAAW,EAAE;QAChC,OAAO,UAAU,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KAC9C;IAED,IAAI,QAAQ,IAAI,KAAK,EAAE;QACrB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;QAEzD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;KAC9D;IAED,OAAO,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {toRef} from \"../utils/ref\";\n\nexport function anyMapper(input: any, options: JsonSchemaOptions = {}): any {\n options.schemas = options.schemas || {};\n\n if (typeof input !== \"object\" || input === null) {\n return input;\n }\n\n if (input instanceof JsonLazyRef) {\n return execMapper(\"lazyRef\", input, options);\n }\n\n if (\"toJSON\" in input) {\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return input.canRef ? toRef(input, schema, options) : schema;\n }\n\n return execMapper(\"object\", input, options);\n}\n\nregisterJsonSchemaMapper(\"any\", anyMapper);\n"]}
1
+ {"version":3,"file":"anyMapper.js","sourceRoot":"","sources":["../../../src/components/anyMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAEnC,MAAM,UAAU,SAAS,CAAC,KAAU,EAAE,UAA6B,EAAE;IACnE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;QAC/C,OAAO,KAAK,CAAC;KACd;IAED,IAAI,KAAK,YAAY,WAAW,EAAE;QAChC,OAAO,UAAU,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KAC9C;IAED,IAAI,QAAQ,IAAI,KAAK,EAAE;QACrB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;QAEzD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;KAC9D;IAED,OAAO,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {toRef} from \"../utils/ref\";\n\nexport function anyMapper(input: any, options: JsonSchemaOptions = {}): any {\n if (typeof input !== \"object\" || input === null) {\n return input;\n }\n\n if (input instanceof JsonLazyRef) {\n return execMapper(\"lazyRef\", input, options);\n }\n\n if (\"toJSON\" in input) {\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return input.canRef ? toRef(input, schema, options) : schema;\n }\n\n return execMapper(\"object\", input, options);\n}\n\nregisterJsonSchemaMapper(\"any\", anyMapper);\n"]}
@@ -2,7 +2,7 @@ import { JsonEntityStore } from "../domain/JsonEntityStore";
2
2
  import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
3
3
  import { mapGenericsOptions, popGenerics } from "../utils/generics";
4
4
  import { createRef, createRefName } from "../utils/ref";
5
- export function classMapper(value, options = {}) {
5
+ export function classMapper(value, options) {
6
6
  const store = JsonEntityStore.from(value.class);
7
7
  const name = createRefName(store.schema.getName() || value.getName(), options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SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;SACxC;QAED,OAAO,MAAM,CAAC;KACf;IAED,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,uBAAuB;QACnD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAChC,KAAK,EACL,KAAK,CAAC,MAAM,EACZ,kBAAkB,CAAC;YACjB,GAAG,OAAO;YACV,IAAI,EAAE,KAAK;SACZ,CAAC,CACH,CAAC;KACH;IAED,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,wBAAwB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions, popGenerics} from \"../utils/generics\";\nimport {createRef, createRefName} from \"../utils/ref\";\n\nexport function classMapper(value: JsonSchema, options: JsonSchemaOptions = {}) {\n const store = JsonEntityStore.from(value.class);\n const name = createRefName(store.schema.getName() || value.getName(), options);\n\n if (value.hasGenerics) {\n // Inline generic\n const {type, properties, additionalProperties, items, ...props} = value.toJSON(options);\n const schema = {\n ...execMapper(\"any\", store.schema, {\n ...options,\n ...popGenerics(value),\n root: false\n }),\n ...props\n };\n\n if (schema.title) {\n const name = createRefName(schema.title, options);\n options.schemas![name] = schema;\n delete schema.title;\n\n return createRef(name, value, options);\n }\n\n return schema;\n }\n\n if (options.schemas && !options.schemas[name]) {\n options.schemas[name] = {}; // avoid infinite calls\n options.schemas[name] = execMapper(\n \"any\",\n store.schema,\n mapGenericsOptions({\n ...options,\n root: false\n })\n );\n }\n\n return createRef(name, value, options);\n}\n\nregisterJsonSchemaMapper(\"class\", classMapper);\n"]}
1
+ {"version":3,"file":"classMapper.js","sourceRoot":"","sources":["../../../src/components/classMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAG1D,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAC,SAAS,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAEtD,MAAM,UAAU,WAAW,CAAC,KAAiB,EAAE,OAA0B;IACvE,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAE/E,IAAI,KAAK,CAAC,WAAW,EAAE;QACrB,iBAAiB;QACjB,MAAM,EAAC,IAAI,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,GAAG,KAAK,EAAC,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxF,MAAM,MAAM,GAAG;YACb,GAAG,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE;gBACjC,GAAG,OAAO;gBACV,GAAG,WAAW,CAAC,KAAK,CAAC;gBACrB,IAAI,EAAE,KAAK;aACZ,CAAC;YACF,GAAG,KAAK;SACT,CAAC;QAEF,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAClD,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YAChC,OAAO,MAAM,CAAC,KAAK,CAAC;YAEpB,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;SACxC;QAED,OAAO,MAAM,CAAC;KACf;IAED,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,uBAAuB;QACnD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAChC,KAAK,EACL,KAAK,CAAC,MAAM,EACZ,kBAAkB,CAAC;YACjB,GAAG,OAAO;YACV,IAAI,EAAE,KAAK;SACZ,CAAC,CACH,CAAC;KACH;IAED,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,wBAAwB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions, popGenerics} from \"../utils/generics\";\nimport {createRef, createRefName} from \"../utils/ref\";\n\nexport function classMapper(value: JsonSchema, options: JsonSchemaOptions) {\n const store = JsonEntityStore.from(value.class);\n const name = createRefName(store.schema.getName() || value.getName(), options);\n\n if (value.hasGenerics) {\n // Inline generic\n const {type, properties, additionalProperties, items, ...props} = value.toJSON(options);\n const schema = {\n ...execMapper(\"any\", store.schema, {\n ...options,\n ...popGenerics(value),\n root: false\n }),\n ...props\n };\n\n if (schema.title) {\n const name = createRefName(schema.title, options);\n options.schemas![name] = schema;\n delete schema.title;\n\n return createRef(name, value, options);\n }\n\n return schema;\n }\n\n if (options.schemas && !options.schemas[name]) {\n options.schemas[name] = {}; // avoid infinite calls\n options.schemas[name] = execMapper(\n \"any\",\n store.schema,\n mapGenericsOptions({\n ...options,\n root: false\n })\n );\n }\n\n return createRef(name, value, options);\n}\n\nregisterJsonSchemaMapper(\"class\", classMapper);\n"]}
@@ -7,4 +7,6 @@ export * from "./lazyRefMapper";
7
7
  export * from "./mapMapper";
8
8
  export * from "./objectMapper";
9
9
  export * from "./schemaMapper";
10
+ export * from "./ofMapper";
11
+ export * from "./propertiesMapper";
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./anyMapper\";\nexport * from \"./classMapper\";\nexport * from \"./genericsMapper\";\nexport * from \"./inheritedClassMapper\";\nexport * from \"./itemMapper\";\nexport * from \"./lazyRefMapper\";\nexport * from \"./mapMapper\";\nexport * from \"./objectMapper\";\nexport * from \"./schemaMapper\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./anyMapper\";\nexport * from \"./classMapper\";\nexport * from \"./genericsMapper\";\nexport * from \"./inheritedClassMapper\";\nexport * from \"./itemMapper\";\nexport * from \"./lazyRefMapper\";\nexport * from \"./mapMapper\";\nexport * from \"./objectMapper\";\nexport * from \"./schemaMapper\";\nexport * from \"./ofMapper\";\nexport * from \"./propertiesMapper\";\n"]}
@@ -4,7 +4,7 @@ import { getInheritedStores } from "../utils/getInheritedStores";
4
4
  /**
5
5
  * @ignore
6
6
  */
7
- export function inheritedClassMapper(obj, { target, ...options } = {}) {
7
+ export function inheritedClassMapper(obj, { target, ...options }) {
8
8
  const stores = Array.from(getInheritedStores(target).entries()).filter(([model]) => classOf(model) !== classOf(target));
9
9
  if (stores.length) {
10
10
  const schema = stores.reduce((obj, [, store]) => {
@@ -1 +1 @@
1
- {"version":3,"file":"inheritedClassMapper.js","sourceRoot":"","sources":["../../../src/components/inheritedClassMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ,EAAE,EAAC,MAAM,EAAE,GAAG,OAAO,KAAuB,EAAE;IACzF,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAExH,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9C,OAAO,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACrE,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC9B;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import {classOf, deepMerge} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getInheritedStores} from \"../utils/getInheritedStores\";\n\n/**\n * @ignore\n */\nexport function inheritedClassMapper(obj: any, {target, ...options}: JsonSchemaOptions = {}) {\n const stores = Array.from(getInheritedStores(target).entries()).filter(([model]) => classOf(model) !== classOf(target));\n\n if (stores.length) {\n const schema = stores.reduce((obj, [, store]) => {\n return deepMerge(obj, execMapper(\"schema\", store.schema, options));\n }, {});\n\n obj = deepMerge(schema, obj);\n }\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"inheritedClass\", inheritedClassMapper);\n"]}
1
+ {"version":3,"file":"inheritedClassMapper.js","sourceRoot":"","sources":["../../../src/components/inheritedClassMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ,EAAE,EAAC,MAAM,EAAE,GAAG,OAAO,EAAoB;IACpF,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAExH,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9C,OAAO,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACrE,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC9B;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import {classOf, deepMerge} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getInheritedStores} from \"../utils/getInheritedStores\";\n\n/**\n * @ignore\n */\nexport function inheritedClassMapper(obj: any, {target, ...options}: JsonSchemaOptions) {\n const stores = Array.from(getInheritedStores(target).entries()).filter(([model]) => classOf(model) !== classOf(target));\n\n if (stores.length) {\n const schema = stores.reduce((obj, [, store]) => {\n return deepMerge(obj, execMapper(\"schema\", store.schema, options));\n }, {});\n\n obj = deepMerge(schema, obj);\n }\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"inheritedClass\", inheritedClassMapper);\n"]}
@@ -7,7 +7,7 @@ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMa
7
7
  * @param options
8
8
  * @ignore
9
9
  */
10
- export function mapMapper(input, { ignore = [], ...options } = {}) {
10
+ export function mapMapper(input, { ignore = [], ...options }) {
11
11
  options = mapGenericsOptions(options);
12
12
  return Array.from(input.entries()).reduce((obj, [key, value]) => {
13
13
  if (ignore.includes(key)) {
@@ -1 +1 @@
1
- {"version":3,"file":"mapMapper.js","sourceRoot":"","sources":["../../../src/components/mapMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAuB,EAAE,EAAC,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,KAAuB,EAAE;IAClG,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACnE,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO,GAAG,CAAC;SACZ;QAED,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import {mapGenericsOptions} from \"../utils/generics\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\n\n/**\n * Serialize class which inherit from Map like JsonMap, JsonOperation, JsonParameter.\n * @param input\n * @param ignore\n * @param options\n * @ignore\n */\nexport function mapMapper(input: Map<string, any>, {ignore = [], ...options}: JsonSchemaOptions = {}): any {\n options = mapGenericsOptions(options);\n\n return Array.from(input.entries()).reduce((obj: any, [key, value]) => {\n if (ignore.includes(key)) {\n return obj;\n }\n\n obj[key] = execMapper(\"item\", value, options);\n return obj;\n }, {});\n}\n\nregisterJsonSchemaMapper(\"map\", mapMapper);\n"]}
1
+ {"version":3,"file":"mapMapper.js","sourceRoot":"","sources":["../../../src/components/mapMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAuB,EAAE,EAAC,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,EAAoB;IAC7F,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACnE,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO,GAAG,CAAC;SACZ;QAED,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import {mapGenericsOptions} from \"../utils/generics\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\n\n/**\n * Serialize class which inherit from Map like JsonMap, JsonOperation, JsonParameter.\n * @param input\n * @param ignore\n * @param options\n * @ignore\n */\nexport function mapMapper(input: Map<string, any>, {ignore = [], ...options}: JsonSchemaOptions): any {\n options = mapGenericsOptions(options);\n\n return Array.from(input.entries()).reduce((obj: any, [key, value]) => {\n if (ignore.includes(key)) {\n return obj;\n }\n\n obj[key] = execMapper(\"item\", value, options);\n return obj;\n }, {});\n}\n\nregisterJsonSchemaMapper(\"map\", mapMapper);\n"]}
@@ -12,7 +12,10 @@ export function objectMapper(input, options) {
12
12
  return Object.entries(input).reduce((obj, [key, value]) => {
13
13
  if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {
14
14
  // remove groups to avoid bad schema generation over children models
15
- obj[key] = execMapper("item", value, { ...options, groups: (value === null || value === void 0 ? void 0 : value.$forwardGroups) ? options.groups : undefined });
15
+ obj[key] = execMapper("item", value, {
16
+ ...options,
17
+ groups: (input === null || input === void 0 ? void 0 : input.$forwardGroups) || (value === null || value === void 0 ? void 0 : value.$forwardGroups) ? options.groups : undefined
18
+ });
16
19
  }
17
20
  return obj;
18
21
  }, isArray(input) ? [] : {});
@@ -1 +1 @@
1
- {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,EAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,EAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAC,CAAC,CAAC;SAChH;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, {...options, groups: value?.$forwardGroups ? options.groups : undefined});\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
1
+ {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE;gBACnC,GAAG,OAAO;gBACV,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAA,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC,CAAC;SACJ;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n });\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
@@ -0,0 +1,13 @@
1
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
2
+ export function ofMapper(input, options, parent) {
3
+ return input.map((value) => {
4
+ return execMapper("item", value, {
5
+ ...options,
6
+ genericLabels: parent.genericLabels
7
+ });
8
+ });
9
+ }
10
+ registerJsonSchemaMapper("anyOf", ofMapper);
11
+ registerJsonSchemaMapper("allOf", ofMapper);
12
+ registerJsonSchemaMapper("oneOf", ofMapper);
13
+ //# sourceMappingURL=ofMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ofMapper.js","sourceRoot":"","sources":["../../../src/components/ofMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAI7F,MAAM,UAAU,QAAQ,CAAC,KAA2B,EAAE,OAA0B,EAAE,MAAkB;IAClG,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAuB,EAAE,EAAE;QAC3C,OAAO,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE;YAC/B,GAAG,OAAO;YACV,aAAa,EAAE,MAAM,CAAC,aAAa;SACpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,wBAAwB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC5C,wBAAwB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC5C,wBAAwB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nexport function ofMapper(input: (any | JsonSchema)[], options: JsonSchemaOptions, parent: JsonSchema) {\n return input.map((value: any | JsonSchema) => {\n return execMapper(\"item\", value, {\n ...options,\n genericLabels: parent.genericLabels\n });\n });\n}\n\nregisterJsonSchemaMapper(\"anyOf\", ofMapper);\nregisterJsonSchemaMapper(\"allOf\", ofMapper);\nregisterJsonSchemaMapper(\"oneOf\", ofMapper);\n"]}
@@ -0,0 +1,21 @@
1
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
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);
21
+ //# sourceMappingURL=propertiesMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertiesMapper.js","sourceRoot":"","sources":["../../../src/components/propertiesMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAI7F,MAAM,UAAU,gBAAgB,CAAC,KAAuB,EAAE,OAA0B,EAAE,MAAkB;IACtG,IAAI,KAAK,CAAC,OAAO,EAAE;QACjB,OAAO,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KAC5C;IAED,OAAO,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC,CAAC;AACL,CAAC;AAED,wBAAwB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AACzD,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACpD,wBAAwB,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;AACnE,wBAAwB,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAC5D,wBAAwB,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAC3D,wBAAwB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AAChE,wBAAwB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;AAC9D,wBAAwB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAClD,wBAAwB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nexport function propertiesMapper(input: any | JsonSchema, options: JsonSchemaOptions, parent: JsonSchema) {\n if (input.isClass) {\n return execMapper(\"class\", input, options);\n }\n\n return execMapper(\"any\", input, {\n ...options,\n genericLabels: parent.genericLabels\n });\n}\n\nregisterJsonSchemaMapper(\"properties\", propertiesMapper);\nregisterJsonSchemaMapper(\"items\", propertiesMapper);\nregisterJsonSchemaMapper(\"additionalProperties\", propertiesMapper);\nregisterJsonSchemaMapper(\"propertyNames\", propertiesMapper);\nregisterJsonSchemaMapper(\"contains\", propertiesMapper);\nregisterJsonSchemaMapper(\"dependencies\", propertiesMapper);\nregisterJsonSchemaMapper(\"patternProperties\", propertiesMapper);\nregisterJsonSchemaMapper(\"additionalItems\", propertiesMapper);\nregisterJsonSchemaMapper(\"not\", propertiesMapper);\nregisterJsonSchemaMapper(\"definitions\", propertiesMapper);\n"]}
@@ -1,7 +1,7 @@
1
1
  import { isObject } from "@tsed/core";
2
2
  import { mapAliasedProperties } from "../domain/JsonAliasMap";
3
3
  import { SpecTypes } from "../domain/SpecTypes";
4
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
4
+ import { execMapper, hasMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
5
5
  import { getRequiredProperties } from "../utils/getRequiredProperties";
6
6
  import { mapNullableType } from "../utils/mapNullableType";
7
7
  /**
@@ -34,46 +34,44 @@ function shouldSkipKey(key, { specType = SpecTypes.JSON, customKeys = false }) {
34
34
  (specType === SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||
35
35
  (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key)));
36
36
  }
37
- export function schemaMapper(schema, options = {}) {
38
- const { useAlias = true, schemas = {}, genericTypes } = options;
39
- let obj = [...schema.entries()].reduce((item, [key, value]) => {
40
- if (shouldSkipKey(key, options)) {
41
- return item;
42
- }
37
+ function isExample(key, value, options) {
38
+ return key === "examples" && isObject(value) && [SpecTypes.OPENAPI, SpecTypes.SWAGGER].includes(options.specType);
39
+ }
40
+ export function schemaMapper(schema, options) {
41
+ const { useAlias = true, schemas = {} } = options;
42
+ options = {
43
+ ...options,
44
+ useAlias,
45
+ schemas
46
+ };
47
+ let obj = [...schema.keys()]
48
+ .filter((key) => !shouldSkipKey(key, options))
49
+ .reduce((item, key) => {
50
+ let value = schema.get(key);
43
51
  key = key.replace(/^#/, "");
44
52
  if (key === "type") {
45
- value = schema.getJsonType();
53
+ return {
54
+ ...item,
55
+ [key]: schema.getJsonType()
56
+ };
46
57
  }
47
- if (key === "examples" && isObject(value) && [SpecTypes.OPENAPI, SpecTypes.SWAGGER].includes(options.specType)) {
58
+ if (isExample(key, value, options)) {
48
59
  key = "example";
49
60
  value = Object.values(value)[0];
50
61
  }
51
- if (value) {
52
- if (value.isClass) {
53
- value = execMapper("class", value, {
54
- ...options,
55
- useAlias,
56
- schemas
57
- });
62
+ if (value && typeof value === "object" && hasMapper(key)) {
63
+ value = execMapper(key, value, options, schema);
64
+ if (isEmptyProperties(key, value)) {
65
+ return item;
58
66
  }
59
- else {
60
- value = execMapper("any", value, {
61
- ...options,
62
- useAlias,
63
- schemas,
64
- genericTypes,
65
- genericLabels: schema.genericLabels
66
- });
67
+ if (shouldMapAlias(key, value, useAlias)) {
68
+ value = mapAliasedProperties(value, schema.alias);
67
69
  }
68
70
  }
69
- if (isEmptyProperties(key, value)) {
70
- return item;
71
- }
72
- if (shouldMapAlias(key, value, useAlias)) {
73
- value = mapAliasedProperties(value, schema.alias);
74
- }
75
- item[key] = value;
76
- return item;
71
+ return {
72
+ ...item,
73
+ [key]: value
74
+ };
77
75
  }, {});
78
76
  if (schema.isClass) {
79
77
  obj = execMapper("inheritedClass", obj, { ...options, root: false, schemas, target: schema.getComputedType() });
@@ -1 +1 @@
1
- {"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC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C,KAAK,IAAI,GAAG,CAAC,UAAU,CAAC,EAAE;QAC3E,OAAO,GAAG,CAAC,IAAI,CAAC;KACjB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {mapAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\nconst IGNORES_OS2 = [\"writeOnly\", \"readOnly\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType === SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions = {}): any {\n const {useAlias = true, schemas = {}, genericTypes} = options;\n\n let obj: any = [...schema.entries()].reduce((item: any, [key, value]) => {\n if (shouldSkipKey(key, options)) {\n return item;\n }\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n value = schema.getJsonType();\n }\n\n if (key === \"examples\" && isObject(value) && [SpecTypes.OPENAPI, SpecTypes.SWAGGER].includes(options.specType!)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value) {\n if (value.isClass) {\n value = execMapper(\"class\", value, {\n ...options,\n useAlias,\n schemas\n });\n } else {\n value = execMapper(\"any\", value, {\n ...options,\n useAlias,\n schemas,\n genericTypes,\n genericLabels: schema.genericLabels\n });\n }\n }\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n\n item[key] = value;\n\n return item;\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n\n if ((obj.oneOf || obj.allOf || obj.anyOf) && !(obj.items || obj.properties)) {\n delete obj.type;\n }\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
1
+ {"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;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CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5C,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,CAAC,EAAE;QAC3E,OAAO,GAAG,CAAC,IAAI,CAAC;KACjB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {mapAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, hasMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\nconst IGNORES_OS2 = [\"writeOnly\", \"readOnly\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType === SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nfunction isExample(key: string, value: any, options: JsonSchemaOptions) {\n return key === \"examples\" && isObject(value) && [SpecTypes.OPENAPI, SpecTypes.SWAGGER].includes(options.specType!);\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any {\n const {useAlias = true, schemas = {}} = options;\n options = {\n ...options,\n useAlias,\n schemas\n };\n\n let obj: any = [...schema.keys()]\n .filter((key) => !shouldSkipKey(key, options))\n .reduce((item: any, key) => {\n let value = schema.get(key);\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n return {\n ...item,\n [key]: schema.getJsonType()\n };\n }\n\n if (isExample(key, value, options)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value && typeof value === \"object\" && hasMapper(key)) {\n value = execMapper(key, value, options, schema);\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n }\n\n return {\n ...item,\n [key]: value\n };\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n\n if ((obj.oneOf || obj.allOf || obj.anyOf) && !(obj.items || obj.properties)) {\n delete obj.type;\n }\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
@@ -1,4 +1,3 @@
1
- import { DecoratorTypes } from "@tsed/core";
2
1
  import { matchGroups } from "../../utils/matchGroups";
3
2
  import { JsonEntityFn } from "./jsonEntityFn";
4
3
  /**
@@ -12,14 +11,12 @@ import { JsonEntityFn } from "./jsonEntityFn";
12
11
  */
13
12
  export function RequiredGroups(...groups) {
14
13
  return JsonEntityFn((entity) => {
15
- if (entity.decoratorType === DecoratorTypes.PROP) {
16
- entity.parent.schema.$hooks.on("requiredGroups", (required, givenGroups) => {
17
- if (matchGroups(groups, givenGroups)) {
18
- return required.filter((key) => key !== entity.propertyKey);
19
- }
20
- return required;
21
- });
22
- }
14
+ entity.parent.schema.$hooks.on("requiredGroups", (required, givenGroups) => {
15
+ if (matchGroups(groups, givenGroups)) {
16
+ return required.filter((key) => key !== entity.propertyKey);
17
+ }
18
+ return required;
19
+ });
23
20
  });
24
21
  }
25
22
  //# sourceMappingURL=requiredGroups.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"requiredGroups.js","sourceRoot":"","sources":["../../../../src/decorators/common/requiredGroups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAG,MAAgB;IAChD,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,IAAI,MAAM,CAAC,aAAa,KAAK,cAAc,CAAC,IAAI,EAAE;YAChD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAkB,EAAE,WAAqB,EAAE,EAAE;gBAC7F,IAAI,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE;oBACpC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,WAAW,CAAC,CAAC;iBACrE;gBAED,OAAO,QAAQ,CAAC;YAClB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorTypes} from \"@tsed/core\";\nimport {matchGroups} from \"../../utils/matchGroups\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * Apply groups validation strategy for required property.\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function RequiredGroups(...groups: string[]): Function {\n return JsonEntityFn((entity) => {\n if (entity.decoratorType === DecoratorTypes.PROP) {\n entity.parent.schema.$hooks.on(\"requiredGroups\", (required: string[], givenGroups: string[]) => {\n if (matchGroups(groups, givenGroups)) {\n return required.filter((key: string) => key !== entity.propertyKey);\n }\n\n return required;\n });\n }\n });\n}\n"]}
1
+ {"version":3,"file":"requiredGroups.js","sourceRoot":"","sources":["../../../../src/decorators/common/requiredGroups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAG,MAAgB;IAChD,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAkB,EAAE,WAAqB,EAAE,EAAE;YAC7F,IAAI,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE;gBACpC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,WAAW,CAAC,CAAC;aACrE;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {matchGroups} from \"../../utils/matchGroups\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * Apply groups validation strategy for required property.\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function RequiredGroups(...groups: string[]): PropertyDecorator {\n return JsonEntityFn((entity) => {\n entity.parent.schema.$hooks.on(\"requiredGroups\", (required: string[], givenGroups: string[]) => {\n if (matchGroups(groups, givenGroups)) {\n return required.filter((key: string) => key !== entity.propertyKey);\n }\n\n return required;\n });\n });\n}\n"]}
@@ -16,6 +16,7 @@ export * from "./operations/deprecated";
16
16
  export * from "./operations/consumes";
17
17
  export * from "./operations/contentType";
18
18
  export * from "./operations/in";
19
+ export * from "./operations/inFile";
19
20
  export * from "./operations/operationId";
20
21
  export * from "./operations/operationPath";
21
22
  export * from "./operations/path";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,cAAc;AACd,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,WAAW;AACX,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAErC,aAAa;AACb,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAEnC,SAAS;AACT,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC","sourcesContent":["// class\nexport * from \"./class/children\";\n\n// collections\nexport * from \"./collections/collectionContains\";\nexport * from \"./collections/collectionOf\";\nexport * from \"./collections/maxItems\";\nexport * from \"./collections/minItems\";\nexport * from \"./collections/uniqueItems\";\nexport * from \"./collections/maxProperties\";\nexport * from \"./collections/minProperties\";\n\n// generics\nexport * from \"./generics/generics\";\nexport * from \"./generics/genericOf\";\n\n// operations\nexport * from \"./operations/deprecated\";\nexport * from \"./operations/consumes\";\nexport * from \"./operations/contentType\";\nexport * from \"./operations/in\";\nexport * from \"./operations/operationId\";\nexport * from \"./operations/operationPath\";\nexport * from \"./operations/path\";\nexport * from \"./operations/produces\";\nexport * from \"./operations/returns\";\nexport * from \"./operations/status\";\nexport * from \"./operations/header\";\nexport * from \"./operations/security\";\nexport * from \"./operations/tags\";\nexport * from \"./operations/summary\";\nexport * from \"./operations/partial\";\nexport * from \"./operations/redirect\";\nexport * from \"./operations/location\";\nexport * from \"./operations/route\";\n\n// common\nexport * from \"./common/additionalProperties\";\nexport * from \"./common/allow\";\nexport * from \"./common/any\";\nexport * from \"./common/integer\";\nexport * from \"./common/const\";\nexport * from \"./common/default\";\nexport * from \"./common/description\";\nexport * from \"./common/example\";\nexport * from \"./common/examples\";\nexport * from \"./common/enum\";\nexport * from \"./common/exclusiveMaximum\";\nexport * from \"./common/exclusiveMinimum\";\nexport * from \"./common/format\";\nexport * from \"./common/forwardGroups\";\nexport * from \"./common/groups\";\nexport * from \"./common/pattern\";\nexport * from \"./common/ignore\";\nexport * from \"./common/maximum\";\nexport * from \"./common/maxLength\";\nexport * from \"./common/minimum\";\nexport * from \"./common/minLength\";\nexport * from \"./common/multipleOf\";\nexport * from \"./common/name\";\nexport * from \"./common/required\";\nexport * from \"./common/requiredGroups\";\nexport * from \"./common/property\";\nexport * from \"./common/hidden\";\nexport * from \"./common/title\";\nexport * from \"./common/schema\";\nexport * from \"./common/oneOf\";\nexport * from \"./common/allOf\";\nexport * from \"./common/anyOf\";\nexport * from \"./common/jsonEntityFn\";\nexport * from \"./common/optional\";\nexport * from \"./common/writeOnly\";\nexport * from \"./common/readOnly\";\nexport * from \"./common/customKey\";\nexport * from \"./common/nullable\";\nexport * from \"./config/jsonEntityComponent\";\n"]}
1
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BAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC","sourcesContent":["// class\nexport * from \"./class/children\";\n\n// collections\nexport * from \"./collections/collectionContains\";\nexport * from \"./collections/collectionOf\";\nexport * from \"./collections/maxItems\";\nexport * from \"./collections/minItems\";\nexport * from \"./collections/uniqueItems\";\nexport * from \"./collections/maxProperties\";\nexport * from \"./collections/minProperties\";\n\n// generics\nexport * from \"./generics/generics\";\nexport * from \"./generics/genericOf\";\n\n// operations\nexport * from \"./operations/deprecated\";\nexport * from \"./operations/consumes\";\nexport * from \"./operations/contentType\";\nexport * from \"./operations/in\";\nexport * from \"./operations/inFile\";\nexport * from \"./operations/operationId\";\nexport * from \"./operations/operationPath\";\nexport * from \"./operations/path\";\nexport * from \"./operations/produces\";\nexport * from \"./operations/returns\";\nexport * from \"./operations/status\";\nexport * from \"./operations/header\";\nexport * from \"./operations/security\";\nexport * from \"./operations/tags\";\nexport * from \"./operations/summary\";\nexport * from \"./operations/partial\";\nexport * from \"./operations/redirect\";\nexport * from \"./operations/location\";\nexport * from \"./operations/route\";\n\n// common\nexport * from \"./common/additionalProperties\";\nexport * from \"./common/allow\";\nexport * from \"./common/any\";\nexport * from \"./common/integer\";\nexport * from \"./common/const\";\nexport * from \"./common/default\";\nexport * from \"./common/description\";\nexport * from \"./common/example\";\nexport * from \"./common/examples\";\nexport * from \"./common/enum\";\nexport * from \"./common/exclusiveMaximum\";\nexport * from \"./common/exclusiveMinimum\";\nexport * from \"./common/format\";\nexport * from \"./common/forwardGroups\";\nexport * from \"./common/groups\";\nexport * from \"./common/pattern\";\nexport * from \"./common/ignore\";\nexport * from \"./common/maximum\";\nexport * from \"./common/maxLength\";\nexport * from \"./common/minimum\";\nexport * from \"./common/minLength\";\nexport * from \"./common/multipleOf\";\nexport * from \"./common/name\";\nexport * from \"./common/required\";\nexport * from \"./common/requiredGroups\";\nexport * from \"./common/property\";\nexport * from \"./common/hidden\";\nexport * from \"./common/title\";\nexport * from \"./common/schema\";\nexport * from \"./common/oneOf\";\nexport * from \"./common/allOf\";\nexport * from \"./common/anyOf\";\nexport * from \"./common/jsonEntityFn\";\nexport * from \"./common/optional\";\nexport * from \"./common/writeOnly\";\nexport * from \"./common/readOnly\";\nexport * from \"./common/customKey\";\nexport * from \"./common/nullable\";\nexport * from \"./config/jsonEntityComponent\";\n"]}
@@ -0,0 +1,41 @@
1
+ import { Metadata, useDecorators, useMethodDecorators } from "@tsed/core";
2
+ import { In } from "./in";
3
+ import { JsonParameterTypes } from "../../domain/JsonParameterTypes";
4
+ import { Returns } from "./returns";
5
+ import { Name } from "../common/name";
6
+ import { Consumes } from "./consumes";
7
+ /**
8
+ * Add a input file parameter.
9
+ *
10
+ * ::: warning
11
+ * Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.
12
+ * But you can use this decorator on Method, to add extra in parameters like Authorization header.
13
+ *
14
+ * ```typescript
15
+ * @Controller("/")
16
+ * class MyController {
17
+ * @Post("/")
18
+ * method(@InFile("file1") file: any) {
19
+ * }
20
+ * }
21
+ * ```
22
+ * :::
23
+ *
24
+ * @decorator
25
+ * @swagger
26
+ * @schema
27
+ * @input
28
+ * @operation
29
+ * @param name
30
+ */
31
+ export function InFile(name) {
32
+ return (...args) => {
33
+ const [target, propertyKey, index] = args;
34
+ const multiple = Metadata.getParamTypes(target, propertyKey)[index] === Array;
35
+ name = (typeof name === "object" ? undefined : name);
36
+ const expression = [name, !multiple && "0"].filter(Boolean).join(".");
37
+ const decorators = useDecorators(In(JsonParameterTypes.FILES), Name(expression), useMethodDecorators(Returns(400).Description(`<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`), Consumes("multipart/form-data")));
38
+ decorators(...args);
39
+ };
40
+ }
41
+ //# sourceMappingURL=inFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inFile.js","sourceRoot":"","sources":["../../../../src/decorators/operations/inFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,aAAa,CAC9B,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAC5B,IAAI,CAAC,UAAU,CAAC,EAChB,mBAAmB,CACjB,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,CACtB,+KAA+K,CAChL,EACD,QAAQ,CAAC,qBAAqB,CAAC,CAChC,CACF,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters, Metadata, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {In} from \"./in\";\nimport {JsonParameterTypes} from \"../../domain/JsonParameterTypes\";\nimport {Returns} from \"./returns\";\nimport {Name} from \"../common/name\";\nimport {Consumes} from \"./consumes\";\n\n/**\n * Add a input file parameter.\n *\n * ::: warning\n * Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.\n * But you can use this decorator on Method, to add extra in parameters like Authorization header.\n *\n * ```typescript\n * @Controller(\"/\")\n * class MyController {\n * @Post(\"/\")\n * method(@InFile(\"file1\") file: any) {\n * }\n * }\n * ```\n * :::\n *\n * @decorator\n * @swagger\n * @schema\n * @input\n * @operation\n * @param name\n */\nexport function InFile(name: string): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n In(JsonParameterTypes.FILES),\n Name(expression),\n useMethodDecorators(\n Returns(400).Description(\n `<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`\n ),\n Consumes(\"multipart/form-data\")\n )\n );\n\n decorators(...args);\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isCollection, isObject, isPlainObject, isPrimitiveOrPrimitiveClass, isString } from "@tsed/core";
1
+ import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isArray, isCollection, isObject, isPlainObject, isPrimitiveOrPrimitiveClass, isString } from "@tsed/core";
2
2
  import { getStatusMessage } from "../../constants/httpStatusMessages";
3
3
  import { DecoratorContext } from "../../domain/DecoratorContext";
4
4
  import { JsonEntityStore } from "../../domain/JsonEntityStore";
@@ -34,6 +34,9 @@ class ReturnDecoratorContext extends DecoratorContext {
34
34
  "type",
35
35
  "status",
36
36
  "of",
37
+ "oneOf",
38
+ "allOf",
39
+ "anyOf",
37
40
  "nested",
38
41
  "header",
39
42
  "headers",
@@ -108,6 +111,33 @@ class ReturnDecoratorContext extends DecoratorContext {
108
111
  });
109
112
  return this;
110
113
  }
114
+ oneOf(...types) {
115
+ const model = this.get("model");
116
+ this.addAction(() => {
117
+ const schema = this.get("schema");
118
+ schema.type(model);
119
+ schema.itemSchema({ oneOf: types.map((type) => ({ type })) });
120
+ });
121
+ return this;
122
+ }
123
+ allOf(...types) {
124
+ const model = this.get("model");
125
+ this.addAction(() => {
126
+ const schema = this.get("schema");
127
+ schema.type(model);
128
+ schema.itemSchema({ allOf: types.map((type) => ({ type })) });
129
+ });
130
+ return this;
131
+ }
132
+ anyOf(...types) {
133
+ const model = this.get("model");
134
+ this.addAction(() => {
135
+ const schema = this.get("schema");
136
+ schema.type(model);
137
+ schema.itemSchema({ anyOf: types.map((type) => ({ type })) });
138
+ });
139
+ return this;
140
+ }
111
141
  schema(partial) {
112
142
  this.addAction(() => {
113
143
  const schema = this.get("schema");
@@ -190,7 +220,14 @@ class ReturnDecoratorContext extends DecoratorContext {
190
220
  const model = this.get("model");
191
221
  const media = response.getMedia(contentType || "*/*");
192
222
  const schema = media.get("schema") || new JsonSchema({ type: model });
193
- model && schema.type(model);
223
+ if (model) {
224
+ if (isArray(model)) {
225
+ schema.oneOf(model.map((type) => ({ type })));
226
+ }
227
+ else {
228
+ schema.type(model);
229
+ }
230
+ }
194
231
  this.set("schema", schema);
195
232
  media.schema(schema);
196
233
  media.groups = this.get("groups");