@tsed/schema 7.0.0-beta.1 → 7.0.0-beta.12

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 (297) hide show
  1. package/jest.config.js +4 -4
  2. package/lib/cjs/components/schemaMapper.js +1 -3
  3. package/lib/cjs/components/schemaMapper.js.map +1 -1
  4. package/lib/cjs/constants/httpStatusMessages.js +12 -96
  5. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  6. package/lib/cjs/decorators/common/description.js.map +1 -1
  7. package/lib/cjs/decorators/common/enum.js +1 -20
  8. package/lib/cjs/decorators/common/enum.js.map +1 -1
  9. package/lib/cjs/decorators/common/ignore.js.map +1 -1
  10. package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -1
  11. package/lib/cjs/decorators/common/recordOf.js +63 -0
  12. package/lib/cjs/decorators/common/recordOf.js.map +1 -0
  13. package/lib/cjs/decorators/operations/acceptMime.js +28 -0
  14. package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
  15. package/lib/cjs/decorators/operations/in.js +6 -4
  16. package/lib/cjs/decorators/operations/in.js.map +1 -1
  17. package/lib/cjs/decorators/operations/view.js +31 -0
  18. package/lib/cjs/decorators/operations/view.js.map +1 -0
  19. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  20. package/lib/cjs/domain/JsonClassStore.js +1 -1
  21. package/lib/cjs/domain/JsonMap.js.map +1 -1
  22. package/lib/cjs/domain/JsonMethodStore.js +66 -24
  23. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  24. package/lib/cjs/domain/JsonOperation.js +11 -26
  25. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  26. package/lib/cjs/domain/JsonOperationRoute.js +4 -0
  27. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  28. package/lib/cjs/domain/JsonParameter.js +36 -74
  29. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  30. package/lib/cjs/domain/JsonParameterStore.js +14 -5
  31. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  32. package/lib/cjs/domain/JsonPropertyStore.js +6 -2
  33. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  34. package/lib/cjs/domain/JsonResponse.js +1 -11
  35. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  36. package/lib/cjs/domain/JsonSchema.js +47 -54
  37. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  38. package/lib/cjs/domain/SpecTypes.js +0 -3
  39. package/lib/cjs/domain/SpecTypes.js.map +1 -1
  40. package/lib/cjs/index.js +150 -20
  41. package/lib/cjs/index.js.map +1 -1
  42. package/lib/cjs/package.json +3 -0
  43. package/lib/cjs/utils/from.js +9 -8
  44. package/lib/cjs/utils/from.js.map +1 -1
  45. package/lib/cjs/utils/generateSpec.js +46 -0
  46. package/lib/cjs/utils/generateSpec.js.map +1 -0
  47. package/lib/cjs/utils/generics.js.map +1 -1
  48. package/lib/cjs/utils/getJsonPathParameters.js +20 -6
  49. package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
  50. package/lib/cjs/utils/getJsonSchema.js +11 -1
  51. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  52. package/lib/cjs/utils/getJsonType.js +1 -1
  53. package/lib/cjs/utils/getJsonType.js.map +1 -1
  54. package/lib/cjs/utils/getOperationsRoutes.js +2 -1
  55. package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
  56. package/lib/cjs/utils/getSpec.js +58 -43
  57. package/lib/cjs/utils/getSpec.js.map +1 -1
  58. package/lib/cjs/utils/getSpecType.js +21 -0
  59. package/lib/cjs/utils/getSpecType.js.map +1 -0
  60. package/lib/cjs/utils/mapNullableType.js +1 -6
  61. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  62. package/lib/cjs/utils/mapOpenSpec.js +41 -0
  63. package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
  64. package/lib/cjs/utils/mapOpenSpec2.js +34 -0
  65. package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
  66. package/lib/cjs/utils/mapOpenSpec3.js +26 -0
  67. package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
  68. package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
  69. package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
  70. package/lib/cjs/utils/matchGroups.js +1 -1
  71. package/lib/cjs/utils/matchGroups.js.map +1 -1
  72. package/lib/cjs/utils/mergeOperation.js +1 -0
  73. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  74. package/lib/cjs/utils/ref.js +0 -8
  75. package/lib/cjs/utils/ref.js.map +1 -1
  76. package/lib/cjs/utils/serializeEnumValues.js +26 -0
  77. package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
  78. package/lib/cjs/utils/transformToOS2.js +510 -0
  79. package/lib/cjs/utils/transformToOS2.js.map +1 -0
  80. package/lib/esm/components/anyMapper.js +4 -4
  81. package/lib/esm/components/classMapper.js +4 -4
  82. package/lib/esm/components/genericsMapper.js +4 -4
  83. package/lib/esm/components/inheritedClassMapper.js +2 -2
  84. package/lib/esm/components/itemMapper.js +1 -1
  85. package/lib/esm/components/lazyRefMapper.js +3 -3
  86. package/lib/esm/components/mapMapper.js +2 -2
  87. package/lib/esm/components/objectMapper.js +3 -3
  88. package/lib/esm/components/ofMapper.js +1 -1
  89. package/lib/esm/components/propertiesMapper.js +1 -1
  90. package/lib/esm/components/schemaMapper.js +7 -9
  91. package/lib/esm/components/schemaMapper.js.map +1 -1
  92. package/lib/esm/constants/httpStatusMessages.js +11 -96
  93. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  94. package/lib/esm/decorators/class/children.js +1 -1
  95. package/lib/esm/decorators/collections/collectionContains.js +1 -1
  96. package/lib/esm/decorators/collections/collectionOf.js +1 -1
  97. package/lib/esm/decorators/collections/maxItems.js +1 -1
  98. package/lib/esm/decorators/collections/maxProperties.js +1 -1
  99. package/lib/esm/decorators/collections/minItems.js +1 -1
  100. package/lib/esm/decorators/collections/minProperties.js +1 -1
  101. package/lib/esm/decorators/collections/uniqueItems.js +1 -1
  102. package/lib/esm/decorators/common/additionalProperties.js +1 -1
  103. package/lib/esm/decorators/common/allOf.js +1 -1
  104. package/lib/esm/decorators/common/allow.js +2 -2
  105. package/lib/esm/decorators/common/any.js +1 -1
  106. package/lib/esm/decorators/common/anyOf.js +1 -1
  107. package/lib/esm/decorators/common/const.js +1 -1
  108. package/lib/esm/decorators/common/customKey.js +1 -1
  109. package/lib/esm/decorators/common/default.js +1 -1
  110. package/lib/esm/decorators/common/description.js +1 -1
  111. package/lib/esm/decorators/common/description.js.map +1 -1
  112. package/lib/esm/decorators/common/enum.js +2 -21
  113. package/lib/esm/decorators/common/enum.js.map +1 -1
  114. package/lib/esm/decorators/common/example.js +1 -1
  115. package/lib/esm/decorators/common/examples.js +1 -1
  116. package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
  117. package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
  118. package/lib/esm/decorators/common/format.js +2 -2
  119. package/lib/esm/decorators/common/forwardGroups.js +1 -1
  120. package/lib/esm/decorators/common/groups.js +2 -2
  121. package/lib/esm/decorators/common/ignore.js +1 -1
  122. package/lib/esm/decorators/common/ignore.js.map +1 -1
  123. package/lib/esm/decorators/common/integer.js +1 -1
  124. package/lib/esm/decorators/common/jsonEntityFn.js +1 -1
  125. package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -1
  126. package/lib/esm/decorators/common/maxLength.js +1 -1
  127. package/lib/esm/decorators/common/maximum.js +1 -1
  128. package/lib/esm/decorators/common/minLength.js +1 -1
  129. package/lib/esm/decorators/common/minimum.js +1 -1
  130. package/lib/esm/decorators/common/multipleOf.js +1 -1
  131. package/lib/esm/decorators/common/name.js +1 -1
  132. package/lib/esm/decorators/common/nullable.js +2 -2
  133. package/lib/esm/decorators/common/oneOf.js +1 -1
  134. package/lib/esm/decorators/common/optional.js +1 -1
  135. package/lib/esm/decorators/common/pattern.js +1 -1
  136. package/lib/esm/decorators/common/property.js +1 -1
  137. package/lib/esm/decorators/common/readOnly.js +1 -1
  138. package/lib/esm/decorators/common/recordOf.js +59 -0
  139. package/lib/esm/decorators/common/recordOf.js.map +1 -0
  140. package/lib/esm/decorators/common/required.js +2 -2
  141. package/lib/esm/decorators/common/requiredGroups.js +2 -2
  142. package/lib/esm/decorators/common/schema.js +1 -1
  143. package/lib/esm/decorators/common/title.js +1 -1
  144. package/lib/esm/decorators/common/writeOnly.js +1 -1
  145. package/lib/esm/decorators/config/jsonEntityComponent.js +1 -1
  146. package/lib/esm/decorators/generics/genericOf.js +2 -2
  147. package/lib/esm/decorators/generics/generics.js +1 -1
  148. package/lib/esm/decorators/operations/acceptMime.js +24 -0
  149. package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
  150. package/lib/esm/decorators/operations/consumes.js +1 -1
  151. package/lib/esm/decorators/operations/contentType.js +1 -1
  152. package/lib/esm/decorators/operations/deprecated.js +1 -1
  153. package/lib/esm/decorators/operations/header.js +1 -1
  154. package/lib/esm/decorators/operations/in.js +3 -1
  155. package/lib/esm/decorators/operations/in.js.map +1 -1
  156. package/lib/esm/decorators/operations/inFile.js +5 -5
  157. package/lib/esm/decorators/operations/location.js +1 -1
  158. package/lib/esm/decorators/operations/operationId.js +1 -1
  159. package/lib/esm/decorators/operations/operationPath.js +1 -1
  160. package/lib/esm/decorators/operations/partial.js +1 -1
  161. package/lib/esm/decorators/operations/path.js +1 -1
  162. package/lib/esm/decorators/operations/produces.js +1 -1
  163. package/lib/esm/decorators/operations/redirect.js +2 -2
  164. package/lib/esm/decorators/operations/returns.js +8 -8
  165. package/lib/esm/decorators/operations/route.js +3 -3
  166. package/lib/esm/decorators/operations/security.js +1 -1
  167. package/lib/esm/decorators/operations/status.js +1 -1
  168. package/lib/esm/decorators/operations/summary.js +1 -1
  169. package/lib/esm/decorators/operations/tags.js +1 -1
  170. package/lib/esm/decorators/operations/view.js +27 -0
  171. package/lib/esm/decorators/operations/view.js.map +1 -0
  172. package/lib/esm/domain/DecoratorContext.js +1 -1
  173. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  174. package/lib/esm/domain/JsonClassStore.js +3 -3
  175. package/lib/esm/domain/JsonLazyRef.js +2 -2
  176. package/lib/esm/domain/JsonMap.js +1 -1
  177. package/lib/esm/domain/JsonMap.js.map +1 -1
  178. package/lib/esm/domain/JsonMethodStore.js +68 -26
  179. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  180. package/lib/esm/domain/JsonOperation.js +10 -25
  181. package/lib/esm/domain/JsonOperation.js.map +1 -1
  182. package/lib/esm/domain/JsonOperationPathsMap.js +1 -1
  183. package/lib/esm/domain/JsonOperationRoute.js +5 -1
  184. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  185. package/lib/esm/domain/JsonParameter.js +40 -78
  186. package/lib/esm/domain/JsonParameter.js.map +1 -1
  187. package/lib/esm/domain/JsonParameterStore.js +17 -8
  188. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  189. package/lib/esm/domain/JsonPropertyStore.js +7 -3
  190. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  191. package/lib/esm/domain/JsonRequestBody.js +2 -2
  192. package/lib/esm/domain/JsonResponse.js +4 -14
  193. package/lib/esm/domain/JsonResponse.js.map +1 -1
  194. package/lib/esm/domain/JsonSchema.js +9 -16
  195. package/lib/esm/domain/JsonSchema.js.map +1 -1
  196. package/lib/esm/domain/SpecTypes.js +0 -3
  197. package/lib/esm/domain/SpecTypes.js.map +1 -1
  198. package/lib/esm/index.js +150 -20
  199. package/lib/esm/index.js.map +1 -1
  200. package/lib/esm/package.json +3 -0
  201. package/lib/esm/utils/from.js +5 -4
  202. package/lib/esm/utils/from.js.map +1 -1
  203. package/lib/esm/utils/generateSpec.js +41 -0
  204. package/lib/esm/utils/generateSpec.js.map +1 -0
  205. package/lib/esm/utils/generics.js.map +1 -1
  206. package/lib/esm/utils/getInheritedStores.js +1 -1
  207. package/lib/esm/utils/getJsonEntityStore.js +5 -5
  208. package/lib/esm/utils/getJsonPathParameters.js +20 -6
  209. package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
  210. package/lib/esm/utils/getJsonSchema.js +14 -4
  211. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  212. package/lib/esm/utils/getJsonType.js +2 -2
  213. package/lib/esm/utils/getJsonType.js.map +1 -1
  214. package/lib/esm/utils/getOperationsRoutes.js +5 -4
  215. package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
  216. package/lib/esm/utils/getOperationsStores.js +4 -4
  217. package/lib/esm/utils/getPropertiesStores.js +3 -3
  218. package/lib/esm/utils/getRequiredProperties.js +1 -1
  219. package/lib/esm/utils/getSpec.js +65 -50
  220. package/lib/esm/utils/getSpec.js.map +1 -1
  221. package/lib/esm/utils/getSpecType.js +16 -0
  222. package/lib/esm/utils/getSpecType.js.map +1 -0
  223. package/lib/esm/utils/mapNullableType.js +2 -7
  224. package/lib/esm/utils/mapNullableType.js.map +1 -1
  225. package/lib/esm/utils/mapOpenSpec.js +37 -0
  226. package/lib/esm/utils/mapOpenSpec.js.map +1 -0
  227. package/lib/esm/utils/mapOpenSpec2.js +30 -0
  228. package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
  229. package/lib/esm/utils/mapOpenSpec3.js +22 -0
  230. package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
  231. package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
  232. package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
  233. package/lib/esm/utils/mapRouteOptions.js +1 -1
  234. package/lib/esm/utils/mergeOperation.js +4 -3
  235. package/lib/esm/utils/mergeOperation.js.map +1 -1
  236. package/lib/esm/utils/ref.js +1 -9
  237. package/lib/esm/utils/ref.js.map +1 -1
  238. package/lib/esm/utils/serializeEnumValues.js +21 -0
  239. package/lib/esm/utils/serializeEnumValues.js.map +1 -0
  240. package/lib/esm/utils/toJsonMapCollection.js +1 -1
  241. package/lib/esm/utils/transformToOS2.js +504 -0
  242. package/lib/esm/utils/transformToOS2.js.map +1 -0
  243. package/lib/types/constants/httpStatusMessages.d.ts +2 -263
  244. package/lib/types/decorators/common/ignore.d.ts +1 -1
  245. package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
  246. package/lib/types/decorators/common/recordOf.d.ts +46 -0
  247. package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
  248. package/lib/types/decorators/operations/in.d.ts +1 -1
  249. package/lib/types/decorators/operations/view.d.ts +23 -0
  250. package/lib/types/domain/JsonMap.d.ts +1 -1
  251. package/lib/types/domain/JsonMethodStore.d.ts +51 -2
  252. package/lib/types/domain/JsonOperation.d.ts +2 -1
  253. package/lib/types/domain/JsonOperationRoute.d.ts +5 -3
  254. package/lib/types/domain/JsonParameter.d.ts +2 -1
  255. package/lib/types/domain/JsonParameterStore.d.ts +23 -1
  256. package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
  257. package/lib/types/domain/JsonResponse.d.ts +2 -1
  258. package/lib/types/domain/JsonSchema.d.ts +2 -2
  259. package/lib/types/domain/SpecTypes.d.ts +0 -3
  260. package/lib/types/index.d.ts +143 -13
  261. package/lib/types/utils/generateSpec.d.ts +16 -0
  262. package/lib/types/utils/generics.d.ts +1 -1
  263. package/lib/types/utils/getJsonSchema.d.ts +12 -2
  264. package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
  265. package/lib/types/utils/getSpec.d.ts +6 -25
  266. package/lib/types/utils/getSpecType.d.ts +12 -0
  267. package/lib/types/utils/mapNullableType.d.ts +1 -1
  268. package/lib/types/utils/mapOpenSpec.d.ts +10 -0
  269. package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
  270. package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
  271. package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
  272. package/lib/types/utils/serializeEnumValues.d.ts +5 -0
  273. package/lib/types/utils/transformToOS2.d.ts +25 -0
  274. package/package.json +34 -16
  275. package/readme.md +3 -1
  276. package/tsconfig.compile.esm.json +2 -12
  277. package/benchmark/cold-start.js +0 -17
  278. package/lib/cjs/components/index.js +0 -15
  279. package/lib/cjs/components/index.js.map +0 -1
  280. package/lib/cjs/decorators/index.js +0 -77
  281. package/lib/cjs/decorators/index.js.map +0 -1
  282. package/lib/cjs/domain/index.js +0 -20
  283. package/lib/cjs/domain/index.js.map +0 -1
  284. package/lib/cjs/interfaces/index.js +0 -8
  285. package/lib/cjs/interfaces/index.js.map +0 -1
  286. package/lib/esm/components/index.js +0 -12
  287. package/lib/esm/components/index.js.map +0 -1
  288. package/lib/esm/decorators/index.js +0 -74
  289. package/lib/esm/decorators/index.js.map +0 -1
  290. package/lib/esm/domain/index.js +0 -17
  291. package/lib/esm/domain/index.js.map +0 -1
  292. package/lib/esm/interfaces/index.js +0 -5
  293. package/lib/esm/interfaces/index.js.map +0 -1
  294. package/lib/types/components/index.d.ts +0 -11
  295. package/lib/types/decorators/index.d.ts +0 -68
  296. package/lib/types/domain/index.d.ts +0 -16
  297. package/lib/types/interfaces/index.d.ts +0 -4
@@ -0,0 +1,510 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformToOS2 = exports.Converter = exports.transformInformation = exports.transformSecurity = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const HTTP_METHODS = ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
6
+ const SCHEMA_PROPERTIES = [
7
+ "format",
8
+ "minimum",
9
+ "maximum",
10
+ "exclusiveMinimum",
11
+ "exclusiveMaximum",
12
+ "minLength",
13
+ "maxLength",
14
+ "multipleOf",
15
+ "minItems",
16
+ "maxItems",
17
+ "uniqueItems",
18
+ "minProperties",
19
+ "maxProperties",
20
+ "additionalProperties",
21
+ "pattern",
22
+ "enum",
23
+ "default"
24
+ ];
25
+ const ARRAY_PROPERTIES = ["type", "items"];
26
+ const APPLICATION_JSON_REGEX = /^(application\/json|[^;\/ \t]+\/[^;\/ \t]+[+]json)[ \t]*(;.*)?$/;
27
+ const SUPPORTED_MIME_TYPES = {
28
+ APPLICATION_X_WWW_URLENCODED: "application/x-www-form-urlencoded",
29
+ MULTIPART_FORM_DATA: "multipart/form-data"
30
+ };
31
+ function fixRef(ref) {
32
+ return ref.replace("#/components/schemas/", "#/definitions/").replace("#/components/", "#/x-components/");
33
+ }
34
+ function fixRefs(obj) {
35
+ if (Array.isArray(obj)) {
36
+ obj.forEach(fixRefs);
37
+ }
38
+ else if (typeof obj === "object") {
39
+ for (let key in obj) {
40
+ if (key === "$ref") {
41
+ obj.$ref = fixRef(obj.$ref);
42
+ }
43
+ else {
44
+ fixRefs(obj[key]);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ function isJsonMimeType(type) {
50
+ return new RegExp(APPLICATION_JSON_REGEX, "i").test(type);
51
+ }
52
+ function getSupportedMimeTypes(content) {
53
+ const MIME_VALUES = Object.keys(SUPPORTED_MIME_TYPES).map((key) => {
54
+ return SUPPORTED_MIME_TYPES[key];
55
+ });
56
+ return Object.keys(content).filter((key) => {
57
+ return MIME_VALUES.indexOf(key) > -1 || isJsonMimeType(key);
58
+ });
59
+ }
60
+ function transformSecurity(securitySchemes) {
61
+ function map(security) {
62
+ const { scheme, type, name, bearerFormat, flows, ...props } = security;
63
+ switch (type) {
64
+ case "http":
65
+ if (scheme === "basic") {
66
+ return {
67
+ ...props,
68
+ type: scheme
69
+ };
70
+ }
71
+ if (scheme === "bearer") {
72
+ return {
73
+ ...props,
74
+ type: "apiKey",
75
+ name: "Authorization",
76
+ in: "header"
77
+ };
78
+ }
79
+ break;
80
+ case "oauth2":
81
+ const flowName = Object.keys(flows)[0];
82
+ const flow = flows[flowName];
83
+ let flowType = flowName;
84
+ if (flowType === "clientCredentials") {
85
+ flowType = "application";
86
+ }
87
+ else if (flowType === "authorizationCode") {
88
+ flowType = "accessCode";
89
+ }
90
+ return {
91
+ type,
92
+ flow: flowType,
93
+ authorizationUrl: flow.authorizationUrl,
94
+ tokenUrl: flow.tokenUrl,
95
+ scopes: flow.scopes
96
+ };
97
+ }
98
+ }
99
+ return Object.entries(securitySchemes).reduce((securityDefinitions, [key, security]) => {
100
+ return {
101
+ ...securityDefinitions,
102
+ [key]: map(security)
103
+ };
104
+ }, {});
105
+ }
106
+ exports.transformSecurity = transformSecurity;
107
+ function transformInformation(server) {
108
+ let serverUrl = server.url;
109
+ const variables = server["variables"] || {};
110
+ for (const variable in variables) {
111
+ const variableObject = variables[variable] || {};
112
+ if (variableObject["default"]) {
113
+ const re = RegExp(`{${variable}}`, "g");
114
+ serverUrl = serverUrl.replace(re, variableObject["default"]);
115
+ }
116
+ }
117
+ const url = new URL(serverUrl);
118
+ return {
119
+ host: url.host ? url.host : undefined,
120
+ basePath: url.pathname,
121
+ schemes: url.protocol !== null ? [url.protocol.substring(0, url.protocol.length - 1)] : undefined
122
+ };
123
+ }
124
+ exports.transformInformation = transformInformation;
125
+ class Converter {
126
+ constructor(spec) {
127
+ this.spec = JSON.parse(JSON.stringify(spec));
128
+ }
129
+ convertInfos() {
130
+ const server = this.spec.servers && this.spec.servers[0];
131
+ if (server) {
132
+ return transformInformation(server);
133
+ }
134
+ return {};
135
+ }
136
+ resolveReference(base, obj, shouldClone) {
137
+ if (!obj || !obj.$ref) {
138
+ return obj;
139
+ }
140
+ const ref = obj.$ref;
141
+ if (ref.startsWith("#")) {
142
+ const keys = ref.split("/").map((k) => k.replace(/~1/g, "/").replace(/~0/g, "~"));
143
+ keys.shift();
144
+ let cur = base;
145
+ keys.forEach((k) => {
146
+ cur = cur[k];
147
+ });
148
+ return shouldClone ? JSON.parse(JSON.stringify(cur)) : cur;
149
+ }
150
+ }
151
+ convert() {
152
+ const spec = {
153
+ swagger: "2.0",
154
+ ...this.convertInfos(),
155
+ paths: this.spec.paths ? this.convertOperations(this.spec.paths, this.spec) : undefined
156
+ };
157
+ if (this.spec.components) {
158
+ this.convertSchemas();
159
+ this.convertSecurityDefinitions();
160
+ this.spec["x-components"] = this.spec.components;
161
+ delete this.spec.components;
162
+ fixRefs(this.spec);
163
+ }
164
+ delete this.spec.servers;
165
+ delete this.spec.openapi;
166
+ delete this.spec["x-components"];
167
+ return (0, core_1.cleanObject)({
168
+ ...spec,
169
+ ...this.spec
170
+ });
171
+ }
172
+ convertOperations(paths, spec) {
173
+ return Object.entries(paths).reduce((paths, [path, operation]) => {
174
+ const pathObject = (paths[path] = this.resolveReference({ ...spec, paths }, operation, true));
175
+ this.convertParameters(pathObject); // converts common parameters
176
+ Object.keys(pathObject).forEach((method) => {
177
+ if (HTTP_METHODS.indexOf(method) >= 0) {
178
+ const operation = (pathObject[method] = this.resolveReference({ ...spec, paths }, pathObject[method], true));
179
+ this.convertOperationParameters(operation);
180
+ this.convertResponses(operation);
181
+ }
182
+ });
183
+ return paths;
184
+ }, paths);
185
+ }
186
+ convertOperationParameters(operation) {
187
+ let content, contentKey, mediaRanges, mediaTypes;
188
+ operation.parameters = operation.parameters || [];
189
+ if (operation.requestBody) {
190
+ let param = this.resolveReference(this.spec, operation.requestBody, true);
191
+ // fixing external $ref in body
192
+ if (operation.requestBody.content) {
193
+ const type = getSupportedMimeTypes(operation.requestBody.content)[0];
194
+ const structuredObj = { content: {} };
195
+ const data = operation.requestBody.content[type];
196
+ if (data && data.schema && data.schema.$ref && !data.schema.$ref.startsWith("#")) {
197
+ param = this.resolveReference(this.spec, data.schema, true);
198
+ structuredObj["content"][`${type}`] = { schema: param };
199
+ param = structuredObj;
200
+ }
201
+ }
202
+ param.name = "body";
203
+ content = param.content;
204
+ if (content && Object.keys(content).length) {
205
+ mediaRanges = Object.keys(content).filter((mediaRange) => mediaRange.indexOf("/") > 0);
206
+ mediaTypes = mediaRanges.filter((range) => range.indexOf("*") < 0);
207
+ contentKey = getSupportedMimeTypes(content)[0];
208
+ delete param.content;
209
+ if ([SUPPORTED_MIME_TYPES.APPLICATION_X_WWW_URLENCODED, SUPPORTED_MIME_TYPES.MULTIPART_FORM_DATA].includes(contentKey)) {
210
+ operation.consumes = mediaTypes;
211
+ param.in = "formData";
212
+ param.schema = content[contentKey].schema;
213
+ param.schema = this.resolveReference(this.spec, param.schema, true);
214
+ if (param.schema.type === "object" && param.schema.properties) {
215
+ const required = param.schema.required || [];
216
+ Object.keys(param.schema.properties).forEach((name) => {
217
+ var _a;
218
+ const schema = param.schema.properties[name];
219
+ // readOnly properties should not be sent in requests
220
+ if (!schema.readOnly) {
221
+ const formDataParam = {
222
+ name,
223
+ in: "formData",
224
+ schema
225
+ };
226
+ if (required.indexOf(name) >= 0) {
227
+ formDataParam.required = true;
228
+ }
229
+ (_a = operation.parameters) === null || _a === void 0 ? void 0 : _a.push(formDataParam);
230
+ }
231
+ });
232
+ }
233
+ else {
234
+ operation.parameters.push(param);
235
+ }
236
+ }
237
+ else if (contentKey) {
238
+ operation.consumes = mediaTypes;
239
+ param.in = "body";
240
+ param.schema = content[contentKey].schema;
241
+ operation.parameters.push(param);
242
+ }
243
+ else if (mediaRanges) {
244
+ operation.consumes = mediaTypes || ["application/octet-stream"];
245
+ param.in = "body";
246
+ param.name = param.name || "file";
247
+ delete param.type;
248
+ param.schema = content[mediaRanges[0]].schema || {
249
+ type: "string",
250
+ format: "binary"
251
+ };
252
+ operation.parameters.push(param);
253
+ }
254
+ if (param.schema) {
255
+ this.convertSchema(param.schema, "request");
256
+ }
257
+ }
258
+ delete operation.requestBody;
259
+ }
260
+ this.convertParameters(operation);
261
+ }
262
+ convertParameters(obj) {
263
+ if (obj.parameters === undefined) {
264
+ return;
265
+ }
266
+ obj.parameters = obj.parameters || [];
267
+ (obj.parameters || []).forEach((param, i) => {
268
+ param = obj.parameters[i] = this.resolveReference(this.spec, param, false);
269
+ if (param.in !== "body") {
270
+ this.copySchemaProperties(param, SCHEMA_PROPERTIES);
271
+ this.copySchemaProperties(param, ARRAY_PROPERTIES);
272
+ this.copySchemaXProperties(param);
273
+ if (!param.description) {
274
+ const schema = this.resolveReference(this.spec, param.schema, false);
275
+ if (!!schema && schema.description) {
276
+ param.description = schema.description;
277
+ }
278
+ }
279
+ if (param.example !== undefined) {
280
+ param["x-example"] = param.example;
281
+ }
282
+ delete param.schema;
283
+ delete param.allowReserved;
284
+ delete param.example;
285
+ }
286
+ if (param.type === "array") {
287
+ let style = param.style || (param.in === "query" || param.in === "cookie" ? "form" : "simple");
288
+ switch (style) {
289
+ case "matrix":
290
+ param.collectionFormat = param.explode ? undefined : "csv";
291
+ break;
292
+ case "label":
293
+ param.collectionFormat = undefined;
294
+ break;
295
+ case "simple":
296
+ param.collectionFormat = "csv";
297
+ break;
298
+ case "spaceDelimited":
299
+ param.collectionFormat = "ssv";
300
+ break;
301
+ case "pipeDelimited":
302
+ param.collectionFormat = "pipes";
303
+ break;
304
+ case "deepOpbject":
305
+ param.collectionFormat = "multi";
306
+ break;
307
+ case "form":
308
+ param.collectionFormat = param.explode === false ? "csv" : "multi";
309
+ break;
310
+ }
311
+ }
312
+ delete param.style;
313
+ delete param.explode;
314
+ });
315
+ }
316
+ copySchemaProperties(obj, props) {
317
+ let schema = this.resolveReference(this.spec, obj.schema, true);
318
+ if (!schema) {
319
+ return;
320
+ }
321
+ props.forEach((prop) => {
322
+ const value = schema[prop];
323
+ if (prop === "additionalProperties" && typeof value === "boolean") {
324
+ return;
325
+ }
326
+ if (value !== undefined) {
327
+ obj[prop] = value;
328
+ }
329
+ });
330
+ }
331
+ copySchemaXProperties(obj) {
332
+ let schema = this.resolveReference(this.spec, obj.schema, true);
333
+ if (!schema) {
334
+ return;
335
+ }
336
+ Object.keys(schema).forEach((propName) => {
337
+ if (Reflect.hasOwnProperty.call(schema, propName) && !Reflect.hasOwnProperty.call(obj, propName) && propName.startsWith("x-")) {
338
+ obj[propName] = schema[propName];
339
+ }
340
+ });
341
+ }
342
+ convertResponses(operation) {
343
+ // var anySchema, code, content, jsonSchema, mediaRange, mediaType, response, resolved, headers
344
+ Object.keys(operation.responses || {}).forEach((code) => {
345
+ const response = (operation.responses[code] = this.resolveReference(this.spec, operation.responses[code], true));
346
+ if (response.content) {
347
+ let anySchema = null;
348
+ let jsonSchema = null;
349
+ Object.keys(response.content).forEach((mediaRange) => {
350
+ // produces and examples only allow media types, not ranges
351
+ // use application/octet-stream as a catch-all type
352
+ const mediaType = mediaRange.indexOf("*") < 0 ? mediaRange : "application/octet-stream";
353
+ if (!operation.produces) {
354
+ operation.produces = [mediaType];
355
+ }
356
+ else if (operation.produces.indexOf(mediaType) < 0) {
357
+ operation.produces.push(mediaType);
358
+ }
359
+ const content = response.content[mediaRange];
360
+ anySchema = anySchema || content.schema;
361
+ if (!jsonSchema && isJsonMimeType(mediaType)) {
362
+ jsonSchema = content.schema;
363
+ }
364
+ if (content.example) {
365
+ response.examples = response.examples || {};
366
+ response.examples[mediaType] = content.example;
367
+ }
368
+ });
369
+ if (anySchema) {
370
+ response.schema = jsonSchema || anySchema;
371
+ const resolved = this.resolveReference(this.spec, response.schema, true);
372
+ if (resolved && response.schema.$ref && !response.schema.$ref.startsWith("#")) {
373
+ response.schema = resolved;
374
+ }
375
+ this.convertSchema(response.schema, "response");
376
+ }
377
+ }
378
+ Object.keys(response.headers || {}).forEach((header) => {
379
+ // Always resolve headers when converting to v2.
380
+ const resolved = this.resolveReference(this.spec, response.headers[header], true);
381
+ // Headers should be converted like parameters.
382
+ if (resolved.schema) {
383
+ resolved.type = resolved.schema.type;
384
+ resolved.format = resolved.schema.format;
385
+ delete resolved.schema;
386
+ }
387
+ response.headers[header] = resolved;
388
+ });
389
+ delete response.content;
390
+ });
391
+ }
392
+ convertSchema(def, operationDirection) {
393
+ if (def.oneOf) {
394
+ delete def.oneOf;
395
+ if (def.discriminator) {
396
+ delete def.discriminator;
397
+ }
398
+ }
399
+ if (def.anyOf) {
400
+ delete def.anyOf;
401
+ if (def.discriminator) {
402
+ delete def.discriminator;
403
+ }
404
+ }
405
+ if (def.allOf) {
406
+ for (const i in def.allOf) {
407
+ this.convertSchema(def.allOf[i], operationDirection);
408
+ }
409
+ }
410
+ if (def.discriminator) {
411
+ if (def.discriminator.mapping) {
412
+ this.convertDiscriminatorMapping(def.discriminator.mapping);
413
+ }
414
+ def.discriminator = def.discriminator.propertyName;
415
+ }
416
+ switch (def.type) {
417
+ case "object":
418
+ if (def.properties) {
419
+ Object.keys(def.properties).forEach((propName) => {
420
+ if (def.properties[propName].writeOnly === true && operationDirection === "response") {
421
+ delete def.properties[propName];
422
+ }
423
+ else {
424
+ this.convertSchema(def.properties[propName], operationDirection);
425
+ delete def.properties[propName].writeOnly;
426
+ }
427
+ });
428
+ }
429
+ break;
430
+ case "array":
431
+ if (def.items) {
432
+ this.convertSchema(def.items, operationDirection);
433
+ }
434
+ }
435
+ if (def.nullable) {
436
+ def["x-nullable"] = true;
437
+ delete def.nullable;
438
+ }
439
+ // OpenAPI 3 has boolean "deprecated" on Schema, OpenAPI 2 does not
440
+ // Convert to x-deprecated for Autorest (and perhaps others)
441
+ if (def["deprecated"] !== undefined) {
442
+ // Move to x-deprecated, unless it is already defined
443
+ if (def["x-deprecated"] === undefined) {
444
+ def["x-deprecated"] = def.deprecated;
445
+ }
446
+ delete def.deprecated;
447
+ }
448
+ }
449
+ convertSchemas() {
450
+ this.spec.definitions = this.spec.components.schemas;
451
+ Object.keys(this.spec.definitions || {}).forEach((defName) => {
452
+ this.convertSchema(this.spec.definitions[defName]);
453
+ });
454
+ delete this.spec.components.schemas;
455
+ }
456
+ convertDiscriminatorMapping(mapping) {
457
+ Object.keys(mapping).forEach((payload) => {
458
+ const schemaNameOrRef = mapping[payload];
459
+ if (typeof schemaNameOrRef !== "string") {
460
+ console.warn(`Ignoring ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);
461
+ return;
462
+ }
463
+ // payload may be a schema name or JSON Reference string.
464
+ // OAS3 spec limits schema names to ^[a-zA-Z0-9._-]+$
465
+ // Note: Valid schema name could be JSON file name without extension.
466
+ // Prefer schema name, with file name as fallback.
467
+ let schema;
468
+ if (/^[a-zA-Z0-9._-]+$/.test(schemaNameOrRef)) {
469
+ try {
470
+ schema = this.resolveReference(this.spec, { $ref: `#/components/schemas/${schemaNameOrRef}` }, false);
471
+ }
472
+ catch (err) {
473
+ console.debug(`Error resolving ${schemaNameOrRef} for ${payload} as schema name in discriminator.mapping: ${err}`);
474
+ }
475
+ }
476
+ // schemaNameRef is not a schema name. Try to resolve as JSON Ref.
477
+ if (!schema) {
478
+ try {
479
+ schema = this.resolveReference(this.spec, { $ref: schemaNameOrRef }, false);
480
+ }
481
+ catch (err) {
482
+ console.debug(`Error resolving ${schemaNameOrRef} for ${payload} in discriminator.mapping: ${err}`);
483
+ }
484
+ }
485
+ if (schema) {
486
+ // Swagger Codegen + OpenAPI Generator extension
487
+ // https://github.com/swagger-api/swagger-codegen/pull/4252
488
+ schema["x-discriminator-value"] = payload;
489
+ // AutoRest extension
490
+ // https://github.com/Azure/autorest/pull/474
491
+ schema["x-ms-discriminator-value"] = payload;
492
+ }
493
+ else {
494
+ console.warn(`Unable to resolve ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);
495
+ }
496
+ });
497
+ }
498
+ convertSecurityDefinitions() {
499
+ if (this.spec.components.securitySchemes) {
500
+ this.spec.securityDefinitions = transformSecurity(this.spec.components.securitySchemes);
501
+ delete this.spec.components.securitySchemes;
502
+ }
503
+ }
504
+ }
505
+ exports.Converter = Converter;
506
+ function transformToOS2(spec) {
507
+ return new Converter(spec).convert();
508
+ }
509
+ exports.transformToOS2 = transformToOS2;
510
+ //# sourceMappingURL=transformToOS2.js.map
@@ -0,0 +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;I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,CAAC,mBAAmB,eAAe,QAAQ,OAAO,8BAA8B,GAAG,EAAE,CAAC,CAAC;iBACrG;aACF;YAED,IAAI,MAAM,EAAE;gBACV,gDAAgD;gBAChD,2DAA2D;gBAC3D,MAAM,CAAC,uBAAuB,CAAC,GAAG,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"]}
@@ -1,7 +1,7 @@
1
- import { JsonLazyRef } from "../domain/JsonLazyRef";
2
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
3
- import { mapGenericsOptions } from "../utils/generics";
4
- import { toRef } from "../utils/ref";
1
+ import { JsonLazyRef } from "../domain/JsonLazyRef.js";
2
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
3
+ import { mapGenericsOptions } from "../utils/generics.js";
4
+ import { toRef } from "../utils/ref.js";
5
5
  export function anyMapper(input, options = {}) {
6
6
  if (typeof input !== "object" || input === null) {
7
7
  return input;
@@ -1,7 +1,7 @@
1
- import { JsonEntityStore } from "../domain/JsonEntityStore";
2
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
3
- import { mapGenericsOptions, popGenerics } from "../utils/generics";
4
- import { createRef, createRefName } from "../utils/ref";
1
+ import { JsonEntityStore } from "../domain/JsonEntityStore.js";
2
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
3
+ import { mapGenericsOptions, popGenerics } from "../utils/generics.js";
4
+ import { createRef, createRefName } from "../utils/ref.js";
5
5
  export function classMapper(value, options) {
6
6
  const store = JsonEntityStore.from(value.class);
7
7
  const name = createRefName(store.schema.getName() || value.getName(), options);
@@ -1,8 +1,8 @@
1
1
  import { isClass, isPrimitiveClass } from "@tsed/core";
2
- import { JsonEntityStore } from "../domain/JsonEntityStore";
3
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
4
- import { popGenerics } from "../utils/generics";
5
- import { getJsonType } from "../utils/getJsonType";
2
+ import { JsonEntityStore } from "../domain/JsonEntityStore.js";
3
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
4
+ import { popGenerics } from "../utils/generics.js";
5
+ import { getJsonType } from "../utils/getJsonType.js";
6
6
  /**
7
7
  * @ignore
8
8
  */
@@ -1,6 +1,6 @@
1
1
  import { classOf, deepMerge } from "@tsed/core";
2
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
3
- import { getInheritedStores } from "../utils/getInheritedStores";
2
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
3
+ import { getInheritedStores } from "../utils/getInheritedStores.js";
4
4
  /**
5
5
  * @ignore
6
6
  */
@@ -1,4 +1,4 @@
1
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
1
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
2
2
  export function itemMapper(value, options) {
3
3
  return value && value.isClass ? execMapper("class", value, options) : execMapper("any", value, options);
4
4
  }
@@ -1,6 +1,6 @@
1
- import { registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
2
- import { mapGenericsOptions } from "../utils/generics";
3
- import { createRef, toRef } from "../utils/ref";
1
+ import { registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
2
+ import { mapGenericsOptions } from "../utils/generics.js";
3
+ import { createRef, toRef } from "../utils/ref.js";
4
4
  export function lazyRefMapper(input, options) {
5
5
  var _a;
6
6
  const name = input.name;