@tsed/schema 7.0.0-beta.8 → 7.0.0-rc.2

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 (142) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +1 -6
  3. package/lib/cjs/components/lazyRefMapper.js +1 -2
  4. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  5. package/lib/cjs/components/objectMapper.js +1 -1
  6. package/lib/cjs/components/objectMapper.js.map +1 -1
  7. package/lib/cjs/constants/httpStatusMessages.js +2 -4
  8. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  9. package/lib/cjs/decorators/collections/collectionOf.js +3 -4
  10. package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
  11. package/lib/cjs/decorators/common/description.js +1 -2
  12. package/lib/cjs/decorators/common/description.js.map +1 -1
  13. package/lib/cjs/decorators/operations/redirect.js +1 -2
  14. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  15. package/lib/cjs/decorators/operations/returns.js +43 -21
  16. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  17. package/lib/cjs/decorators/operations/route.js +1 -4
  18. package/lib/cjs/decorators/operations/route.js.map +1 -1
  19. package/lib/cjs/domain/DecoratorContext.js +6 -3
  20. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  21. package/lib/cjs/domain/JsonClassStore.js +4 -7
  22. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  23. package/lib/cjs/domain/JsonEntityStore.js +40 -1
  24. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  25. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  26. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  27. package/lib/cjs/domain/JsonMethodStore.js +19 -15
  28. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  29. package/lib/cjs/domain/JsonOperation.js +12 -16
  30. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  31. package/lib/cjs/domain/JsonOperationPathsMap.js +2 -16
  32. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  33. package/lib/cjs/domain/JsonOperationRoute.js +7 -8
  34. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  35. package/lib/cjs/domain/JsonParameter.js +4 -4
  36. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  37. package/lib/cjs/domain/JsonParameterStore.js +12 -5
  38. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  39. package/lib/cjs/domain/JsonPropertyStore.js +1 -4
  40. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  41. package/lib/cjs/domain/JsonResponse.js +6 -7
  42. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  43. package/lib/cjs/domain/JsonSchema.js +58 -60
  44. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  45. package/lib/cjs/hooks/alterIgnore.js +2 -3
  46. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  47. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  48. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  49. package/lib/cjs/utils/concatPath.js +16 -1
  50. package/lib/cjs/utils/concatPath.js.map +1 -1
  51. package/lib/cjs/utils/getJsonPathParameters.js +20 -6
  52. package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
  53. package/lib/cjs/utils/getJsonSchema.js +4 -5
  54. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  55. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  56. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  57. package/lib/cjs/utils/mapNullableType.js +1 -1
  58. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  59. package/lib/cjs/utils/mergeOperation.js +1 -2
  60. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  61. package/lib/cjs/utils/operationIdFormatter.js +3 -3
  62. package/lib/cjs/utils/operationIdFormatter.js.map +1 -1
  63. package/lib/cjs/utils/ref.js +2 -2
  64. package/lib/cjs/utils/ref.js.map +1 -1
  65. package/lib/cjs/utils/transformToOS2.js +2 -2
  66. package/lib/cjs/utils/transformToOS2.js.map +1 -1
  67. package/lib/esm/components/lazyRefMapper.js +1 -2
  68. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  69. package/lib/esm/components/objectMapper.js +1 -1
  70. package/lib/esm/components/objectMapper.js.map +1 -1
  71. package/lib/esm/constants/httpStatusMessages.js +2 -4
  72. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  73. package/lib/esm/decorators/collections/collectionOf.js +3 -4
  74. package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
  75. package/lib/esm/decorators/common/description.js +1 -2
  76. package/lib/esm/decorators/common/description.js.map +1 -1
  77. package/lib/esm/decorators/operations/redirect.js +1 -2
  78. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  79. package/lib/esm/decorators/operations/returns.js +43 -21
  80. package/lib/esm/decorators/operations/returns.js.map +1 -1
  81. package/lib/esm/decorators/operations/route.js +1 -4
  82. package/lib/esm/decorators/operations/route.js.map +1 -1
  83. package/lib/esm/domain/DecoratorContext.js +5 -2
  84. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  85. package/lib/esm/domain/JsonClassStore.js +4 -7
  86. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  87. package/lib/esm/domain/JsonEntityStore.js +40 -1
  88. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  89. package/lib/esm/domain/JsonLazyRef.js +2 -1
  90. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  91. package/lib/esm/domain/JsonMethodStore.js +19 -15
  92. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  93. package/lib/esm/domain/JsonOperation.js +12 -16
  94. package/lib/esm/domain/JsonOperation.js.map +1 -1
  95. package/lib/esm/domain/JsonOperationPathsMap.js +2 -16
  96. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  97. package/lib/esm/domain/JsonOperationRoute.js +7 -8
  98. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  99. package/lib/esm/domain/JsonParameter.js +4 -4
  100. package/lib/esm/domain/JsonParameter.js.map +1 -1
  101. package/lib/esm/domain/JsonParameterStore.js +12 -5
  102. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  103. package/lib/esm/domain/JsonPropertyStore.js +1 -4
  104. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  105. package/lib/esm/domain/JsonResponse.js +6 -7
  106. package/lib/esm/domain/JsonResponse.js.map +1 -1
  107. package/lib/esm/domain/JsonSchema.js +58 -60
  108. package/lib/esm/domain/JsonSchema.js.map +1 -1
  109. package/lib/esm/hooks/alterIgnore.js +2 -3
  110. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  111. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  112. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  113. package/lib/esm/utils/concatPath.js +16 -1
  114. package/lib/esm/utils/concatPath.js.map +1 -1
  115. package/lib/esm/utils/getJsonPathParameters.js +20 -6
  116. package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
  117. package/lib/esm/utils/getJsonSchema.js +4 -5
  118. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  119. package/lib/esm/utils/getRequiredProperties.js +3 -3
  120. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  121. package/lib/esm/utils/mapNullableType.js +1 -1
  122. package/lib/esm/utils/mapNullableType.js.map +1 -1
  123. package/lib/esm/utils/mergeOperation.js +1 -2
  124. package/lib/esm/utils/mergeOperation.js.map +1 -1
  125. package/lib/esm/utils/operationIdFormatter.js +1 -1
  126. package/lib/esm/utils/operationIdFormatter.js.map +1 -1
  127. package/lib/esm/utils/ref.js +1 -1
  128. package/lib/esm/utils/ref.js.map +1 -1
  129. package/lib/esm/utils/transformToOS2.js +2 -2
  130. package/lib/esm/utils/transformToOS2.js.map +1 -1
  131. package/lib/types/decorators/operations/returns.d.ts +7 -2
  132. package/lib/types/domain/JsonEntityStore.d.ts +1 -0
  133. package/lib/types/domain/JsonMethodStore.d.ts +5 -2
  134. package/lib/types/domain/JsonOperation.d.ts +0 -1
  135. package/lib/types/domain/JsonOperationPathsMap.d.ts +0 -2
  136. package/lib/types/domain/JsonOperationRoute.d.ts +2 -3
  137. package/lib/types/domain/JsonResponse.d.ts +1 -0
  138. package/lib/types/utils/concatPath.d.ts +1 -1
  139. package/lib/types/utils/getJsonSchema.d.ts +1 -1
  140. package/package.json +13 -11
  141. package/readme.md +3 -2
  142. package/tsconfig.compile.esm.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/utils/ref.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC,mDAA8C;AAE9C,qCAAuC;AAEvC;;;GAGG;AACH,SAAS,OAAO,CAAC,OAA0B;IACzC,MAAM,EAAC,IAAI,GAAG,KAAK,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,aAAa,EAAE,EAAC,GAAG,OAAO,CAAC;IAEvG,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,OAA0B;IACpE,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3C,OAAO,IAAA,wBAAU,EAAC,GAAG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;KAC1D;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAND,sCAMC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,MAAkB,EAAE,OAA0B;IACpF,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG;QACV,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,EAAE;KACxB,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;IAErC,IAAI,QAAQ,IAAI,QAAQ,IAAI,SAAS,EAAE;QACrC,QAAQ,OAAO,CAAC,QAAQ,EAAE;YACxB,KAAK,qBAAS,CAAC,OAAO;gBACpB,OAAO,IAAA,kBAAW,EAAC;oBACjB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;oBACrC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;oBACrC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;oBACvC,KAAK,EAAE,CAAC,GAAG,CAAC;iBACb,CAAC,CAAC;YACL,KAAK,qBAAS,CAAC,IAAI;gBACjB,OAAO,IAAA,kBAAW,EAAC;oBACjB,QAAQ;oBACR,SAAS;oBACT,KAAK,EAAE,CAAC,GAAG,CAAC;iBACb,CAAC,CAAC;SACN;KACF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AA7BD,8BA6BC;AAED;;GAEG;AACH,SAAgB,KAAK,CAAC,KAAiB,EAAE,MAAW,EAAE,OAA0B;IAC9E,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,CAAC,OAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3C,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAND,sBAMC","sourcesContent":["import {pascalCase} from \"pascal-case\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {cleanObject} from \"@tsed/core\";\n\n/**\n * ignore\n * @param options\n */\nfunction getHost(options: JsonSchemaOptions) {\n const {host = `#/${options.specType === \"openapi3\" ? \"components/schemas\" : \"definitions\"}`} = options;\n\n return host;\n}\n\n/**\n * @ignore\n */\nexport function createRefName(name: string, options: JsonSchemaOptions) {\n if (options.groups && options.groups.length) {\n return pascalCase(`${name} ${options.groups.join(\" \")}`);\n }\n\n return name;\n}\n\n/**\n * @ignore\n */\nexport function createRef(name: string, schema: JsonSchema, options: JsonSchemaOptions) {\n const host = getHost(options);\n const ref = {\n $ref: `${host}/${name}`\n };\n\n const nullable = schema.isNullable;\n const readOnly = schema.isReadOnly;\n const writeOnly = schema.isWriteOnly;\n\n if (nullable || readOnly || writeOnly) {\n switch (options.specType) {\n case SpecTypes.OPENAPI:\n return cleanObject({\n nullable: nullable ? true : undefined,\n readOnly: readOnly ? true : undefined,\n writeOnly: writeOnly ? true : undefined,\n oneOf: [ref]\n });\n case SpecTypes.JSON:\n return cleanObject({\n readOnly,\n writeOnly,\n oneOf: [ref]\n });\n }\n }\n\n return ref;\n}\n\n/**\n * @ignore\n */\nexport function toRef(value: JsonSchema, schema: any, options: JsonSchemaOptions) {\n const name = createRefName(value.getName(), options);\n\n options.schemas![value.getName()] = schema;\n\n return createRef(name, value, options);\n}\n"]}
1
+ {"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/utils/ref.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC,mDAA8C;AAE9C,qCAAuC;AAEvC;;;GAGG;AACH,SAAS,OAAO,CAAC,OAA0B;IACzC,MAAM,EAAC,IAAI,GAAG,KAAK,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,aAAa,EAAE,EAAC,GAAG,OAAO,CAAC;IAEvG,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,OAA0B;IACpE,IAAI,OAAO,C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gB,KAAK,CAAC,KAAiB,EAAE,MAAW,EAAE,OAA0B;IAC9E,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,CAAC,OAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3C,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAND,sBAMC","sourcesContent":["import {pascalCase} from \"change-case\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {cleanObject} from \"@tsed/core\";\n\n/**\n * ignore\n * @param options\n */\nfunction getHost(options: JsonSchemaOptions) {\n const {host = `#/${options.specType === \"openapi3\" ? \"components/schemas\" : \"definitions\"}`} = options;\n\n return host;\n}\n\n/**\n * @ignore\n */\nexport function createRefName(name: string, options: JsonSchemaOptions) {\n if (options.groups && options.groups.length) {\n return pascalCase(`${name} ${options.groups.join(\" \")}`);\n }\n\n return name;\n}\n\n/**\n * @ignore\n */\nexport function createRef(name: string, schema: JsonSchema, options: JsonSchemaOptions) {\n const host = getHost(options);\n const ref = {\n $ref: `${host}/${name}`\n };\n\n const nullable = schema.isNullable;\n const readOnly = schema.isReadOnly;\n const writeOnly = schema.isWriteOnly;\n\n if (nullable || readOnly || writeOnly) {\n switch (options.specType) {\n case SpecTypes.OPENAPI:\n return cleanObject({\n nullable: nullable ? true : undefined,\n readOnly: readOnly ? true : undefined,\n writeOnly: writeOnly ? true : undefined,\n oneOf: [ref]\n });\n case SpecTypes.JSON:\n return cleanObject({\n readOnly,\n writeOnly,\n oneOf: [ref]\n });\n }\n }\n\n return ref;\n}\n\n/**\n * @ignore\n */\nexport function toRef(value: JsonSchema, schema: any, options: JsonSchemaOptions) {\n const name = createRefName(value.getName(), options);\n\n options.schemas![value.getName()] = schema;\n\n return createRef(name, value, options);\n}\n"]}
@@ -123,6 +123,7 @@ function transformInformation(server) {
123
123
  }
124
124
  exports.transformInformation = transformInformation;
125
125
  class Converter {
126
+ spec;
126
127
  constructor(spec) {
127
128
  this.spec = JSON.parse(JSON.stringify(spec));
128
129
  }
@@ -214,7 +215,6 @@ class Converter {
214
215
  if (param.schema.type === "object" && param.schema.properties) {
215
216
  const required = param.schema.required || [];
216
217
  Object.keys(param.schema.properties).forEach((name) => {
217
- var _a;
218
218
  const schema = param.schema.properties[name];
219
219
  // readOnly properties should not be sent in requests
220
220
  if (!schema.readOnly) {
@@ -226,7 +226,7 @@ class Converter {
226
226
  if (required.indexOf(name) >= 0) {
227
227
  formDataParam.required = true;
228
228
  }
229
- (_a = operation.parameters) === null || _a === void 0 ? void 0 : _a.push(formDataParam);
229
+ operation.parameters?.push(formDataParam);
230
230
  }
231
231
  });
232
232
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transformToOS2.js","sourceRoot":"","sources":["../../../src/utils/transformToOS2.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qCAAuC;AAEvC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC3F,MAAM,iBAAiB,GAAG;IACxB,QAAQ;IACR,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,YAAY;IACZ,UAAU;IACV,UAAU;IACV,aAAa;IACb,eAAe;IACf,eAAe;IACf,sBAAsB;IACtB,SAAS;IACT,MAAM;IACN,SAAS;CACV,CAAC;AACF,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,MAAM,sBAAsB,GAAG,iEAAiE,CAAC;AACjG,MAAM,oBAAoB,GAAwB;IAChD,4BAA4B,EAAE,mCAAmC;IACjE,m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C,IAAI,CAAC,qBAAqB,eAAe,QAAQ,OAAO,4BAA4B,CAAC,CAAC;aAC/F;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,0BAA0B;QACxB,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YACxF,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;SAC7C;IACH,CAAC;CACF;AA5cD,8BA4cC;AAED,SAAgB,cAAc,CAAC,IAAS;IACtC,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACvC,CAAC;AAFD,wCAEC","sourcesContent":["\"use strict\";\nimport {OpenSpec2, OpenSpec3, OS3Operation} from \"@tsed/openspec\";\nimport {cleanObject} from \"@tsed/core\";\n\nconst HTTP_METHODS = [\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"];\nconst SCHEMA_PROPERTIES = [\n \"format\",\n \"minimum\",\n \"maximum\",\n \"exclusiveMinimum\",\n \"exclusiveMaximum\",\n \"minLength\",\n \"maxLength\",\n \"multipleOf\",\n \"minItems\",\n \"maxItems\",\n \"uniqueItems\",\n \"minProperties\",\n \"maxProperties\",\n \"additionalProperties\",\n \"pattern\",\n \"enum\",\n \"default\"\n];\nconst ARRAY_PROPERTIES = [\"type\", \"items\"];\n\nconst APPLICATION_JSON_REGEX = /^(application\\/json|[^;\\/ \\t]+\\/[^;\\/ \\t]+[+]json)[ \\t]*(;.*)?$/;\nconst SUPPORTED_MIME_TYPES: Record<string, any> = {\n APPLICATION_X_WWW_URLENCODED: \"application/x-www-form-urlencoded\",\n MULTIPART_FORM_DATA: \"multipart/form-data\"\n};\n\nfunction fixRef(ref: string) {\n return ref.replace(\"#/components/schemas/\", \"#/definitions/\").replace(\"#/components/\", \"#/x-components/\");\n}\n\nfunction fixRefs(obj: any) {\n if (Array.isArray(obj)) {\n obj.forEach(fixRefs);\n } else if (typeof obj === \"object\") {\n for (let key in obj) {\n if (key === \"$ref\") {\n obj.$ref = fixRef(obj.$ref);\n } else {\n fixRefs(obj[key]);\n }\n }\n }\n}\n\nfunction isJsonMimeType(type: string) {\n return new RegExp(APPLICATION_JSON_REGEX, \"i\").test(type);\n}\n\nfunction getSupportedMimeTypes(content: any) {\n const MIME_VALUES = Object.keys(SUPPORTED_MIME_TYPES).map((key) => {\n return SUPPORTED_MIME_TYPES[key];\n });\n return Object.keys(content).filter((key) => {\n return MIME_VALUES.indexOf(key) > -1 || isJsonMimeType(key);\n });\n}\n\nexport function transformSecurity(securitySchemes: any) {\n function map(security: any) {\n const {scheme, type, name, bearerFormat, flows, ...props} = security;\n\n switch (type) {\n case \"http\":\n if (scheme === \"basic\") {\n return {\n ...props,\n type: scheme\n };\n }\n\n if (scheme === \"bearer\") {\n return {\n ...props,\n type: \"apiKey\",\n name: \"Authorization\",\n in: \"header\"\n };\n }\n break;\n case \"oauth2\":\n const flowName = Object.keys(flows)[0];\n const flow = flows[flowName];\n let flowType = flowName;\n\n if (flowType === \"clientCredentials\") {\n flowType = \"application\";\n } else if (flowType === \"authorizationCode\") {\n flowType = \"accessCode\";\n }\n\n return {\n type,\n flow: flowType,\n authorizationUrl: flow.authorizationUrl,\n tokenUrl: flow.tokenUrl,\n scopes: flow.scopes\n };\n }\n }\n\n return Object.entries(securitySchemes).reduce((securityDefinitions, [key, security]) => {\n return {\n ...securityDefinitions,\n [key]: map(security)\n };\n }, {});\n}\n\nexport function transformInformation(server: any) {\n let serverUrl = server.url;\n\n const variables = server[\"variables\"] || {};\n\n for (const variable in variables) {\n const variableObject = variables[variable] || {};\n if (variableObject[\"default\"]) {\n const re = RegExp(`{${variable}}`, \"g\");\n serverUrl = serverUrl.replace(re, variableObject[\"default\"]);\n }\n }\n\n const url = new URL(serverUrl);\n\n return {\n host: url.host ? url.host : undefined,\n basePath: url.pathname,\n schemes: url.protocol !== null ? [url.protocol.substring(0, url.protocol.length - 1)] : undefined\n };\n}\n\nexport class Converter {\n private spec: any;\n\n constructor(spec: Partial<OpenSpec3>) {\n this.spec = JSON.parse(JSON.stringify(spec));\n }\n\n convertInfos() {\n const server = this.spec.servers && this.spec.servers[0];\n\n if (server) {\n return transformInformation(server);\n }\n\n return {};\n }\n\n resolveReference(base: any, obj: any, shouldClone: boolean) {\n if (!obj || !obj.$ref) {\n return obj;\n }\n\n const ref: string = obj.$ref;\n\n if (ref.startsWith(\"#\")) {\n const keys = ref.split(\"/\").map((k) => k.replace(/~1/g, \"/\").replace(/~0/g, \"~\"));\n keys.shift();\n\n let cur = base;\n keys.forEach((k) => {\n cur = cur[k];\n });\n\n return shouldClone ? JSON.parse(JSON.stringify(cur)) : cur;\n }\n }\n\n convert() {\n const spec = {\n swagger: \"2.0\",\n ...this.convertInfos(),\n paths: this.spec.paths ? this.convertOperations(this.spec.paths, this.spec) : undefined\n };\n\n if (this.spec.components) {\n this.convertSchemas();\n this.convertSecurityDefinitions();\n\n this.spec[\"x-components\"] = this.spec.components;\n delete this.spec.components;\n\n fixRefs(this.spec);\n }\n\n delete this.spec.servers;\n delete this.spec.openapi;\n delete this.spec[\"x-components\"];\n\n return cleanObject({\n ...spec,\n ...this.spec\n });\n }\n\n convertOperations(paths: any, spec: any) {\n return Object.entries(paths).reduce((paths, [path, operation]) => {\n const pathObject = (paths[path] = this.resolveReference({...spec, paths}, operation, true));\n\n this.convertParameters(pathObject); // converts common parameters\n\n Object.keys(pathObject).forEach((method) => {\n if (HTTP_METHODS.indexOf(method) >= 0) {\n const operation = (pathObject[method] = this.resolveReference({...spec, paths}, pathObject[method], true));\n\n this.convertOperationParameters(operation);\n this.convertResponses(operation);\n }\n });\n\n return paths;\n }, paths);\n }\n\n convertOperationParameters(operation: OS3Operation) {\n let content, contentKey, mediaRanges, mediaTypes;\n operation.parameters = operation.parameters || [];\n\n if (operation.requestBody) {\n let param = this.resolveReference(this.spec, operation.requestBody, true);\n\n // fixing external $ref in body\n if (operation.requestBody.content) {\n const type = getSupportedMimeTypes(operation.requestBody.content)[0];\n const structuredObj: any = {content: {}};\n const data = operation.requestBody.content[type];\n\n if (data && data.schema && data.schema.$ref && !data.schema.$ref.startsWith(\"#\")) {\n param = this.resolveReference(this.spec, data.schema, true);\n structuredObj[\"content\"][`${type}`] = {schema: param};\n param = structuredObj;\n }\n }\n\n param.name = \"body\";\n content = param.content;\n\n if (content && Object.keys(content).length) {\n mediaRanges = Object.keys(content).filter((mediaRange) => mediaRange.indexOf(\"/\") > 0);\n mediaTypes = mediaRanges.filter((range) => range.indexOf(\"*\") < 0);\n contentKey = getSupportedMimeTypes(content)[0];\n\n delete param.content;\n\n if ([SUPPORTED_MIME_TYPES.APPLICATION_X_WWW_URLENCODED, SUPPORTED_MIME_TYPES.MULTIPART_FORM_DATA].includes(contentKey)) {\n (operation as any).consumes = mediaTypes;\n\n param.in = \"formData\";\n param.schema = content[contentKey].schema;\n param.schema = this.resolveReference(this.spec, param.schema, true);\n\n if (param.schema.type === \"object\" && param.schema.properties) {\n const required = param.schema.required || [];\n\n Object.keys(param.schema.properties).forEach((name) => {\n const schema = param.schema.properties[name];\n\n // readOnly properties should not be sent in requests\n if (!schema.readOnly) {\n const formDataParam: any = {\n name,\n in: \"formData\",\n schema\n };\n if (required.indexOf(name) >= 0) {\n formDataParam.required = true;\n }\n\n operation.parameters?.push(formDataParam);\n }\n });\n } else {\n operation.parameters.push(param);\n }\n } else if (contentKey) {\n (operation as any).consumes = mediaTypes;\n param.in = \"body\";\n param.schema = content[contentKey].schema;\n operation.parameters.push(param);\n } else if (mediaRanges) {\n (operation as any).consumes = mediaTypes || [\"application/octet-stream\"];\n param.in = \"body\";\n param.name = param.name || \"file\";\n delete param.type;\n\n param.schema = content[mediaRanges[0]].schema || {\n type: \"string\",\n format: \"binary\"\n };\n\n operation.parameters.push(param);\n }\n\n if (param.schema) {\n this.convertSchema(param.schema, \"request\");\n }\n }\n\n delete operation.requestBody;\n }\n this.convertParameters(operation);\n }\n\n convertParameters(obj: any) {\n if (obj.parameters === undefined) {\n return;\n }\n\n obj.parameters = obj.parameters || [];\n\n (obj.parameters || []).forEach((param: any, i: number) => {\n param = obj.parameters[i] = this.resolveReference(this.spec, param, false);\n\n if (param.in !== \"body\") {\n this.copySchemaProperties(param, SCHEMA_PROPERTIES);\n this.copySchemaProperties(param, ARRAY_PROPERTIES);\n this.copySchemaXProperties(param);\n\n if (!param.description) {\n const schema = this.resolveReference(this.spec, param.schema, false);\n if (!!schema && schema.description) {\n param.description = schema.description;\n }\n }\n\n if (param.example !== undefined) {\n param[\"x-example\"] = param.example;\n }\n\n delete param.schema;\n delete param.allowReserved;\n delete param.example;\n }\n\n if (param.type === \"array\") {\n let style = param.style || (param.in === \"query\" || param.in === \"cookie\" ? \"form\" : \"simple\");\n\n switch (style) {\n case \"matrix\":\n param.collectionFormat = param.explode ? undefined : \"csv\";\n break;\n case \"label\":\n param.collectionFormat = undefined;\n break;\n case \"simple\":\n param.collectionFormat = \"csv\";\n break;\n case \"spaceDelimited\":\n param.collectionFormat = \"ssv\";\n break;\n case \"pipeDelimited\":\n param.collectionFormat = \"pipes\";\n break;\n case \"deepOpbject\":\n param.collectionFormat = \"multi\";\n break;\n case \"form\":\n param.collectionFormat = param.explode === false ? \"csv\" : \"multi\";\n break;\n }\n }\n\n delete param.style;\n delete param.explode;\n });\n }\n\n copySchemaProperties(obj: any, props: any[]) {\n let schema = this.resolveReference(this.spec, obj.schema, true);\n\n if (!schema) {\n return;\n }\n\n props.forEach((prop) => {\n const value = schema[prop];\n\n if (prop === \"additionalProperties\" && typeof value === \"boolean\") {\n return;\n }\n\n if (value !== undefined) {\n obj[prop] = value;\n }\n });\n }\n\n copySchemaXProperties(obj: Record<string, any>) {\n let schema = this.resolveReference(this.spec, obj.schema, true);\n if (!schema) {\n return;\n }\n\n Object.keys(schema).forEach((propName) => {\n if (Reflect.hasOwnProperty.call(schema, propName) && !Reflect.hasOwnProperty.call(obj, propName) && propName.startsWith(\"x-\")) {\n obj[propName] = schema[propName];\n }\n });\n }\n\n convertResponses(operation: Record<string, any>) {\n // var anySchema, code, content, jsonSchema, mediaRange, mediaType, response, resolved, headers\n\n Object.keys(operation.responses || {}).forEach((code) => {\n const response = (operation.responses[code] = this.resolveReference(this.spec, operation.responses[code], true));\n\n if (response.content) {\n let anySchema: any = null;\n let jsonSchema: any = null;\n\n Object.keys(response.content).forEach((mediaRange) => {\n // produces and examples only allow media types, not ranges\n // use application/octet-stream as a catch-all type\n const mediaType = mediaRange.indexOf(\"*\") < 0 ? mediaRange : \"application/octet-stream\";\n\n if (!operation.produces) {\n operation.produces = [mediaType];\n } else if (operation.produces.indexOf(mediaType) < 0) {\n operation.produces.push(mediaType);\n }\n\n const content = response.content[mediaRange];\n anySchema = anySchema || content.schema;\n\n if (!jsonSchema && isJsonMimeType(mediaType)) {\n jsonSchema = content.schema;\n }\n\n if (content.example) {\n response.examples = response.examples || {};\n response.examples[mediaType] = content.example;\n }\n });\n\n if (anySchema) {\n response.schema = jsonSchema || anySchema;\n const resolved = this.resolveReference(this.spec, response.schema, true);\n\n if (resolved && response.schema.$ref && !response.schema.$ref.startsWith(\"#\")) {\n response.schema = resolved;\n }\n\n this.convertSchema(response.schema, \"response\");\n }\n }\n\n Object.keys(response.headers || {}).forEach((header) => {\n // Always resolve headers when converting to v2.\n const resolved = this.resolveReference(this.spec, response.headers[header], true);\n\n // Headers should be converted like parameters.\n if (resolved.schema) {\n resolved.type = resolved.schema.type;\n resolved.format = resolved.schema.format;\n delete resolved.schema;\n }\n\n response.headers[header] = resolved;\n });\n\n delete response.content;\n });\n }\n\n convertSchema(def: any, operationDirection?: any) {\n if (def.oneOf) {\n delete def.oneOf;\n\n if (def.discriminator) {\n delete def.discriminator;\n }\n }\n\n if (def.anyOf) {\n delete def.anyOf;\n\n if (def.discriminator) {\n delete def.discriminator;\n }\n }\n\n if (def.allOf) {\n for (const i in def.allOf) {\n this.convertSchema(def.allOf[i], operationDirection);\n }\n }\n\n if (def.discriminator) {\n if (def.discriminator.mapping) {\n this.convertDiscriminatorMapping(def.discriminator.mapping);\n }\n\n def.discriminator = def.discriminator.propertyName;\n }\n\n switch (def.type) {\n case \"object\":\n if (def.properties) {\n Object.keys(def.properties).forEach((propName) => {\n if (def.properties[propName].writeOnly === true && operationDirection === \"response\") {\n delete def.properties[propName];\n } else {\n this.convertSchema(def.properties[propName], operationDirection);\n delete def.properties[propName].writeOnly;\n }\n });\n }\n break;\n case \"array\":\n if (def.items) {\n this.convertSchema(def.items, operationDirection);\n }\n }\n\n if (def.nullable) {\n def[\"x-nullable\"] = true;\n delete def.nullable;\n }\n\n // OpenAPI 3 has boolean \"deprecated\" on Schema, OpenAPI 2 does not\n // Convert to x-deprecated for Autorest (and perhaps others)\n if (def[\"deprecated\"] !== undefined) {\n // Move to x-deprecated, unless it is already defined\n if (def[\"x-deprecated\"] === undefined) {\n def[\"x-deprecated\"] = def.deprecated;\n }\n delete def.deprecated;\n }\n }\n\n convertSchemas() {\n this.spec.definitions = this.spec.components.schemas;\n\n Object.keys(this.spec.definitions || {}).forEach((defName) => {\n this.convertSchema(this.spec.definitions[defName]);\n });\n\n delete this.spec.components.schemas;\n }\n\n convertDiscriminatorMapping(mapping: any) {\n Object.keys(mapping).forEach((payload) => {\n const schemaNameOrRef = mapping[payload];\n\n if (typeof schemaNameOrRef !== \"string\") {\n console.warn(`Ignoring ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);\n return;\n }\n\n // payload may be a schema name or JSON Reference string.\n // OAS3 spec limits schema names to ^[a-zA-Z0-9._-]+$\n // Note: Valid schema name could be JSON file name without extension.\n // Prefer schema name, with file name as fallback.\n let schema;\n if (/^[a-zA-Z0-9._-]+$/.test(schemaNameOrRef)) {\n try {\n schema = this.resolveReference(this.spec, {$ref: `#/components/schemas/${schemaNameOrRef}`}, false);\n } catch (err) {\n console.debug(`Error resolving ${schemaNameOrRef} for ${payload} as schema name in discriminator.mapping: ${err}`);\n }\n }\n\n // schemaNameRef is not a schema name. Try to resolve as JSON Ref.\n if (!schema) {\n try {\n schema = this.resolveReference(this.spec, {$ref: schemaNameOrRef}, false);\n } catch (err) {\n console.debug(`Error resolving ${schemaNameOrRef} for ${payload} in discriminator.mapping: ${err}`);\n }\n }\n\n if (schema) {\n // Swagger Codegen + OpenAPI Generator extension\n // https://github.com/swagger-api/swagger-codegen/pull/4252\n schema[\"x-discriminator-value\"] = payload;\n\n // AutoRest extension\n // https://github.com/Azure/autorest/pull/474\n schema[\"x-ms-discriminator-value\"] = payload;\n } else {\n console.warn(`Unable to resolve ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);\n }\n });\n }\n\n convertSecurityDefinitions() {\n if (this.spec.components.securitySchemes) {\n this.spec.securityDefinitions = transformSecurity(this.spec.components.securitySchemes);\n delete this.spec.components.securitySchemes;\n }\n }\n}\n\nexport function transformToOS2(spec: any): Partial<OpenSpec2> {\n return new Converter(spec).convert();\n}\n"]}
1
+ {"version":3,"file":"transformToOS2.js","sourceRoot":"","sources":["../../../src/utils/transformToOS2.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qCAAuC;AAEvC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC3F,MAAM,iBAAiB,GAAG;IACxB,QAAQ;IACR,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,YAAY;IACZ,UAAU;IACV,UAAU;IACV,aAAa;IACb,eAAe;IACf,eAAe;IACf,sBAAsB;IACtB,SAAS;IACT,MAAM;IACN,SAAS;CACV,CAAC;AACF,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,MAAM,sBAAsB,GAAG,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6C;gBAC7C,MAAM,CAAC,0BAA0B,CAAC,GAAG,OAAO,CAAC;aAC9C;iBAAM;gBACL,OAAO,CAAC,IAAI,CAAC,qBAAqB,eAAe,QAAQ,OAAO,4BAA4B,CAAC,CAAC;aAC/F;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,0BAA0B;QACxB,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YACxF,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;SAC7C;IACH,CAAC;CACF;AA5cD,8BA4cC;AAED,SAAgB,cAAc,CAAC,IAAS;IACtC,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACvC,CAAC;AAFD,wCAEC","sourcesContent":["\"use strict\";\nimport {OpenSpec2, OpenSpec3, OS3Operation} from \"@tsed/openspec\";\nimport {cleanObject} from \"@tsed/core\";\n\nconst HTTP_METHODS = [\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"];\nconst SCHEMA_PROPERTIES = [\n \"format\",\n \"minimum\",\n \"maximum\",\n \"exclusiveMinimum\",\n \"exclusiveMaximum\",\n \"minLength\",\n \"maxLength\",\n \"multipleOf\",\n \"minItems\",\n \"maxItems\",\n \"uniqueItems\",\n \"minProperties\",\n \"maxProperties\",\n \"additionalProperties\",\n \"pattern\",\n \"enum\",\n \"default\"\n];\nconst ARRAY_PROPERTIES = [\"type\", \"items\"];\n\nconst APPLICATION_JSON_REGEX = /^(application\\/json|[^;\\/ \\t]+\\/[^;\\/ \\t]+[+]json)[ \\t]*(;.*)?$/;\nconst SUPPORTED_MIME_TYPES: Record<string, any> = {\n APPLICATION_X_WWW_URLENCODED: \"application/x-www-form-urlencoded\",\n MULTIPART_FORM_DATA: \"multipart/form-data\"\n};\n\nfunction fixRef(ref: string) {\n return ref.replace(\"#/components/schemas/\", \"#/definitions/\").replace(\"#/components/\", \"#/x-components/\");\n}\n\nfunction fixRefs(obj: any) {\n if (Array.isArray(obj)) {\n obj.forEach(fixRefs);\n } else if (typeof obj === \"object\") {\n for (let key in obj) {\n if (key === \"$ref\") {\n obj.$ref = fixRef(obj.$ref);\n } else {\n fixRefs(obj[key]);\n }\n }\n }\n}\n\nfunction isJsonMimeType(type: string) {\n return new RegExp(APPLICATION_JSON_REGEX, \"i\").test(type);\n}\n\nfunction getSupportedMimeTypes(content: any) {\n const MIME_VALUES = Object.keys(SUPPORTED_MIME_TYPES).map((key) => {\n return SUPPORTED_MIME_TYPES[key];\n });\n return Object.keys(content).filter((key) => {\n return MIME_VALUES.indexOf(key) > -1 || isJsonMimeType(key);\n });\n}\n\nexport function transformSecurity(securitySchemes: any) {\n function map(security: any) {\n const {scheme, type, name, bearerFormat, flows, ...props} = security;\n\n switch (type) {\n case \"http\":\n if (scheme === \"basic\") {\n return {\n ...props,\n type: scheme\n };\n }\n\n if (scheme === \"bearer\") {\n return {\n ...props,\n type: \"apiKey\",\n name: \"Authorization\",\n in: \"header\"\n };\n }\n break;\n case \"oauth2\":\n const flowName = Object.keys(flows)[0];\n const flow = flows[flowName];\n let flowType = flowName;\n\n if (flowType === \"clientCredentials\") {\n flowType = \"application\";\n } else if (flowType === \"authorizationCode\") {\n flowType = \"accessCode\";\n }\n\n return {\n type,\n flow: flowType,\n authorizationUrl: flow.authorizationUrl,\n tokenUrl: flow.tokenUrl,\n scopes: flow.scopes\n };\n }\n }\n\n return Object.entries(securitySchemes).reduce((securityDefinitions, [key, security]) => {\n return {\n ...securityDefinitions,\n [key]: map(security)\n };\n }, {});\n}\n\nexport function transformInformation(server: any) {\n let serverUrl = server.url;\n\n const variables = server[\"variables\"] || {};\n\n for (const variable in variables) {\n const variableObject = variables[variable] || {};\n if (variableObject[\"default\"]) {\n const re = RegExp(`{${variable}}`, \"g\");\n serverUrl = serverUrl.replace(re, variableObject[\"default\"]);\n }\n }\n\n const url = new URL(serverUrl);\n\n return {\n host: url.host ? url.host : undefined,\n basePath: url.pathname,\n schemes: url.protocol !== null ? [url.protocol.substring(0, url.protocol.length - 1)] : undefined\n };\n}\n\nexport class Converter {\n private spec: any;\n\n constructor(spec: Partial<OpenSpec3>) {\n this.spec = JSON.parse(JSON.stringify(spec));\n }\n\n convertInfos() {\n const server = this.spec.servers && this.spec.servers[0];\n\n if (server) {\n return transformInformation(server);\n }\n\n return {};\n }\n\n resolveReference(base: any, obj: any, shouldClone: boolean) {\n if (!obj || !obj.$ref) {\n return obj;\n }\n\n const ref: string = obj.$ref;\n\n if (ref.startsWith(\"#\")) {\n const keys = ref.split(\"/\").map((k) => k.replace(/~1/g, \"/\").replace(/~0/g, \"~\"));\n keys.shift();\n\n let cur = base;\n keys.forEach((k) => {\n cur = cur[k];\n });\n\n return shouldClone ? JSON.parse(JSON.stringify(cur)) : cur;\n }\n }\n\n convert() {\n const spec = {\n swagger: \"2.0\",\n ...this.convertInfos(),\n paths: this.spec.paths ? this.convertOperations(this.spec.paths, this.spec) : undefined\n };\n\n if (this.spec.components) {\n this.convertSchemas();\n this.convertSecurityDefinitions();\n\n this.spec[\"x-components\"] = this.spec.components;\n delete this.spec.components;\n\n fixRefs(this.spec);\n }\n\n delete this.spec.servers;\n delete this.spec.openapi;\n delete this.spec[\"x-components\"];\n\n return cleanObject({\n ...spec,\n ...this.spec\n });\n }\n\n convertOperations(paths: any, spec: any) {\n return Object.entries(paths).reduce((paths, [path, operation]) => {\n const pathObject = (paths[path] = this.resolveReference({...spec, paths}, operation, true));\n\n this.convertParameters(pathObject); // converts common parameters\n\n Object.keys(pathObject).forEach((method) => {\n if (HTTP_METHODS.indexOf(method) >= 0) {\n const operation = (pathObject[method] = this.resolveReference({...spec, paths}, pathObject[method], true));\n\n this.convertOperationParameters(operation);\n this.convertResponses(operation);\n }\n });\n\n return paths;\n }, paths);\n }\n\n convertOperationParameters(operation: OS3Operation) {\n let content, contentKey, mediaRanges, mediaTypes;\n operation.parameters = operation.parameters || [];\n\n if (operation.requestBody) {\n let param = this.resolveReference(this.spec, operation.requestBody, true);\n\n // fixing external $ref in body\n if (operation.requestBody.content) {\n const type = getSupportedMimeTypes(operation.requestBody.content)[0];\n const structuredObj: any = {content: {}};\n const data = operation.requestBody.content[type];\n\n if (data && data.schema && data.schema.$ref && !data.schema.$ref.startsWith(\"#\")) {\n param = this.resolveReference(this.spec, data.schema, true);\n structuredObj[\"content\"][`${type}`] = {schema: param};\n param = structuredObj;\n }\n }\n\n param.name = \"body\";\n content = param.content;\n\n if (content && Object.keys(content).length) {\n mediaRanges = Object.keys(content).filter((mediaRange) => mediaRange.indexOf(\"/\") > 0);\n mediaTypes = mediaRanges.filter((range) => range.indexOf(\"*\") < 0);\n contentKey = getSupportedMimeTypes(content)[0];\n\n delete param.content;\n\n if ([SUPPORTED_MIME_TYPES.APPLICATION_X_WWW_URLENCODED, SUPPORTED_MIME_TYPES.MULTIPART_FORM_DATA].includes(contentKey)) {\n (operation as any).consumes = mediaTypes;\n\n param.in = \"formData\";\n param.schema = content[contentKey].schema;\n param.schema = this.resolveReference(this.spec, param.schema, true);\n\n if (param.schema.type === \"object\" && param.schema.properties) {\n const required = param.schema.required || [];\n\n Object.keys(param.schema.properties).forEach((name) => {\n const schema = param.schema.properties[name];\n\n // readOnly properties should not be sent in requests\n if (!schema.readOnly) {\n const formDataParam: any = {\n name,\n in: \"formData\",\n schema\n };\n if (required.indexOf(name) >= 0) {\n formDataParam.required = true;\n }\n\n operation.parameters?.push(formDataParam);\n }\n });\n } else {\n operation.parameters.push(param);\n }\n } else if (contentKey) {\n (operation as any).consumes = mediaTypes;\n param.in = \"body\";\n param.schema = content[contentKey].schema;\n operation.parameters.push(param);\n } else if (mediaRanges) {\n (operation as any).consumes = mediaTypes || [\"application/octet-stream\"];\n param.in = \"body\";\n param.name = param.name || \"file\";\n delete param.type;\n\n param.schema = content[mediaRanges[0]].schema || {\n type: \"string\",\n format: \"binary\"\n };\n\n operation.parameters.push(param);\n }\n\n if (param.schema) {\n this.convertSchema(param.schema, \"request\");\n }\n }\n\n delete operation.requestBody;\n }\n this.convertParameters(operation);\n }\n\n convertParameters(obj: any) {\n if (obj.parameters === undefined) {\n return;\n }\n\n obj.parameters = obj.parameters || [];\n\n (obj.parameters || []).forEach((param: any, i: number) => {\n param = obj.parameters[i] = this.resolveReference(this.spec, param, false);\n\n if (param.in !== \"body\") {\n this.copySchemaProperties(param, SCHEMA_PROPERTIES);\n this.copySchemaProperties(param, ARRAY_PROPERTIES);\n this.copySchemaXProperties(param);\n\n if (!param.description) {\n const schema = this.resolveReference(this.spec, param.schema, false);\n if (!!schema && schema.description) {\n param.description = schema.description;\n }\n }\n\n if (param.example !== undefined) {\n param[\"x-example\"] = param.example;\n }\n\n delete param.schema;\n delete param.allowReserved;\n delete param.example;\n }\n\n if (param.type === \"array\") {\n let style = param.style || (param.in === \"query\" || param.in === \"cookie\" ? \"form\" : \"simple\");\n\n switch (style) {\n case \"matrix\":\n param.collectionFormat = param.explode ? undefined : \"csv\";\n break;\n case \"label\":\n param.collectionFormat = undefined;\n break;\n case \"simple\":\n param.collectionFormat = \"csv\";\n break;\n case \"spaceDelimited\":\n param.collectionFormat = \"ssv\";\n break;\n case \"pipeDelimited\":\n param.collectionFormat = \"pipes\";\n break;\n case \"deepOpbject\":\n param.collectionFormat = \"multi\";\n break;\n case \"form\":\n param.collectionFormat = param.explode === false ? \"csv\" : \"multi\";\n break;\n }\n }\n\n delete param.style;\n delete param.explode;\n });\n }\n\n copySchemaProperties(obj: any, props: any[]) {\n let schema = this.resolveReference(this.spec, obj.schema, true);\n\n if (!schema) {\n return;\n }\n\n props.forEach((prop) => {\n const value = schema[prop];\n\n if (prop === \"additionalProperties\" && typeof value === \"boolean\") {\n return;\n }\n\n if (value !== undefined) {\n obj[prop] = value;\n }\n });\n }\n\n copySchemaXProperties(obj: Record<string, any>) {\n let schema = this.resolveReference(this.spec, obj.schema, true);\n if (!schema) {\n return;\n }\n\n Object.keys(schema).forEach((propName) => {\n if (Reflect.hasOwnProperty.call(schema, propName) && !Reflect.hasOwnProperty.call(obj, propName) && propName.startsWith(\"x-\")) {\n obj[propName] = schema[propName];\n }\n });\n }\n\n convertResponses(operation: Record<string, any>) {\n // var anySchema, code, content, jsonSchema, mediaRange, mediaType, response, resolved, headers\n\n Object.keys(operation.responses || {}).forEach((code) => {\n const response = (operation.responses[code] = this.resolveReference(this.spec, operation.responses[code], true));\n\n if (response.content) {\n let anySchema: any = null;\n let jsonSchema: any = null;\n\n Object.keys(response.content).forEach((mediaRange) => {\n // produces and examples only allow media types, not ranges\n // use application/octet-stream as a catch-all type\n const mediaType = mediaRange.indexOf(\"*\") < 0 ? mediaRange : \"application/octet-stream\";\n\n if (!operation.produces) {\n operation.produces = [mediaType];\n } else if (operation.produces.indexOf(mediaType) < 0) {\n operation.produces.push(mediaType);\n }\n\n const content = response.content[mediaRange];\n anySchema = anySchema || content.schema;\n\n if (!jsonSchema && isJsonMimeType(mediaType)) {\n jsonSchema = content.schema;\n }\n\n if (content.example) {\n response.examples = response.examples || {};\n response.examples[mediaType] = content.example;\n }\n });\n\n if (anySchema) {\n response.schema = jsonSchema || anySchema;\n const resolved = this.resolveReference(this.spec, response.schema, true);\n\n if (resolved && response.schema.$ref && !response.schema.$ref.startsWith(\"#\")) {\n response.schema = resolved;\n }\n\n this.convertSchema(response.schema, \"response\");\n }\n }\n\n Object.keys(response.headers || {}).forEach((header) => {\n // Always resolve headers when converting to v2.\n const resolved = this.resolveReference(this.spec, response.headers[header], true);\n\n // Headers should be converted like parameters.\n if (resolved.schema) {\n resolved.type = resolved.schema.type;\n resolved.format = resolved.schema.format;\n delete resolved.schema;\n }\n\n response.headers[header] = resolved;\n });\n\n delete response.content;\n });\n }\n\n convertSchema(def: any, operationDirection?: any) {\n if (def.oneOf) {\n delete def.oneOf;\n\n if (def.discriminator) {\n delete def.discriminator;\n }\n }\n\n if (def.anyOf) {\n delete def.anyOf;\n\n if (def.discriminator) {\n delete def.discriminator;\n }\n }\n\n if (def.allOf) {\n for (const i in def.allOf) {\n this.convertSchema(def.allOf[i], operationDirection);\n }\n }\n\n if (def.discriminator) {\n if (def.discriminator.mapping) {\n this.convertDiscriminatorMapping(def.discriminator.mapping);\n }\n\n def.discriminator = def.discriminator.propertyName;\n }\n\n switch (def.type) {\n case \"object\":\n if (def.properties) {\n Object.keys(def.properties).forEach((propName) => {\n if (def.properties[propName].writeOnly === true && operationDirection === \"response\") {\n delete def.properties[propName];\n } else {\n this.convertSchema(def.properties[propName], operationDirection);\n delete def.properties[propName].writeOnly;\n }\n });\n }\n break;\n case \"array\":\n if (def.items) {\n this.convertSchema(def.items, operationDirection);\n }\n }\n\n if (def.nullable) {\n def[\"x-nullable\"] = true;\n delete def.nullable;\n }\n\n // OpenAPI 3 has boolean \"deprecated\" on Schema, OpenAPI 2 does not\n // Convert to x-deprecated for Autorest (and perhaps others)\n if (def[\"deprecated\"] !== undefined) {\n // Move to x-deprecated, unless it is already defined\n if (def[\"x-deprecated\"] === undefined) {\n def[\"x-deprecated\"] = def.deprecated;\n }\n delete def.deprecated;\n }\n }\n\n convertSchemas() {\n this.spec.definitions = this.spec.components.schemas;\n\n Object.keys(this.spec.definitions || {}).forEach((defName) => {\n this.convertSchema(this.spec.definitions[defName]);\n });\n\n delete this.spec.components.schemas;\n }\n\n convertDiscriminatorMapping(mapping: any) {\n Object.keys(mapping).forEach((payload) => {\n const schemaNameOrRef = mapping[payload];\n\n if (typeof schemaNameOrRef !== \"string\") {\n console.warn(`Ignoring ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);\n return;\n }\n\n // payload may be a schema name or JSON Reference string.\n // OAS3 spec limits schema names to ^[a-zA-Z0-9._-]+$\n // Note: Valid schema name could be JSON file name without extension.\n // Prefer schema name, with file name as fallback.\n let schema;\n if (/^[a-zA-Z0-9._-]+$/.test(schemaNameOrRef)) {\n try {\n schema = this.resolveReference(this.spec, {$ref: `#/components/schemas/${schemaNameOrRef}`}, false);\n } catch (err) {\n console.debug(`Error resolving ${schemaNameOrRef} for ${payload} as schema name in discriminator.mapping: ${err}`);\n }\n }\n\n // schemaNameRef is not a schema name. Try to resolve as JSON Ref.\n if (!schema) {\n try {\n schema = this.resolveReference(this.spec, {$ref: schemaNameOrRef}, false);\n } catch (err) {\n console.debug(`Error resolving ${schemaNameOrRef} for ${payload} in discriminator.mapping: ${err}`);\n }\n }\n\n if (schema) {\n // Swagger Codegen + OpenAPI Generator extension\n // https://github.com/swagger-api/swagger-codegen/pull/4252\n schema[\"x-discriminator-value\"] = payload;\n\n // AutoRest extension\n // https://github.com/Azure/autorest/pull/474\n schema[\"x-ms-discriminator-value\"] = payload;\n } else {\n console.warn(`Unable to resolve ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);\n }\n });\n }\n\n convertSecurityDefinitions() {\n if (this.spec.components.securitySchemes) {\n this.spec.securityDefinitions = transformSecurity(this.spec.components.securitySchemes);\n delete this.spec.components.securitySchemes;\n }\n }\n}\n\nexport function transformToOS2(spec: any): Partial<OpenSpec2> {\n return new Converter(spec).convert();\n}\n"]}
@@ -2,9 +2,8 @@ import { registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContaine
2
2
  import { mapGenericsOptions } from "../utils/generics.js";
3
3
  import { createRef, toRef } from "../utils/ref.js";
4
4
  export function lazyRefMapper(input, options) {
5
- var _a;
6
5
  const name = input.name;
7
- if ((_a = options.$refs) === null || _a === void 0 ? void 0 : _a.find((t) => t === input.target)) {
6
+ if (options.$refs?.find((t) => t === input.target)) {
8
7
  return createRef(name, input.schema, options);
9
8
  }
10
9
  options.$refs = [...(options.$refs || []), input.target];
@@ -1 +1 @@
1
- {"version":3,"file":"lazyRefMapper.js","sourceRoot":"","sources":["../../../src/components/lazyRefMapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AAE9C,MAAM,UAAU,aAAa,CAAC,KAAkB,EAAE,OAA0B;;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAExB,IAAI,MAAA,OAAO,CAAC,KAAK,0CAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE;QACvD,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,wBAAwB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {createRef, toRef} from \"../utils/ref\";\n\nexport function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions) {\n const name = input.name;\n\n if (options.$refs?.find((t: any) => t === input.target)) {\n return createRef(name, input.schema, options);\n }\n\n options.$refs = [...(options.$refs || []), input.target];\n\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return toRef(input.schema, schema, options);\n}\n\nregisterJsonSchemaMapper(\"lazyRef\", lazyRefMapper);\n"]}
1
+ {"version":3,"file":"lazyRefMapper.js","sourceRoot":"","sources":["../../../src/components/lazyRefMapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AAE9C,MAAM,UAAU,aAAa,CAAC,KAAkB,EAAE,OAA0B;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAExB,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE;QACvD,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,wBAAwB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {createRef, toRef} from \"../utils/ref\";\n\nexport function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions) {\n const name = input.name;\n\n if (options.$refs?.find((t: any) => t === input.target)) {\n return createRef(name, input.schema, options);\n }\n\n options.$refs = [...(options.$refs || []), input.target];\n\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return toRef(input.schema, schema, options);\n}\n\nregisterJsonSchemaMapper(\"lazyRef\", lazyRefMapper);\n"]}
@@ -14,7 +14,7 @@ export function objectMapper(input, options) {
14
14
  if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {
15
15
  const opts = {
16
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
17
+ groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined
18
18
  };
19
19
  // remove groups to avoid bad schema generation over children models
20
20
  obj[key] = execMapper("item", value, opts);
@@ -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;AAC7F,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;;;;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,MAAM,IAAI,GAAG;gBACX,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;YACF,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACnD;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\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\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 const opts = {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n };\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, opts);\n obj[key] = mapNullableType(obj[key], value, opts);\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;AAC7F,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;;;;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,MAAM,IAAI,GAAG;gBACX,GAAG,OAAO;gBACV,MAAM,EAAE,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC;YACF,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACnD;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\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\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 const opts = {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n };\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, opts);\n obj[key] = mapNullableType(obj[key], value, opts);\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
@@ -10,11 +10,9 @@ export const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map, code) => {
10
10
  HTTP_STATUS_MESSAGES["200"].label = "Success";
11
11
  HTTP_STATUS_MESSAGES["200"].code = "SUCCESS";
12
12
  export function getStatusConstant(status) {
13
- var _a;
14
- return (_a = HTTP_STATUS_MESSAGES[status]) === null || _a === void 0 ? void 0 : _a.code;
13
+ return HTTP_STATUS_MESSAGES[status]?.code;
15
14
  }
16
15
  export function getStatusMessage(status) {
17
- var _a;
18
- return (_a = HTTP_STATUS_MESSAGES[status]) === null || _a === void 0 ? void 0 : _a.label;
16
+ return HTTP_STATUS_MESSAGES[status]?.label;
19
17
  }
20
18
  //# sourceMappingURL=httpStatusMessages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAkD,EAAE,IAAY,EAAE,EAAE;IAC7H,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,GAAG,GAAG;QACN,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,EAAC;KAC9D,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,oBAAoB,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC;AAC9C,oBAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;AAE7C,MAAM,UAAU,iBAAiB,CAAC,MAAuB;;IACvD,OAAO,MAAC,oBAA4B,CAAC,MAAM,CAAC,0CAAE,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAuB;;IACtD,OAAO,MAAC,oBAA4B,CAAC,MAAM,CAAC,0CAAE,KAAK,CAAC;AACtD,CAAC","sourcesContent":["import statuses from \"statuses\";\nimport {constantCase} from \"change-case\";\n\nexport const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map: Record<string, {label: string; code: string}>, code: number) => {\n const message: string = String(statuses(code));\n return {\n ...map,\n [String(code)]: {label: message, code: constantCase(message)}\n };\n}, {});\n\nHTTP_STATUS_MESSAGES[\"200\"].label = \"Success\";\nHTTP_STATUS_MESSAGES[\"200\"].code = \"SUCCESS\";\n\nexport function getStatusConstant(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.code;\n}\n\nexport function getStatusMessage(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.label;\n}\n"]}
1
+ {"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAkD,EAAE,IAAY,EAAE,EAAE;IAC7H,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,GAAG,GAAG;QACN,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,EAAC;KAC9D,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,oBAAoB,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC;AAC9C,oBAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;AAE7C,MAAM,UAAU,iBAAiB,CAAC,MAAuB;IACvD,OAAQ,oBAA4B,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACtD,OAAQ,oBAA4B,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;AACtD,CAAC","sourcesContent":["import statuses from \"statuses\";\nimport {constantCase} from \"change-case\";\n\nexport const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map: Record<string, {label: string; code: string}>, code: number) => {\n const message: string = String(statuses(code));\n return {\n ...map,\n [String(code)]: {label: message, code: constantCase(message)}\n };\n}, {});\n\nHTTP_STATUS_MESSAGES[\"200\"].label = \"Success\";\nHTTP_STATUS_MESSAGES[\"200\"].code = \"SUCCESS\";\n\nexport function getStatusConstant(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.code;\n}\n\nexport function getStatusMessage(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.label;\n}\n"]}
@@ -32,20 +32,19 @@ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
32
32
  * @collections
33
33
  */
34
34
  export function CollectionOf(type, collectionType) {
35
+ if (!type) {
36
+ throw new Error("A type is required on `@CollectionOf(type)` decorator. Please give a type or wrap it inside an arrow function if you have a circular reference.");
37
+ }
35
38
  const schema = {};
36
39
  let contains = false;
37
40
  const decorator = (...args) => {
38
41
  const store = JsonEntityStore.from(...args);
39
- // const itemSchema = store.itemSchema.toJSON();
40
42
  if (collectionType) {
41
43
  store.collectionType = collectionType;
42
44
  store.schema.type(collectionType);
43
45
  }
44
46
  store.type = type;
45
- // console.log(type);
46
47
  store.itemSchema.type(type);
47
- // console.log(store.itemSchema.getComputedType(), schema);
48
- // store.itemSchema.assign({...itemSchema, type});
49
48
  store.schema.assign(schema);
50
49
  if (store.isArray && contains) {
51
50
  store.schema.set("contains", store.schema.get("items"));
@@ -1 +1 @@
1
- {"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAkE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,YAAY,CAAC,IAAS,EAAE,cAAoB;IAC1D,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAS,EAAE,EAAE;QACjC,MAAM,KAAK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F,SAAS,CAAC,QAAQ,GAAG,GAAG,EAAE;QACxB,QAAQ,GAAG,IAAI,CAAC;QAEhB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,CAAC,WAAW,GAAG,IAAI,EAAE,EAAE;QAC7C,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;QAEjC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,IAAS;IAC/B,OAAO,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,IAAS;IAC7B,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\n\nexport interface ArrayOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value `minItems` MUST be a non-negative integer.\n * :::\n *\n * ::: tip\n * Omitting this keyword has the same behavior as a value of 0.\n * :::\n */\n MinItems(minItems: number): this;\n\n /**\n * The value `maxItems` MUST be a non-negative integer.\n *\n * An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.\n *\n * :: warning\n * The value `maxItems` MUST be a non-negative integer.\n * :::\n */\n MaxItems(maxItems: number): this;\n\n /**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * The array instance will be valid against \"contains\" if at least one of its elements is valid against the given schema.\n */\n Contains(): this;\n\n /**\n * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.\n */\n UniqueItems(uniqueItems?: boolean): this;\n}\n\nexport interface MapOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MinProperties(minProperties: number): this;\n\n /**\n * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MaxProperties(maxProperties: number): this;\n}\n\nexport interface CollectionOfChainedDecorators extends MapOfChainedDecorators, ArrayOfChainedDecorators {}\n\n/**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String).MinLength(0).MaxLength(0)\n * property: string[];\n * }\n * ```\n * ::: warning\n * You mustn't use the `type Type = string | number` as parameters Type.\n *\n * This example doesn't work:\n *\n * ```typescript\n * type Type = \"string\" | \"number\"\n * class Model {\n * @CollectionOf(Type)\n * property: Type[];\n * }\n * ```\n * :::\n *\n * @param {Type<any>} type\n * @param collectionType\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n */\nexport function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators {\n const schema: any = {};\n let contains: boolean = false;\n\n const decorator = (...args: any) => {\n const store = JsonEntityStore.from(...args);\n // const itemSchema = store.itemSchema.toJSON();\n\n if (collectionType) {\n store.collectionType = collectionType;\n store.schema.type(collectionType);\n }\n\n store.type = type;\n // console.log(type);\n store.itemSchema.type(type);\n // console.log(store.itemSchema.getComputedType(), schema);\n // store.itemSchema.assign({...itemSchema, type});\n store.schema.assign(schema);\n\n if (store.isArray && contains) {\n store.schema.set(\"contains\", store.schema.get(\"items\"));\n store.schema.delete(\"items\");\n }\n };\n\n decorator.MinItems = (minItems: number) => {\n schema.minItems = minItems;\n\n return decorator;\n };\n\n decorator.MaxItems = (maxItems: number) => {\n schema.maxItems = maxItems;\n\n return decorator;\n };\n decorator.MinProperties = (minProperties: number) => {\n schema.minProperties = minProperties;\n\n return decorator;\n };\n\n decorator.MaxProperties = (maxProperties: number) => {\n schema.maxProperties = maxProperties;\n\n return decorator;\n };\n\n decorator.Contains = () => {\n contains = true;\n\n return decorator;\n };\n\n decorator.UniqueItems = (uniqueItems = true) => {\n schema.uniqueItems = uniqueItems;\n\n return decorator;\n };\n\n return decorator;\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function ArrayOf(type: any): ArrayOfChainedDecorators {\n return CollectionOf(type, Array);\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function MapOf(type: any): MapOfChainedDecorators {\n return CollectionOf(type, Map);\n}\n"]}
1
+ {"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAkE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,YAAY,CAAC,IAAS,EAAE,cAAoB;IAC1D,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,iJAAiJ,CAClJ,CAAC;KACH;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAS,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAE5C,IAAI,cAAc,EAAE;YAClB,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;YACtC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACnC;QAED,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE5B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,K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;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,IAAS;IAC7B,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\n\nexport interface ArrayOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value `minItems` MUST be a non-negative integer.\n * :::\n *\n * ::: tip\n * Omitting this keyword has the same behavior as a value of 0.\n * :::\n */\n MinItems(minItems: number): this;\n\n /**\n * The value `maxItems` MUST be a non-negative integer.\n *\n * An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.\n *\n * :: warning\n * The value `maxItems` MUST be a non-negative integer.\n * :::\n */\n MaxItems(maxItems: number): this;\n\n /**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * The array instance will be valid against \"contains\" if at least one of its elements is valid against the given schema.\n */\n Contains(): this;\n\n /**\n * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.\n */\n UniqueItems(uniqueItems?: boolean): this;\n}\n\nexport interface MapOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MinProperties(minProperties: number): this;\n\n /**\n * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MaxProperties(maxProperties: number): this;\n}\n\nexport interface CollectionOfChainedDecorators extends MapOfChainedDecorators, ArrayOfChainedDecorators {}\n\n/**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String).MinLength(0).MaxLength(0)\n * property: string[];\n * }\n * ```\n * ::: warning\n * You mustn't use the `type Type = string | number` as parameters Type.\n *\n * This example doesn't work:\n *\n * ```typescript\n * type Type = \"string\" | \"number\"\n * class Model {\n * @CollectionOf(Type)\n * property: Type[];\n * }\n * ```\n * :::\n *\n * @param {Type<any>} type\n * @param collectionType\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n */\nexport function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators {\n if (!type) {\n throw new Error(\n \"A type is required on `@CollectionOf(type)` decorator. Please give a type or wrap it inside an arrow function if you have a circular reference.\"\n );\n }\n\n const schema: any = {};\n let contains: boolean = false;\n\n const decorator = (...args: any) => {\n const store = JsonEntityStore.from(...args);\n\n if (collectionType) {\n store.collectionType = collectionType;\n store.schema.type(collectionType);\n }\n\n store.type = type;\n store.itemSchema.type(type);\n\n store.schema.assign(schema);\n\n if (store.isArray && contains) {\n store.schema.set(\"contains\", store.schema.get(\"items\"));\n store.schema.delete(\"items\");\n }\n };\n\n decorator.MinItems = (minItems: number) => {\n schema.minItems = minItems;\n\n return decorator;\n };\n\n decorator.MaxItems = (maxItems: number) => {\n schema.maxItems = maxItems;\n\n return decorator;\n };\n decorator.MinProperties = (minProperties: number) => {\n schema.minProperties = minProperties;\n\n return decorator;\n };\n\n decorator.MaxProperties = (maxProperties: number) => {\n schema.maxProperties = maxProperties;\n\n return decorator;\n };\n\n decorator.Contains = () => {\n contains = true;\n\n return decorator;\n };\n\n decorator.UniqueItems = (uniqueItems = true) => {\n schema.uniqueItems = uniqueItems;\n\n return decorator;\n };\n\n return decorator;\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function ArrayOf(type: any): ArrayOfChainedDecorators {\n return CollectionOf(type, Array);\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function MapOf(type: any): MapOfChainedDecorators {\n return CollectionOf(type, Map);\n}\n"]}
@@ -54,7 +54,6 @@ import { JsonEntityFn } from "./jsonEntityFn.js";
54
54
  */
55
55
  export function Description(description) {
56
56
  return JsonEntityFn((store, args) => {
57
- var _a;
58
57
  switch (decoratorTypeOf(args)) {
59
58
  case DecoratorTypes.PROP:
60
59
  case DecoratorTypes.CLASS:
@@ -64,7 +63,7 @@ export function Description(description) {
64
63
  store.parameter.description(description);
65
64
  break;
66
65
  case DecoratorTypes.METHOD:
67
- (_a = store.operation) === null || _a === void 0 ? void 0 : _a.description(description);
66
+ store.operation?.description(description);
68
67
  break;
69
68
  }
70
69
  });
@@ -1 +1 @@
1
- {"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,WAAW,CAAC,WAAgB;IAC1C,OAAO,YAAY,CAAC,CAAC,KAAsB,EAAE,IAAyB,EAAE,EAAE;;QACxE,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,IAAI,CAAC;YACzB,KAAK,cAAc,CAAC,KAAK;gBACvB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACjE,MAAM;YAER,KAAK,cAAc,CAAC,MAAM;gBACxB,MAAC,KAAyB,CAAC,SAAS,0CAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC/D,MAAM;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\nimport type {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport type {JsonParameterStore} from \"../../domain/JsonParameterStore\";\n\n/**\n * Add a description to the class, method or property\n *\n * ## Examples\n * ### On class\n *\n * ```typescript\n * @Description(\"description\")\n * class Model {\n *\n * }\n * ```\n *\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Description(\"description\")\n * async method() {}\n * }\n * ```\n *\n * ### On parameter\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * async method(@Description(\"description\") @PathParam(\"id\") id: string) {}\n * }\n * ```\n *\n * ### On property\n *\n * ```typescript\n * class Model {\n * @Description(\"description\")\n * id: string;\n * }\n * ```\n *\n * @param {string} description\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @classDecorator\n * @methodDecorator\n * @propertyDecorator\n * @parameterDecorator\n */\nexport function Description(description: any) {\n return JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PROP:\n case DecoratorTypes.CLASS:\n store.schema.description(description);\n break;\n\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.description(description);\n break;\n\n case DecoratorTypes.METHOD:\n (store as JsonMethodStore).operation?.description(description);\n break;\n }\n });\n}\n"]}
1
+ {"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,WAAW,CAAC,WAAgB;IAC1C,OAAO,YAAY,CAAC,CAAC,KAAsB,EAAE,IAAyB,EAAE,EAAE;QACxE,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,IAAI,CAAC;YACzB,KAAK,cAAc,CAAC,KAAK;gBACvB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACjE,MAAM;YAER,KAAK,cAAc,CAAC,MAAM;gBACvB,KAAyB,CAAC,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC/D,MAAM;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\nimport type {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport type {JsonParameterStore} from \"../../domain/JsonParameterStore\";\n\n/**\n * Add a description to the class, method or property\n *\n * ## Examples\n * ### On class\n *\n * ```typescript\n * @Description(\"description\")\n * class Model {\n *\n * }\n * ```\n *\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Description(\"description\")\n * async method() {}\n * }\n * ```\n *\n * ### On parameter\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * async method(@Description(\"description\") @PathParam(\"id\") id: string) {}\n * }\n * ```\n *\n * ### On property\n *\n * ```typescript\n * class Model {\n * @Description(\"description\")\n * id: string;\n * }\n * ```\n *\n * @param {string} description\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @classDecorator\n * @methodDecorator\n * @propertyDecorator\n * @parameterDecorator\n */\nexport function Description(description: any) {\n return JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PROP:\n case DecoratorTypes.CLASS:\n store.schema.description(description);\n break;\n\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.description(description);\n break;\n\n case DecoratorTypes.METHOD:\n (store as JsonMethodStore).operation?.description(description);\n break;\n }\n });\n}\n"]}
@@ -15,8 +15,7 @@ export function Redirect(...args) {
15
15
  return options;
16
16
  }, { status: 302, url: "", meta: {} });
17
17
  return useDecorators(Returns(status).Location(url, meta), JsonEntityFn((entity) => {
18
- var _a;
19
- (_a = entity.operation) === null || _a === void 0 ? void 0 : _a.setRedirection(status);
18
+ entity.operation?.setRedirection(status);
20
19
  }));
21
20
  }
22
21
  //# sourceMappingURL=redirect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../../../src/decorators/operations/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAqDlC,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,MAAM,CACrC,CAAC,OAAY,EAAE,KAAU,EAAE,EAAE;QAC3B,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;YACvB,OAAO,OAAO,CAAC;SAChB;QAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;YACpB,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CACjC,CAAC;IACF,OAAO,aAAa,CAClB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EACnC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;;QACtB,MAAA,MAAM,CAAC,SAAS,0CAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import {isNumber, isString, useDecorators} from \"@tsed/core\";\nimport {JsonHeader} from \"../../interfaces/JsonOpenSpec\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\nimport {Returns} from \"./returns\";\n\n/**\n * Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.\n *\n * ```typescript\n * @Redirect('/foo/bar')\n * @Redirect(301, 'http://example.com').Type(Model)\n * private myMethod() {}\n * ```\n * Redirects can be a fully-qualified URL for redirecting to a different site:\n *\n * ```typescript\n * @Redirect('http://google.com');\n * private myMethod() {}\n * ```\n *\n * Redirects can be relative to the root of the host name. For example, if the application is on http://example.com/admin/post/new, the following would redirect to the URL http://example.com/admin:\n *\n * ```typescript\n * @Redirect('/admin');\n * ```\n * Redirects can be relative to the current URL. For example, from http://example.com/blog/admin/ (notice the trailing slash), the following would redirect to the URL http://example.com/blog/admin/post/new.\n *\n * ```typescript\n * @Redirect('post/new');\n * ```\n *\n * Redirecting to post/new from http://example.com/blog/admin (no trailing slash), will redirect to http://example.com/blog/post/new.\n *\n * If you found the above behavior confusing, think of path segments as directories (with trailing slashes) and files, it will start to make sense.\n *\n * Path-relative redirects are also possible. If you were on http://example.com/admin/post/new, the following would redirect to http//example.com/admin/post:\n *\n * ```typescript\n * @Redirect('..');\n * ``\n *\n * A back redirection redirects the request back to the referer, defaulting to / when the referer is missing.\n *\n * ```typescript\n * @Redirect('back');\n * ```\n *\n * @param url\n * @param meta\n * @decorator\n * @operation\n * @response\n * @headers\n */\nexport function Redirect(url: string, meta?: JsonHeader): Function;\nexport function Redirect(status: number, url: string, meta?: JsonHeader): Function;\nexport function Redirect(...args: any[]): Function {\n const {status, url, meta} = args.reduce(\n (options: any, value: any) => {\n if (isNumber(value)) {\n options.status = value;\n return options;\n }\n\n if (isString(value)) {\n options.url = value;\n return options;\n }\n\n options.meta = value;\n return options;\n },\n {status: 302, url: \"\", meta: {}}\n );\n return useDecorators(\n Returns(status).Location(url, meta),\n JsonEntityFn((entity) => {\n entity.operation?.setRedirection(status);\n })\n );\n}\n"]}
1
+ {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../../../src/decorators/operations/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAqDlC,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,MAAM,CACrC,CAAC,OAAY,EAAE,KAAU,EAAE,EAAE;QAC3B,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;YACvB,OAAO,OAAO,CAAC;SAChB;QAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;YACpB,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CACjC,CAAC;IACF,OAAO,aAAa,CAClB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EACnC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QACtB,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import {isNumber, isString, useDecorators} from \"@tsed/core\";\nimport {JsonHeader} from \"../../interfaces/JsonOpenSpec\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\nimport {Returns} from \"./returns\";\n\n/**\n * Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.\n *\n * ```typescript\n * @Redirect('/foo/bar')\n * @Redirect(301, 'http://example.com').Type(Model)\n * private myMethod() {}\n * ```\n * Redirects can be a fully-qualified URL for redirecting to a different site:\n *\n * ```typescript\n * @Redirect('http://google.com');\n * private myMethod() {}\n * ```\n *\n * Redirects can be relative to the root of the host name. For example, if the application is on http://example.com/admin/post/new, the following would redirect to the URL http://example.com/admin:\n *\n * ```typescript\n * @Redirect('/admin');\n * ```\n * Redirects can be relative to the current URL. For example, from http://example.com/blog/admin/ (notice the trailing slash), the following would redirect to the URL http://example.com/blog/admin/post/new.\n *\n * ```typescript\n * @Redirect('post/new');\n * ```\n *\n * Redirecting to post/new from http://example.com/blog/admin (no trailing slash), will redirect to http://example.com/blog/post/new.\n *\n * If you found the above behavior confusing, think of path segments as directories (with trailing slashes) and files, it will start to make sense.\n *\n * Path-relative redirects are also possible. If you were on http://example.com/admin/post/new, the following would redirect to http//example.com/admin/post:\n *\n * ```typescript\n * @Redirect('..');\n * ``\n *\n * A back redirection redirects the request back to the referer, defaulting to / when the referer is missing.\n *\n * ```typescript\n * @Redirect('back');\n * ```\n *\n * @param url\n * @param meta\n * @decorator\n * @operation\n * @response\n * @headers\n */\nexport function Redirect(url: string, meta?: JsonHeader): Function;\nexport function Redirect(status: number, url: string, meta?: JsonHeader): Function;\nexport function Redirect(...args: any[]): Function {\n const {status, url, meta} = args.reduce(\n (options: any, value: any) => {\n if (isNumber(value)) {\n options.status = value;\n return options;\n }\n\n if (isString(value)) {\n options.url = value;\n return options;\n }\n\n options.meta = value;\n return options;\n },\n {status: 302, url: \"\", meta: {}}\n );\n return useDecorators(\n Returns(status).Location(url, meta),\n JsonEntityFn((entity) => {\n entity.operation?.setRedirection(status);\n })\n );\n}\n"]}
@@ -2,6 +2,7 @@ import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isArray, isCollecti
2
2
  import { getStatusMessage } from "../../constants/httpStatusMessages.js";
3
3
  import { DecoratorContext } from "../../domain/DecoratorContext.js";
4
4
  import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
5
+ import { JsonParameter } from "../../domain/JsonParameter.js";
5
6
  import { JsonSchema } from "../../domain/JsonSchema.js";
6
7
  import { getStatusModel } from "../../utils/defineStatusModel.js";
7
8
  import { string } from "../../utils/from.js";
@@ -25,26 +26,27 @@ function mapGenerics(types) {
25
26
  * @ignore
26
27
  */
27
28
  class ReturnDecoratorContext extends DecoratorContext {
29
+ methods = [
30
+ "contentType",
31
+ "description",
32
+ "examples",
33
+ "type",
34
+ "status",
35
+ "of",
36
+ "oneOf",
37
+ "allOf",
38
+ "anyOf",
39
+ "nested",
40
+ "header",
41
+ "headers",
42
+ "schema",
43
+ "title",
44
+ "groups",
45
+ "allowedGroups",
46
+ "location"
47
+ ];
28
48
  constructor({ status, model }) {
29
49
  super();
30
- this.methods = [
31
- "contentType",
32
- "description",
33
- "examples",
34
- "type",
35
- "status",
36
- "of",
37
- "oneOf",
38
- "allOf",
39
- "anyOf",
40
- "nested",
41
- "header",
42
- "headers",
43
- "schema",
44
- "title",
45
- "groups",
46
- "location"
47
- ];
48
50
  this.model(model);
49
51
  this.status(status);
50
52
  }
@@ -88,6 +90,10 @@ class ReturnDecoratorContext extends DecoratorContext {
88
90
  this.set("groups", groups);
89
91
  return this;
90
92
  }
93
+ allowedGroups(...allowedGroups) {
94
+ this.set("allowedGroups", new Set(allowedGroups));
95
+ return this;
96
+ }
91
97
  nested(...generics) {
92
98
  const model = this.get("model");
93
99
  this.checkPrimitive(model);
@@ -103,10 +109,10 @@ class ReturnDecoratorContext extends DecoratorContext {
103
109
  this.addAction(() => {
104
110
  const schema = this.get("schema");
105
111
  if (isCollection(model)) {
106
- schema === null || schema === void 0 ? void 0 : schema.itemSchema({ type: types[0] });
112
+ schema?.itemSchema({ type: types[0] });
107
113
  }
108
114
  else {
109
- schema === null || schema === void 0 ? void 0 : schema.nestedGenerics.push(mapGenerics(types));
115
+ schema?.nestedGenerics.push(mapGenerics(types));
110
116
  }
111
117
  });
112
118
  return this;
@@ -220,6 +226,9 @@ class ReturnDecoratorContext extends DecoratorContext {
220
226
  const model = this.get("model");
221
227
  const media = response.getMedia(contentType || "*/*");
222
228
  const schema = media.get("schema") || new JsonSchema({ type: model });
229
+ const groups = this.get("groups");
230
+ const allowedGroups = this.get("allowedGroups");
231
+ const operation = this.entity.operation;
223
232
  if (model) {
224
233
  if (isArray(model)) {
225
234
  schema.oneOf(model.map((type) => ({ type })));
@@ -230,7 +239,20 @@ class ReturnDecoratorContext extends DecoratorContext {
230
239
  }
231
240
  this.set("schema", schema);
232
241
  media.schema(schema);
233
- media.groups = this.get("groups");
242
+ media.groups = groups;
243
+ if (allowedGroups) {
244
+ media.allowedGroups = allowedGroups;
245
+ const jsonParameter = new JsonParameter();
246
+ jsonParameter.in("query").name("includes");
247
+ jsonParameter.schema(JsonSchema.from({
248
+ type: "array",
249
+ items: {
250
+ type: "string",
251
+ enum: [...allowedGroups]
252
+ }
253
+ }));
254
+ operation.addParameter(-1, jsonParameter);
255
+ }
234
256
  const examples = this.get("examples");
235
257
  if (examples) {
236
258
  media.examples(examples);