@tsed/schema 6.114.17 → 6.114.18

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 (110) hide show
  1. package/lib/cjs/components/lazyRefMapper.js +1 -2
  2. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  3. package/lib/cjs/components/objectMapper.js +1 -1
  4. package/lib/cjs/components/objectMapper.js.map +1 -1
  5. package/lib/cjs/constants/httpStatusMessages.js +2 -4
  6. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  7. package/lib/cjs/decorators/common/description.js +1 -2
  8. package/lib/cjs/decorators/common/description.js.map +1 -1
  9. package/lib/cjs/decorators/operations/redirect.js +1 -2
  10. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  11. package/lib/cjs/decorators/operations/returns.js +20 -20
  12. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  13. package/lib/cjs/decorators/operations/route.js +1 -4
  14. package/lib/cjs/decorators/operations/route.js.map +1 -1
  15. package/lib/cjs/domain/DecoratorContext.js +4 -1
  16. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  17. package/lib/cjs/domain/JsonClassStore.js +4 -7
  18. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  19. package/lib/cjs/domain/JsonEntityStore.js +37 -1
  20. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  21. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  22. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  23. package/lib/cjs/domain/JsonMethodStore.js +12 -12
  24. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  25. package/lib/cjs/domain/JsonOperation.js +12 -16
  26. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  27. package/lib/cjs/domain/JsonOperationPathsMap.js +1 -4
  28. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  29. package/lib/cjs/domain/JsonOperationRoute.js +8 -6
  30. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  31. package/lib/cjs/domain/JsonParameter.js +4 -4
  32. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  33. package/lib/cjs/domain/JsonParameterStore.js +12 -5
  34. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  35. package/lib/cjs/domain/JsonPropertyStore.js +1 -4
  36. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  37. package/lib/cjs/domain/JsonResponse.js +3 -6
  38. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  39. package/lib/cjs/domain/JsonSchema.js +58 -60
  40. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  41. package/lib/cjs/hooks/alterIgnore.js +2 -3
  42. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  43. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  44. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  45. package/lib/cjs/utils/getJsonSchema.js +1 -2
  46. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  47. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  48. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  49. package/lib/cjs/utils/mapNullableType.js +1 -1
  50. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  51. package/lib/cjs/utils/mergeOperation.js +1 -2
  52. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  53. package/lib/cjs/utils/transformToOS2.js +2 -2
  54. package/lib/cjs/utils/transformToOS2.js.map +1 -1
  55. package/lib/esm/components/lazyRefMapper.js +1 -2
  56. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  57. package/lib/esm/components/objectMapper.js +1 -1
  58. package/lib/esm/components/objectMapper.js.map +1 -1
  59. package/lib/esm/constants/httpStatusMessages.js +2 -4
  60. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  61. package/lib/esm/decorators/common/description.js +1 -2
  62. package/lib/esm/decorators/common/description.js.map +1 -1
  63. package/lib/esm/decorators/operations/redirect.js +1 -2
  64. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  65. package/lib/esm/decorators/operations/returns.js +20 -20
  66. package/lib/esm/decorators/operations/returns.js.map +1 -1
  67. package/lib/esm/decorators/operations/route.js +1 -4
  68. package/lib/esm/decorators/operations/route.js.map +1 -1
  69. package/lib/esm/domain/DecoratorContext.js +4 -1
  70. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  71. package/lib/esm/domain/JsonClassStore.js +4 -7
  72. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  73. package/lib/esm/domain/JsonEntityStore.js +37 -1
  74. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  75. package/lib/esm/domain/JsonLazyRef.js +2 -1
  76. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  77. package/lib/esm/domain/JsonMethodStore.js +12 -12
  78. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  79. package/lib/esm/domain/JsonOperation.js +12 -16
  80. package/lib/esm/domain/JsonOperation.js.map +1 -1
  81. package/lib/esm/domain/JsonOperationPathsMap.js +1 -4
  82. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  83. package/lib/esm/domain/JsonOperationRoute.js +8 -6
  84. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  85. package/lib/esm/domain/JsonParameter.js +4 -4
  86. package/lib/esm/domain/JsonParameter.js.map +1 -1
  87. package/lib/esm/domain/JsonParameterStore.js +12 -5
  88. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  89. package/lib/esm/domain/JsonPropertyStore.js +1 -4
  90. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  91. package/lib/esm/domain/JsonResponse.js +3 -6
  92. package/lib/esm/domain/JsonResponse.js.map +1 -1
  93. package/lib/esm/domain/JsonSchema.js +58 -60
  94. package/lib/esm/domain/JsonSchema.js.map +1 -1
  95. package/lib/esm/hooks/alterIgnore.js +2 -3
  96. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  97. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  98. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  99. package/lib/esm/utils/getJsonSchema.js +1 -2
  100. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  101. package/lib/esm/utils/getRequiredProperties.js +3 -3
  102. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  103. package/lib/esm/utils/mapNullableType.js +1 -1
  104. package/lib/esm/utils/mapNullableType.js.map +1 -1
  105. package/lib/esm/utils/mergeOperation.js +1 -2
  106. package/lib/esm/utils/mergeOperation.js.map +1 -1
  107. package/lib/esm/utils/transformToOS2.js +2 -2
  108. package/lib/esm/utils/transformToOS2.js.map +1 -1
  109. package/package.json +6 -6
  110. package/tsconfig.compile.esm.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"mapNullableType.js","sourceRoot":"","sources":["../../../src/utils/mapNullableType.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAEhC,mDAA8C;AAG9C,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,SAAgB,eAAe,CAAC,GAAQ,EAAE,MAAyB,EAAE,OAA0B;IAC7F,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,EAAE;QACvB,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,KAAK,GAAa,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1D,QAAQ,OAAO,CAAC,QAAQ,EAAE;QACxB,QAAQ;QACR,KAAK,qBAAS,CAAC,IAAI;YACjB,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;oBACrB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;wBAChB,IAAI,EAAE,MAAM;qBACb,CAAC,CAAC;iBACJ;aACF;iBAAM;gBACL,GAAG,CAAC,IAAI,GAAG,IAAA,WAAI,EAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;aACrC;YACD,MAAM;QAER,KAAK,qBAAS,CAAC,OAAO;YACpB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;YAEpB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBACd,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBACpB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC;oBAC1C,OAAO,GAAG,CAAC,IAAI,CAAC;iBACjB;qBAAM;oBACL,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;iBACrB;aACF;YACD,MAAM;KACT;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAnCD,0CAmCC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction hasNullable(obj: any) {\n return obj.oneOf.find((o: any) => o.type === \"null\");\n}\n\nexport function mapNullableType(obj: any, schema: JsonSchema | null, options: JsonSchemaOptions) {\n if (!schema?.isNullable) {\n return obj;\n }\n let types: string[] = [].concat(obj.type).filter(Boolean);\n\n switch (options.specType) {\n default:\n case SpecTypes.JSON:\n if (obj.oneOf) {\n if (!hasNullable(obj)) {\n obj.oneOf.unshift({\n type: \"null\"\n });\n }\n } else {\n obj.type = uniq([\"null\", ...types]);\n }\n break;\n\n case SpecTypes.OPENAPI:\n obj.nullable = true;\n\n if (!obj.oneOf) {\n if (types.length > 1) {\n obj.oneOf = types.map((type) => ({type}));\n delete obj.type;\n } else {\n obj.type = types[0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oBAC1C,OAAO,GAAG,CAAC,IAAI,CAAC;iBACjB;qBAAM;oBACL,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;iBACrB;aACF;YACD,MAAM;KACT;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAnCD,0CAmCC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction hasNullable(obj: any) {\n return obj.oneOf.find((o: any) => o.type === \"null\");\n}\n\nexport function mapNullableType(obj: any, schema: JsonSchema | null, options: JsonSchemaOptions) {\n if (!schema?.isNullable) {\n return obj;\n }\n let types: string[] = [].concat(obj.type).filter(Boolean);\n\n switch (options.specType) {\n default:\n case SpecTypes.JSON:\n if (obj.oneOf) {\n if (!hasNullable(obj)) {\n obj.oneOf.unshift({\n type: \"null\"\n });\n }\n } else {\n obj.type = uniq([\"null\", ...types]);\n }\n break;\n\n case SpecTypes.OPENAPI:\n obj.nullable = true;\n\n if (!obj.oneOf) {\n if (types.length > 1) {\n obj.oneOf = types.map((type) => ({type}));\n delete obj.type;\n } else {\n obj.type = types[0];\n }\n }\n break;\n }\n\n return obj;\n}\n"]}
@@ -24,10 +24,9 @@ function mergeOperation(obj, operation, { rootPath, specType, operationId, defau
24
24
  return { path, parameters };
25
25
  });
26
26
  return pathParameters.reduce((obj, { path, parameters }) => {
27
- var _a;
28
27
  parameters = (0, concatParameters_1.concatParameters)(parameters, operation);
29
28
  path = path ? path : "/";
30
- const operationTags = ((_a = operation.tags) === null || _a === void 0 ? void 0 : _a.length) ? operation.tags : [defaultTags];
29
+ const operationTags = operation.tags?.length ? operation.tags : [defaultTags];
31
30
  obj.paths[path] = {
32
31
  ...obj.paths[path],
33
32
  [method.toLowerCase()]: {
@@ -1 +1 @@
1
- {"version":3,"file":"mergeOperation.js","sourceRoot":"","sources":["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AC,GAAG;YAChB,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAClB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE;gBACtB,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC;gBACvD,GAAG,SAAS;gBACZ,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAM,EAAE,EAAE,CAAC,IAAI,CAAC;gBAC9C,UAAU;aACX;SACF,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QAE5B,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC;AA3CD,wCA2CC","sourcesContent":["import {SpecTypes} from \"../domain/SpecTypes\";\nimport {concatParameters} from \"./concatParameters\";\nimport {getJsonPathParameters} from \"./getJsonPathParameters\";\n\n/**\n * @ignore\n */\nexport interface MergeOperationOptions {\n rootPath: string;\n specType: SpecTypes;\n operationId: (path: string) => string | undefined;\n defaultTags: string[];\n tags: string[];\n path: string;\n method: string;\n}\n\n/**\n * @ignore\n */\nexport function mergeOperation(\n obj: any,\n operation: any,\n {rootPath, specType, operationId, defaultTags, tags, path, method}: MergeOperationOptions\n) {\n const pathParameters = getJsonPathParameters(rootPath, path).map(({path, parameters}) => {\n path = path ? path : \"/\";\n\n // FIXME not on the right place\n if (specType === SpecTypes.OPENAPI) {\n parameters = parameters.map(({type, ...param}) => {\n return {\n ...param,\n schema: {\n type\n }\n };\n });\n }\n\n return {path, parameters};\n });\n\n return pathParameters.reduce((obj, {path, parameters}) => {\n parameters = concatParameters(parameters, operation);\n path = path ? path : \"/\";\n\n const operationTags = operation.tags?.length ? operation.tags : [defaultTags];\n\n obj.paths[path] = {\n ...obj.paths[path],\n [method.toLowerCase()]: {\n operationId: operation.operationId || operationId(path),\n ...operation,\n tags: operationTags.map(({name}: any) => name),\n parameters\n }\n };\n\n tags.push(...operationTags);\n\n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,CAAC,CAAC;QAE9E,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG;YAChB,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAClB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE;gBACtB,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC;gBACvD,GAAG,SAAS;gBACZ,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAM,EAAE,EAAE,CAAC,IAAI,CAAC;gBAC9C,UAAU;aACX;SACF,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QAE5B,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC;AA3CD,wCA2CC","sourcesContent":["import {SpecTypes} from \"../domain/SpecTypes\";\nimport {concatParameters} from \"./concatParameters\";\nimport {getJsonPathParameters} from \"./getJsonPathParameters\";\n\n/**\n * @ignore\n */\nexport interface MergeOperationOptions {\n rootPath: string;\n specType: SpecTypes;\n operationId: (path: string) => string | undefined;\n defaultTags: string[];\n tags: string[];\n path: string;\n method: string;\n}\n\n/**\n * @ignore\n */\nexport function mergeOperation(\n obj: any,\n operation: any,\n {rootPath, specType, operationId, defaultTags, tags, path, method}: MergeOperationOptions\n) {\n const pathParameters = getJsonPathParameters(rootPath, path).map(({path, parameters}) => {\n path = path ? path : \"/\";\n\n // FIXME not on the right place\n if (specType === SpecTypes.OPENAPI) {\n parameters = parameters.map(({type, ...param}) => {\n return {\n ...param,\n schema: {\n type\n }\n };\n });\n }\n\n return {path, parameters};\n });\n\n return pathParameters.reduce((obj, {path, parameters}) => {\n parameters = concatParameters(parameters, operation);\n path = path ? path : \"/\";\n\n const operationTags = operation.tags?.length ? operation.tags : [defaultTags];\n\n obj.paths[path] = {\n ...obj.paths[path],\n [method.toLowerCase()]: {\n operationId: operation.operationId || operationId(path),\n ...operation,\n tags: operationTags.map(({name}: any) => name),\n parameters\n }\n };\n\n tags.push(...operationTags);\n\n return obj;\n }, obj);\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,GA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AAO,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"]}
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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OAAO,CAAC;gBAE1C,qBAAqB;gBACrB,6CAA6C;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"]}
@@ -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"]}
@@ -25,26 +25,26 @@ function mapGenerics(types) {
25
25
  * @ignore
26
26
  */
27
27
  class ReturnDecoratorContext extends DecoratorContext {
28
+ methods = [
29
+ "contentType",
30
+ "description",
31
+ "examples",
32
+ "type",
33
+ "status",
34
+ "of",
35
+ "oneOf",
36
+ "allOf",
37
+ "anyOf",
38
+ "nested",
39
+ "header",
40
+ "headers",
41
+ "schema",
42
+ "title",
43
+ "groups",
44
+ "location"
45
+ ];
28
46
  constructor({ status, model }) {
29
47
  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
48
  this.model(model);
49
49
  this.status(status);
50
50
  }
@@ -103,10 +103,10 @@ class ReturnDecoratorContext extends DecoratorContext {
103
103
  this.addAction(() => {
104
104
  const schema = this.get("schema");
105
105
  if (isCollection(model)) {
106
- schema === null || schema === void 0 ? void 0 : schema.itemSchema({ type: types[0] });
106
+ schema?.itemSchema({ type: types[0] });
107
107
  }
108
108
  else {
109
- schema === null || schema === void 0 ? void 0 : schema.nestedGenerics.push(mapGenerics(types));
109
+ schema?.nestedGenerics.push(mapGenerics(types));
110
110
  }
111
111
  });
112
112
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"returns.js","sourceRoot":"","sources":["../../../../src/decorators/operations/returns.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,2BAA2B,EAC3B,QAAQ,EAET,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,gBAAgB,EAAuB,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAC,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAgHlD;;GAEG;AACH,SAAS,MAAM,CAAC,IAAS;IACvB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,WAAW,CAAC,KAAqB;IACxC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE;YAChB,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED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ChC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,UAAU,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;QAEpE,IAAI,KAAK,EAAE;YACT,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;gBAClB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC;aAC7C;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAErB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAC1B;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA+JD,MAAM,UAAU,OAAO,CAAC,MAAwB,EAAE,KAAqC;IACrF,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM;QACN,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import {\n decorateMethodsOf,\n decoratorTypeOf,\n DecoratorTypes,\n isArray,\n isCollection,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n isString,\n Type\n} from \"@tsed/core\";\nimport {OS3Example} from \"@tsed/openspec\";\nimport {getStatusMessage, HTTP_STATUS_MESSAGES} from \"../../constants/httpStatusMessages\";\nimport {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonResponse} from \"../../domain/JsonResponse\";\nimport {JsonSchema, JsonSchemaObject} from \"../../domain/JsonSchema\";\nimport {JsonHeader, JsonHeaders} from \"../../interfaces/JsonOpenSpec\";\nimport {getStatusModel} from \"../../utils/defineStatusModel\";\nimport {string} from \"../../utils/from\";\nimport {GenericValue} from \"../../utils/generics\";\nimport {isSuccessStatus} from \"../../utils/isSuccessStatus\";\nimport {mapHeaders} from \"../../utils/mapHeaders\";\n\nexport interface ReturnsChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Function): void;\n\n /**\n * Set a Content-Type for the current response\n * @param value\n * @constructor\n */\n ContentType(value: string): this;\n\n /**\n * Add a description\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Add examples\n * @param examples\n */\n Examples(examples: Record<string, OS3Example>): this;\n\n Examples(examples: Record<string, any>): this;\n\n Examples(examples: any): this;\n\n /**\n * Change the model type\n * @param type\n */\n Type(type: Type<any> | any): this;\n\n /**\n * Change the status\n * @param status\n * @constructor\n */\n Status(status: string | number): this;\n\n /**\n * Add the nested types\n * @param types\n */\n Of(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n OneOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AllOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AnyOf(...types: GenericValue[]): this;\n\n /**\n * Declare a nested generic models\n * @param generics\n */\n Nested(...generics: GenericValue[]): this;\n\n /**\n * Add header.\n * @param key\n * @param value\n */\n Header(key: string, value: number | string | (JsonHeader & {value?: string | number | boolean})): this;\n\n /**\n * Add headers\n */\n Headers(headers: JsonHeaders): this;\n\n /**\n * Add location hea\n */\n Location(location: string, meta?: JsonHeader): this;\n\n /**\n * Assign partial schema\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject> | JsonSchema): this;\n\n /**\n * Add an inline title for the return model.\n * @param title\n */\n Title(title: string): this;\n\n /**\n *\n * @param groups\n * @constructor\n */\n Groups(...groups: string[]): this;\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nfunction isEnum(type: any) {\n return isObject(type) && !(\"toJSON\" in type);\n}\n\nfunction mapGenerics(types: GenericValue[]) {\n return types.map((type) => {\n if (isEnum(type)) {\n return string().enum(Object.values(type));\n }\n return type;\n });\n}\n\n/**\n * @ignore\n */\nclass ReturnDecoratorContext extends DecoratorContext<ReturnsChainedDecorators> {\n readonly methods: string[] = [\n \"contentType\",\n \"description\",\n \"examples\",\n \"type\",\n \"status\",\n \"of\",\n \"oneOf\",\n \"allOf\",\n \"anyOf\",\n \"nested\",\n \"header\",\n \"headers\",\n \"schema\",\n \"title\",\n \"groups\",\n \"location\"\n ];\n\n constructor({status, model}: any) {\n super();\n\n this.model(model);\n this.status(status);\n }\n\n type(model: any) {\n return this.model(model);\n }\n\n model(model: any) {\n model && this.set(\"model\", model);\n return this;\n }\n\n status(status: number | string) {\n this.set(\"status\", status);\n\n if (status && getStatusMessage(status) && !this.get(\"description\")) {\n this.set(\"description\", getStatusMessage(status));\n\n if (!this.get(\"model\")) {\n this.model(getStatusModel(+status));\n }\n }\n\n return this;\n }\n\n headers(headers: JsonHeaders) {\n this.set(\"headers\", {\n ...(this.get(\"headers\") || {}),\n ...mapHeaders(headers)\n });\n\n return this;\n }\n\n header(key: string, value: string | JsonHeader) {\n return this.headers({[key]: value});\n }\n\n location(path: string, meta: JsonHeaders = {}) {\n this.headers({\n Location: {\n ...meta,\n value: path\n }\n });\n\n return this;\n }\n\n groups(...groups: string[]) {\n this.set(\"groups\", groups);\n return this;\n }\n\n nested(...generics: GenericValue[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n this.checkCollection(model);\n\n this.addAction((ctx) => {\n (this.get(\"schema\") as JsonSchema).nestedGenerics.push(mapGenerics(generics));\n });\n\n return this;\n }\n\n of(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n if (isCollection(model)) {\n schema?.itemSchema({type: types[0]});\n } else {\n schema?.nestedGenerics.push(mapGenerics(types));\n }\n });\n\n return this;\n }\n\n oneOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({oneOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n allOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({allOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n anyOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({anyOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n schema(partial: Partial<JsonSchemaObject>) {\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n schema!.assign(partial);\n });\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", isString(examples) ? [examples] : examples);\n return this;\n }\n\n title(title: string) {\n return this.schema({title});\n }\n\n protected checkPrimitive(model: any) {\n if (isPrimitiveOrPrimitiveClass(model)) {\n throw new Error(\"Returns.Of cannot be used with the following primitive classes: String, Number, Boolean\");\n }\n }\n\n protected checkCollection(model: any) {\n if (isCollection(model)) {\n throw new Error(\"Returns.Nested cannot be used with the following classes: Map, Set, Array, String, Number, Boolean\");\n }\n }\n\n protected getContentType() {\n const model = this.get(\"model\");\n let contentType = this.get(\"contentType\");\n\n if (model && !isPlainObject(model) && !isPrimitiveOrPrimitiveClass(model)) {\n contentType = contentType || \"application/json\";\n }\n\n return contentType;\n }\n\n protected getStatus() {\n return this.get(\"status\") || \"default\";\n }\n\n protected onInit(args: any[], decorator: any) {\n const type = decoratorTypeOf(args);\n switch (type) {\n case DecoratorTypes.METHOD:\n this.entity = JsonEntityStore.from(...args);\n if (this.entity.operation) {\n this.map();\n }\n break;\n case DecoratorTypes.CLASS:\n this.decoratorType = DecoratorTypes.CLASS;\n decorateMethodsOf(args[0], decorator);\n break;\n }\n }\n\n protected map() {\n const model = this.get(\"model\");\n const {entity, decoratorType} = this;\n const operation = this.entity.operation!;\n const currentStatus = this.getStatus();\n const response = operation.ensureResponseOf(currentStatus);\n const contentType = this.getContentType();\n\n let {description = response.get(\"description\")} = this.toObject();\n\n if (description) {\n description = decoratorType === DecoratorTypes.CLASS ? response.get(\"description\") || description : description;\n response.description(description);\n }\n\n const headers = this.getMergedKey(\"headers\", response.get(\"headers\"));\n\n if (headers) {\n response.headers(headers);\n }\n\n this.mapMedia(response);\n\n if (isSuccessStatus(this.get(\"status\")) || currentStatus === \"default\") {\n if (model) {\n entity.type = model;\n }\n }\n\n // additional info for OS2\n contentType && operation.addProduce(contentType);\n\n // run additional actions\n return this.runActions();\n }\n\n protected mapMedia(response: JsonResponse) {\n const contentType = this.getContentType();\n const model = this.get(\"model\");\n const media = response.getMedia(contentType || \"*/*\");\n const schema = media.get(\"schema\") || new JsonSchema({type: model});\n\n if (model) {\n if (isArray(model)) {\n schema.oneOf(model.map((type) => ({type})));\n } else {\n schema.type(model);\n }\n }\n\n this.set(\"schema\", schema);\n\n media.schema(schema);\n\n media.groups = this.get(\"groups\");\n\n const examples = this.get(\"examples\");\n\n if (examples) {\n media.examples(examples);\n }\n\n return media;\n }\n}\n\n/**\n * Add responses documentation for a specific status code.\n *\n * ## Usage\n *\n * Ts.ED v5/v6 API introducing the chaining decorator concept. Now a decorator like Returns can be used with another decorators like Description.\n *\n * ::: warning\n * v5 has a basic support of the chaining decorator to facilitate the migration to v6!\n * :::\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @Returns(404, String).Description(\"Not Found\")\n * @Returns(200, Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ::: tip\n * TypeScript and your IDE will discover automatically the chained decorators. But for more details you can look on @@ReturnsChainedDecorators@@ interface, to know\n * what chained decorators are available under Returns decorator.\n * :::\n *\n * This example will produce this documentation in swagger:\n *\n * ```json\n * {\n * \"responses\": {\n * \"404\": {\n * \"description\": \"Description\",\n * \"schema\": {\"type\": \"string\"}\n * },\n * \"2OO\": {\n * \"description\": \"Description\",\n * \"schema\": {\"$ref\": \"...\"}\n * }\n * }\n * }\n * ```\n *\n * ## Declaring an Array\n *\n * Use chained decorators to declare an array with model as following:\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/models\")\n * class ModelCtrl {\n * @Get(\"/\")\n * @Returns(200, Array).Of(Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {\n * }\n * }\n * ```\n *\n * Deprecated version:\n *\n * ```typescript\n * import {ReturnsArray} from \"@tsed/common\";\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @ReturnsArray(200, Model) // deprecated\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ### Declaring a generic model <Badge text=\"6+\"/>\n *\n * Sometime, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to\n * declare explicitly the generic models with the decorators.\n *\n * One of the generic's usage, can be a paginated list. With Returns decorator it's now possible to declare generic type and generate the appropriate OpenSpec documentation.\n *\n * Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:\n *\n * ```typescript\n * @Generics(\"T\")\n * class Pagination<T> {\n * @CollectionOf(\"T\")\n * data: T[];\n *\n * @Property()\n * totalCount: number;\n * }\n * ```\n *\n * Now, we need a model to be used with the generic Pagination model:\n *\n * ```typescript\n * class Product {\n * @Property()\n * id: string;\n *\n * @Property()\n * title: string;\n * }\n * ```\n *\n * Finally, we can use our models on a method as following:\n *\n * ```typescript\n * class Controller {\n * @OperationPath(\"POST\", \"/\")\n * @Returns(200, Pagination).Of(Product).Description(\"description\")\n * async method(): Promise<Pagination<Product> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * ### Declaring a nested generics models <Badge text=\"6+\"/>\n *\n * It's also possible to declare a nested generics models in order to have this type `Pagination<Submission<Product>>`:\n *\n * ```typescript\n * import {Generics, Property, Returns} from \"@tsed/schema\";\n * import {Post} from \"@tsed/common\";\n *\n * class Controller {\n * @Post(\"/\")\n * @Returns(200, Pagination).Of(Submission).Nested(Product).Description(\"description\")\n * async method(): Promise<Pagination<Submission<Product>> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * And here is the Submission model:\n *\n * ```typescript\n * import {Generics, Property} from \"@tsed/schema\";\n *\n * @Generics(\"T\")\n * class Submission<T> {\n * @Property()\n * _id: string;\n * @Property(\"T\")\n * data: T;\n * }\n * ```\n *\n * @param status\n * @param model\n * @decorator\n * @swagger\n * @schema\n * @response\n * @operation\n */\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[] | any): ReturnsChainedDecorators {\n const context = new ReturnDecoratorContext({\n status,\n model\n });\n\n return context.build();\n}\n"]}
1
+ {"version":3,"file":"returns.js","sourceRoot":"","sources":["../../../../src/decorators/operations/returns.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,2BAA2B,EAC3B,QAAQ,EAET,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,gBAAgB,EAAuB,MAAM,oCAAoC,CAAC;AAC1F,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CA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ErB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAC1B;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA+JD,MAAM,UAAU,OAAO,CAAC,MAAwB,EAAE,KAAqC;IACrF,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM;QACN,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import {\n decorateMethodsOf,\n decoratorTypeOf,\n DecoratorTypes,\n isArray,\n isCollection,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n isString,\n Type\n} from \"@tsed/core\";\nimport {OS3Example} from \"@tsed/openspec\";\nimport {getStatusMessage, HTTP_STATUS_MESSAGES} from \"../../constants/httpStatusMessages\";\nimport {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonResponse} from \"../../domain/JsonResponse\";\nimport {JsonSchema, JsonSchemaObject} from \"../../domain/JsonSchema\";\nimport {JsonHeader, JsonHeaders} from \"../../interfaces/JsonOpenSpec\";\nimport {getStatusModel} from \"../../utils/defineStatusModel\";\nimport {string} from \"../../utils/from\";\nimport {GenericValue} from \"../../utils/generics\";\nimport {isSuccessStatus} from \"../../utils/isSuccessStatus\";\nimport {mapHeaders} from \"../../utils/mapHeaders\";\n\nexport interface ReturnsChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Function): void;\n\n /**\n * Set a Content-Type for the current response\n * @param value\n * @constructor\n */\n ContentType(value: string): this;\n\n /**\n * Add a description\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Add examples\n * @param examples\n */\n Examples(examples: Record<string, OS3Example>): this;\n\n Examples(examples: Record<string, any>): this;\n\n Examples(examples: any): this;\n\n /**\n * Change the model type\n * @param type\n */\n Type(type: Type<any> | any): this;\n\n /**\n * Change the status\n * @param status\n * @constructor\n */\n Status(status: string | number): this;\n\n /**\n * Add the nested types\n * @param types\n */\n Of(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n OneOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AllOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AnyOf(...types: GenericValue[]): this;\n\n /**\n * Declare a nested generic models\n * @param generics\n */\n Nested(...generics: GenericValue[]): this;\n\n /**\n * Add header.\n * @param key\n * @param value\n */\n Header(key: string, value: number | string | (JsonHeader & {value?: string | number | boolean})): this;\n\n /**\n * Add headers\n */\n Headers(headers: JsonHeaders): this;\n\n /**\n * Add location hea\n */\n Location(location: string, meta?: JsonHeader): this;\n\n /**\n * Assign partial schema\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject> | JsonSchema): this;\n\n /**\n * Add an inline title for the return model.\n * @param title\n */\n Title(title: string): this;\n\n /**\n *\n * @param groups\n * @constructor\n */\n Groups(...groups: string[]): this;\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nfunction isEnum(type: any) {\n return isObject(type) && !(\"toJSON\" in type);\n}\n\nfunction mapGenerics(types: GenericValue[]) {\n return types.map((type) => {\n if (isEnum(type)) {\n return string().enum(Object.values(type));\n }\n return type;\n });\n}\n\n/**\n * @ignore\n */\nclass ReturnDecoratorContext extends DecoratorContext<ReturnsChainedDecorators> {\n readonly methods: string[] = [\n \"contentType\",\n \"description\",\n \"examples\",\n \"type\",\n \"status\",\n \"of\",\n \"oneOf\",\n \"allOf\",\n \"anyOf\",\n \"nested\",\n \"header\",\n \"headers\",\n \"schema\",\n \"title\",\n \"groups\",\n \"location\"\n ];\n\n constructor({status, model}: any) {\n super();\n\n this.model(model);\n this.status(status);\n }\n\n type(model: any) {\n return this.model(model);\n }\n\n model(model: any) {\n model && this.set(\"model\", model);\n return this;\n }\n\n status(status: number | string) {\n this.set(\"status\", status);\n\n if (status && getStatusMessage(status) && !this.get(\"description\")) {\n this.set(\"description\", getStatusMessage(status));\n\n if (!this.get(\"model\")) {\n this.model(getStatusModel(+status));\n }\n }\n\n return this;\n }\n\n headers(headers: JsonHeaders) {\n this.set(\"headers\", {\n ...(this.get(\"headers\") || {}),\n ...mapHeaders(headers)\n });\n\n return this;\n }\n\n header(key: string, value: string | JsonHeader) {\n return this.headers({[key]: value});\n }\n\n location(path: string, meta: JsonHeaders = {}) {\n this.headers({\n Location: {\n ...meta,\n value: path\n }\n });\n\n return this;\n }\n\n groups(...groups: string[]) {\n this.set(\"groups\", groups);\n return this;\n }\n\n nested(...generics: GenericValue[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n this.checkCollection(model);\n\n this.addAction((ctx) => {\n (this.get(\"schema\") as JsonSchema).nestedGenerics.push(mapGenerics(generics));\n });\n\n return this;\n }\n\n of(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n if (isCollection(model)) {\n schema?.itemSchema({type: types[0]});\n } else {\n schema?.nestedGenerics.push(mapGenerics(types));\n }\n });\n\n return this;\n }\n\n oneOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({oneOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n allOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({allOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n anyOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({anyOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n schema(partial: Partial<JsonSchemaObject>) {\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n schema!.assign(partial);\n });\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", isString(examples) ? [examples] : examples);\n return this;\n }\n\n title(title: string) {\n return this.schema({title});\n }\n\n protected checkPrimitive(model: any) {\n if (isPrimitiveOrPrimitiveClass(model)) {\n throw new Error(\"Returns.Of cannot be used with the following primitive classes: String, Number, Boolean\");\n }\n }\n\n protected checkCollection(model: any) {\n if (isCollection(model)) {\n throw new Error(\"Returns.Nested cannot be used with the following classes: Map, Set, Array, String, Number, Boolean\");\n }\n }\n\n protected getContentType() {\n const model = this.get(\"model\");\n let contentType = this.get(\"contentType\");\n\n if (model && !isPlainObject(model) && !isPrimitiveOrPrimitiveClass(model)) {\n contentType = contentType || \"application/json\";\n }\n\n return contentType;\n }\n\n protected getStatus() {\n return this.get(\"status\") || \"default\";\n }\n\n protected onInit(args: any[], decorator: any) {\n const type = decoratorTypeOf(args);\n switch (type) {\n case DecoratorTypes.METHOD:\n this.entity = JsonEntityStore.from(...args);\n if (this.entity.operation) {\n this.map();\n }\n break;\n case DecoratorTypes.CLASS:\n this.decoratorType = DecoratorTypes.CLASS;\n decorateMethodsOf(args[0], decorator);\n break;\n }\n }\n\n protected map() {\n const model = this.get(\"model\");\n const {entity, decoratorType} = this;\n const operation = this.entity.operation!;\n const currentStatus = this.getStatus();\n const response = operation.ensureResponseOf(currentStatus);\n const contentType = this.getContentType();\n\n let {description = response.get(\"description\")} = this.toObject();\n\n if (description) {\n description = decoratorType === DecoratorTypes.CLASS ? response.get(\"description\") || description : description;\n response.description(description);\n }\n\n const headers = this.getMergedKey(\"headers\", response.get(\"headers\"));\n\n if (headers) {\n response.headers(headers);\n }\n\n this.mapMedia(response);\n\n if (isSuccessStatus(this.get(\"status\")) || currentStatus === \"default\") {\n if (model) {\n entity.type = model;\n }\n }\n\n // additional info for OS2\n contentType && operation.addProduce(contentType);\n\n // run additional actions\n return this.runActions();\n }\n\n protected mapMedia(response: JsonResponse) {\n const contentType = this.getContentType();\n const model = this.get(\"model\");\n const media = response.getMedia(contentType || \"*/*\");\n const schema = media.get(\"schema\") || new JsonSchema({type: model});\n\n if (model) {\n if (isArray(model)) {\n schema.oneOf(model.map((type) => ({type})));\n } else {\n schema.type(model);\n }\n }\n\n this.set(\"schema\", schema);\n\n media.schema(schema);\n\n media.groups = this.get(\"groups\");\n\n const examples = this.get(\"examples\");\n\n if (examples) {\n media.examples(examples);\n }\n\n return media;\n }\n}\n\n/**\n * Add responses documentation for a specific status code.\n *\n * ## Usage\n *\n * Ts.ED v5/v6 API introducing the chaining decorator concept. Now a decorator like Returns can be used with another decorators like Description.\n *\n * ::: warning\n * v5 has a basic support of the chaining decorator to facilitate the migration to v6!\n * :::\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @Returns(404, String).Description(\"Not Found\")\n * @Returns(200, Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ::: tip\n * TypeScript and your IDE will discover automatically the chained decorators. But for more details you can look on @@ReturnsChainedDecorators@@ interface, to know\n * what chained decorators are available under Returns decorator.\n * :::\n *\n * This example will produce this documentation in swagger:\n *\n * ```json\n * {\n * \"responses\": {\n * \"404\": {\n * \"description\": \"Description\",\n * \"schema\": {\"type\": \"string\"}\n * },\n * \"2OO\": {\n * \"description\": \"Description\",\n * \"schema\": {\"$ref\": \"...\"}\n * }\n * }\n * }\n * ```\n *\n * ## Declaring an Array\n *\n * Use chained decorators to declare an array with model as following:\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/models\")\n * class ModelCtrl {\n * @Get(\"/\")\n * @Returns(200, Array).Of(Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {\n * }\n * }\n * ```\n *\n * Deprecated version:\n *\n * ```typescript\n * import {ReturnsArray} from \"@tsed/common\";\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @ReturnsArray(200, Model) // deprecated\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ### Declaring a generic model <Badge text=\"6+\"/>\n *\n * Sometime, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to\n * declare explicitly the generic models with the decorators.\n *\n * One of the generic's usage, can be a paginated list. With Returns decorator it's now possible to declare generic type and generate the appropriate OpenSpec documentation.\n *\n * Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:\n *\n * ```typescript\n * @Generics(\"T\")\n * class Pagination<T> {\n * @CollectionOf(\"T\")\n * data: T[];\n *\n * @Property()\n * totalCount: number;\n * }\n * ```\n *\n * Now, we need a model to be used with the generic Pagination model:\n *\n * ```typescript\n * class Product {\n * @Property()\n * id: string;\n *\n * @Property()\n * title: string;\n * }\n * ```\n *\n * Finally, we can use our models on a method as following:\n *\n * ```typescript\n * class Controller {\n * @OperationPath(\"POST\", \"/\")\n * @Returns(200, Pagination).Of(Product).Description(\"description\")\n * async method(): Promise<Pagination<Product> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * ### Declaring a nested generics models <Badge text=\"6+\"/>\n *\n * It's also possible to declare a nested generics models in order to have this type `Pagination<Submission<Product>>`:\n *\n * ```typescript\n * import {Generics, Property, Returns} from \"@tsed/schema\";\n * import {Post} from \"@tsed/common\";\n *\n * class Controller {\n * @Post(\"/\")\n * @Returns(200, Pagination).Of(Submission).Nested(Product).Description(\"description\")\n * async method(): Promise<Pagination<Submission<Product>> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * And here is the Submission model:\n *\n * ```typescript\n * import {Generics, Property} from \"@tsed/schema\";\n *\n * @Generics(\"T\")\n * class Submission<T> {\n * @Property()\n * _id: string;\n * @Property(\"T\")\n * data: T;\n * }\n * ```\n *\n * @param status\n * @param model\n * @decorator\n * @swagger\n * @schema\n * @response\n * @operation\n */\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[] | any): ReturnsChainedDecorators {\n const context = new ReturnDecoratorContext({\n status,\n model\n });\n\n return context.build();\n}\n"]}
@@ -2,10 +2,7 @@ import { DecoratorContext } from "../../domain/DecoratorContext.js";
2
2
  import { mapRouteOptions } from "../../utils/mapRouteOptions.js";
3
3
  import { OperationMethods } from "../../constants/httpMethods.js";
4
4
  class RouteDecoratorContext extends DecoratorContext {
5
- constructor() {
6
- super(...arguments);
7
- this.methods = ["name", "description", "summary", "method", "id", "use", "useAfter", "useBefore"];
8
- }
5
+ methods = ["name", "description", "summary", "method", "id", "use", "useAfter", "useBefore"];
9
6
  beforeInit() {
10
7
  const path = this.get("path");
11
8
  const method = OperationMethods[this.get("method")] || OperationMethods.CUSTOM;