@tsed/schema 7.0.0-beta.2 → 7.0.0-beta.20

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 (367) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +1 -6
  3. package/lib/cjs/components/lazyRefMapper.js +1 -2
  4. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  5. package/lib/cjs/components/objectMapper.js +1 -1
  6. package/lib/cjs/components/objectMapper.js.map +1 -1
  7. package/lib/cjs/components/schemaMapper.js +1 -1
  8. package/lib/cjs/components/schemaMapper.js.map +1 -1
  9. package/lib/cjs/constants/httpStatusMessages.js +14 -100
  10. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  11. package/lib/cjs/decorators/collections/collectionOf.js +3 -4
  12. package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
  13. package/lib/cjs/decorators/common/anyOf.js +4 -0
  14. package/lib/cjs/decorators/common/anyOf.js.map +1 -1
  15. package/lib/cjs/decorators/common/description.js +1 -2
  16. package/lib/cjs/decorators/common/description.js.map +1 -1
  17. package/lib/cjs/decorators/common/enum.js +1 -20
  18. package/lib/cjs/decorators/common/enum.js.map +1 -1
  19. package/lib/cjs/decorators/common/ignore.js.map +1 -1
  20. package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -1
  21. package/lib/cjs/decorators/common/oneOf.js +4 -0
  22. package/lib/cjs/decorators/common/oneOf.js.map +1 -1
  23. package/lib/cjs/decorators/common/recordOf.js +63 -0
  24. package/lib/cjs/decorators/common/recordOf.js.map +1 -0
  25. package/lib/cjs/decorators/operations/acceptMime.js +28 -0
  26. package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
  27. package/lib/cjs/decorators/operations/in.js +6 -4
  28. package/lib/cjs/decorators/operations/in.js.map +1 -1
  29. package/lib/cjs/decorators/operations/redirect.js +1 -2
  30. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  31. package/lib/cjs/decorators/operations/returns.js +43 -21
  32. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  33. package/lib/cjs/decorators/operations/route.js +1 -4
  34. package/lib/cjs/decorators/operations/route.js.map +1 -1
  35. package/lib/cjs/decorators/operations/view.js +31 -0
  36. package/lib/cjs/decorators/operations/view.js.map +1 -0
  37. package/lib/cjs/domain/DecoratorContext.js +6 -3
  38. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  39. package/lib/cjs/domain/JsonClassStore.js +5 -8
  40. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  41. package/lib/cjs/domain/JsonEntityStore.js +40 -1
  42. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  43. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  44. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  45. package/lib/cjs/domain/JsonMap.js.map +1 -1
  46. package/lib/cjs/domain/JsonMethodStore.js +85 -39
  47. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  48. package/lib/cjs/domain/JsonOperation.js +15 -34
  49. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  50. package/lib/cjs/domain/JsonOperationPathsMap.js +2 -16
  51. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  52. package/lib/cjs/domain/JsonOperationRoute.js +11 -8
  53. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  54. package/lib/cjs/domain/JsonParameter.js +42 -48
  55. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  56. package/lib/cjs/domain/JsonParameterStore.js +26 -10
  57. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  58. package/lib/cjs/domain/JsonPropertyStore.js +7 -6
  59. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  60. package/lib/cjs/domain/JsonResponse.js +7 -18
  61. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  62. package/lib/cjs/domain/JsonSchema.js +62 -71
  63. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  64. package/lib/cjs/domain/SpecTypes.js +1 -0
  65. package/lib/cjs/domain/SpecTypes.js.map +1 -1
  66. package/lib/cjs/hooks/alterIgnore.js +2 -3
  67. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  68. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  69. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  70. package/lib/cjs/index.js +150 -20
  71. package/lib/cjs/index.js.map +1 -1
  72. package/lib/cjs/interfaces/JsonSchemaOptions.js.map +1 -1
  73. package/lib/cjs/package.json +3 -0
  74. package/lib/cjs/utils/concatPath.js +16 -1
  75. package/lib/cjs/utils/concatPath.js.map +1 -1
  76. package/lib/cjs/utils/from.js +9 -8
  77. package/lib/cjs/utils/from.js.map +1 -1
  78. package/lib/cjs/utils/generateSpec.js +46 -0
  79. package/lib/cjs/utils/generateSpec.js.map +1 -0
  80. package/lib/cjs/utils/generics.js.map +1 -1
  81. package/lib/cjs/utils/getJsonPathParameters.js +20 -6
  82. package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
  83. package/lib/cjs/utils/getJsonSchema.js +12 -3
  84. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  85. package/lib/cjs/utils/getJsonType.js +1 -1
  86. package/lib/cjs/utils/getJsonType.js.map +1 -1
  87. package/lib/cjs/utils/getOperationsRoutes.js +2 -1
  88. package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
  89. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  90. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  91. package/lib/cjs/utils/getSpec.js +58 -43
  92. package/lib/cjs/utils/getSpec.js.map +1 -1
  93. package/lib/cjs/utils/getSpecType.js +21 -0
  94. package/lib/cjs/utils/getSpecType.js.map +1 -0
  95. package/lib/cjs/utils/mapNullableType.js +1 -1
  96. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  97. package/lib/cjs/utils/mapOpenSpec.js +41 -0
  98. package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
  99. package/lib/cjs/utils/mapOpenSpec2.js +34 -0
  100. package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
  101. package/lib/cjs/utils/mapOpenSpec3.js +26 -0
  102. package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
  103. package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
  104. package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
  105. package/lib/cjs/utils/matchGroups.js +1 -1
  106. package/lib/cjs/utils/matchGroups.js.map +1 -1
  107. package/lib/cjs/utils/mergeOperation.js +2 -2
  108. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  109. package/lib/cjs/utils/mergeSpec.js.map +1 -1
  110. package/lib/cjs/utils/operationIdFormatter.js +3 -3
  111. package/lib/cjs/utils/operationIdFormatter.js.map +1 -1
  112. package/lib/cjs/utils/ref.js +2 -2
  113. package/lib/cjs/utils/ref.js.map +1 -1
  114. package/lib/cjs/utils/serializeEnumValues.js +26 -0
  115. package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
  116. package/lib/cjs/utils/transformToOS2.js +510 -0
  117. package/lib/cjs/utils/transformToOS2.js.map +1 -0
  118. package/lib/esm/components/anyMapper.js +4 -4
  119. package/lib/esm/components/classMapper.js +4 -4
  120. package/lib/esm/components/genericsMapper.js +4 -4
  121. package/lib/esm/components/inheritedClassMapper.js +2 -2
  122. package/lib/esm/components/itemMapper.js +1 -1
  123. package/lib/esm/components/lazyRefMapper.js +4 -5
  124. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  125. package/lib/esm/components/mapMapper.js +2 -2
  126. package/lib/esm/components/objectMapper.js +4 -4
  127. package/lib/esm/components/objectMapper.js.map +1 -1
  128. package/lib/esm/components/ofMapper.js +1 -1
  129. package/lib/esm/components/propertiesMapper.js +1 -1
  130. package/lib/esm/components/schemaMapper.js +7 -7
  131. package/lib/esm/components/schemaMapper.js.map +1 -1
  132. package/lib/esm/constants/httpStatusMessages.js +13 -100
  133. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  134. package/lib/esm/decorators/class/children.js +1 -1
  135. package/lib/esm/decorators/collections/collectionContains.js +1 -1
  136. package/lib/esm/decorators/collections/collectionOf.js +4 -5
  137. package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
  138. package/lib/esm/decorators/collections/maxItems.js +1 -1
  139. package/lib/esm/decorators/collections/maxProperties.js +1 -1
  140. package/lib/esm/decorators/collections/minItems.js +1 -1
  141. package/lib/esm/decorators/collections/minProperties.js +1 -1
  142. package/lib/esm/decorators/collections/uniqueItems.js +1 -1
  143. package/lib/esm/decorators/common/additionalProperties.js +1 -1
  144. package/lib/esm/decorators/common/allOf.js +1 -1
  145. package/lib/esm/decorators/common/allow.js +2 -2
  146. package/lib/esm/decorators/common/any.js +1 -1
  147. package/lib/esm/decorators/common/anyOf.js +5 -1
  148. package/lib/esm/decorators/common/anyOf.js.map +1 -1
  149. package/lib/esm/decorators/common/const.js +1 -1
  150. package/lib/esm/decorators/common/customKey.js +1 -1
  151. package/lib/esm/decorators/common/default.js +1 -1
  152. package/lib/esm/decorators/common/description.js +2 -3
  153. package/lib/esm/decorators/common/description.js.map +1 -1
  154. package/lib/esm/decorators/common/enum.js +2 -21
  155. package/lib/esm/decorators/common/enum.js.map +1 -1
  156. package/lib/esm/decorators/common/example.js +1 -1
  157. package/lib/esm/decorators/common/examples.js +1 -1
  158. package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
  159. package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
  160. package/lib/esm/decorators/common/format.js +2 -2
  161. package/lib/esm/decorators/common/forwardGroups.js +1 -1
  162. package/lib/esm/decorators/common/groups.js +2 -2
  163. package/lib/esm/decorators/common/ignore.js +1 -1
  164. package/lib/esm/decorators/common/ignore.js.map +1 -1
  165. package/lib/esm/decorators/common/integer.js +1 -1
  166. package/lib/esm/decorators/common/jsonEntityFn.js +1 -1
  167. package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -1
  168. package/lib/esm/decorators/common/maxLength.js +1 -1
  169. package/lib/esm/decorators/common/maximum.js +1 -1
  170. package/lib/esm/decorators/common/minLength.js +1 -1
  171. package/lib/esm/decorators/common/minimum.js +1 -1
  172. package/lib/esm/decorators/common/multipleOf.js +1 -1
  173. package/lib/esm/decorators/common/name.js +1 -1
  174. package/lib/esm/decorators/common/nullable.js +2 -2
  175. package/lib/esm/decorators/common/oneOf.js +5 -1
  176. package/lib/esm/decorators/common/oneOf.js.map +1 -1
  177. package/lib/esm/decorators/common/optional.js +1 -1
  178. package/lib/esm/decorators/common/pattern.js +1 -1
  179. package/lib/esm/decorators/common/property.js +1 -1
  180. package/lib/esm/decorators/common/readOnly.js +1 -1
  181. package/lib/esm/decorators/common/recordOf.js +59 -0
  182. package/lib/esm/decorators/common/recordOf.js.map +1 -0
  183. package/lib/esm/decorators/common/required.js +2 -2
  184. package/lib/esm/decorators/common/requiredGroups.js +2 -2
  185. package/lib/esm/decorators/common/schema.js +1 -1
  186. package/lib/esm/decorators/common/title.js +1 -1
  187. package/lib/esm/decorators/common/writeOnly.js +1 -1
  188. package/lib/esm/decorators/config/jsonEntityComponent.js +1 -1
  189. package/lib/esm/decorators/generics/genericOf.js +2 -2
  190. package/lib/esm/decorators/generics/generics.js +1 -1
  191. package/lib/esm/decorators/operations/acceptMime.js +24 -0
  192. package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
  193. package/lib/esm/decorators/operations/consumes.js +1 -1
  194. package/lib/esm/decorators/operations/contentType.js +1 -1
  195. package/lib/esm/decorators/operations/deprecated.js +1 -1
  196. package/lib/esm/decorators/operations/header.js +1 -1
  197. package/lib/esm/decorators/operations/in.js +3 -1
  198. package/lib/esm/decorators/operations/in.js.map +1 -1
  199. package/lib/esm/decorators/operations/inFile.js +5 -5
  200. package/lib/esm/decorators/operations/location.js +1 -1
  201. package/lib/esm/decorators/operations/operationId.js +1 -1
  202. package/lib/esm/decorators/operations/operationPath.js +1 -1
  203. package/lib/esm/decorators/operations/partial.js +1 -1
  204. package/lib/esm/decorators/operations/path.js +1 -1
  205. package/lib/esm/decorators/operations/produces.js +1 -1
  206. package/lib/esm/decorators/operations/redirect.js +3 -4
  207. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  208. package/lib/esm/decorators/operations/returns.js +51 -29
  209. package/lib/esm/decorators/operations/returns.js.map +1 -1
  210. package/lib/esm/decorators/operations/route.js +4 -7
  211. package/lib/esm/decorators/operations/route.js.map +1 -1
  212. package/lib/esm/decorators/operations/security.js +1 -1
  213. package/lib/esm/decorators/operations/status.js +1 -1
  214. package/lib/esm/decorators/operations/summary.js +1 -1
  215. package/lib/esm/decorators/operations/tags.js +1 -1
  216. package/lib/esm/decorators/operations/view.js +27 -0
  217. package/lib/esm/decorators/operations/view.js.map +1 -0
  218. package/lib/esm/domain/DecoratorContext.js +6 -3
  219. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  220. package/lib/esm/domain/JsonClassStore.js +7 -10
  221. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  222. package/lib/esm/domain/JsonEntityStore.js +40 -1
  223. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  224. package/lib/esm/domain/JsonLazyRef.js +4 -3
  225. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  226. package/lib/esm/domain/JsonMap.js +1 -1
  227. package/lib/esm/domain/JsonMap.js.map +1 -1
  228. package/lib/esm/domain/JsonMethodStore.js +86 -40
  229. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  230. package/lib/esm/domain/JsonOperation.js +22 -41
  231. package/lib/esm/domain/JsonOperation.js.map +1 -1
  232. package/lib/esm/domain/JsonOperationPathsMap.js +3 -17
  233. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  234. package/lib/esm/domain/JsonOperationRoute.js +12 -9
  235. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  236. package/lib/esm/domain/JsonParameter.js +46 -52
  237. package/lib/esm/domain/JsonParameter.js.map +1 -1
  238. package/lib/esm/domain/JsonParameterStore.js +29 -13
  239. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  240. package/lib/esm/domain/JsonPropertyStore.js +8 -7
  241. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  242. package/lib/esm/domain/JsonRequestBody.js +2 -2
  243. package/lib/esm/domain/JsonResponse.js +10 -21
  244. package/lib/esm/domain/JsonResponse.js.map +1 -1
  245. package/lib/esm/domain/JsonSchema.js +67 -76
  246. package/lib/esm/domain/JsonSchema.js.map +1 -1
  247. package/lib/esm/domain/SpecTypes.js +1 -0
  248. package/lib/esm/domain/SpecTypes.js.map +1 -1
  249. package/lib/esm/hooks/alterIgnore.js +2 -3
  250. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  251. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  252. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  253. package/lib/esm/index.js +150 -20
  254. package/lib/esm/index.js.map +1 -1
  255. package/lib/esm/interfaces/JsonSchemaOptions.js.map +1 -1
  256. package/lib/esm/package.json +3 -0
  257. package/lib/esm/utils/concatPath.js +16 -1
  258. package/lib/esm/utils/concatPath.js.map +1 -1
  259. package/lib/esm/utils/from.js +5 -4
  260. package/lib/esm/utils/from.js.map +1 -1
  261. package/lib/esm/utils/generateSpec.js +41 -0
  262. package/lib/esm/utils/generateSpec.js.map +1 -0
  263. package/lib/esm/utils/generics.js.map +1 -1
  264. package/lib/esm/utils/getInheritedStores.js +1 -1
  265. package/lib/esm/utils/getJsonEntityStore.js +5 -5
  266. package/lib/esm/utils/getJsonPathParameters.js +20 -6
  267. package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
  268. package/lib/esm/utils/getJsonSchema.js +15 -6
  269. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  270. package/lib/esm/utils/getJsonType.js +2 -2
  271. package/lib/esm/utils/getJsonType.js.map +1 -1
  272. package/lib/esm/utils/getOperationsRoutes.js +5 -4
  273. package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
  274. package/lib/esm/utils/getOperationsStores.js +4 -4
  275. package/lib/esm/utils/getPropertiesStores.js +3 -3
  276. package/lib/esm/utils/getRequiredProperties.js +4 -4
  277. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  278. package/lib/esm/utils/getSpec.js +65 -50
  279. package/lib/esm/utils/getSpec.js.map +1 -1
  280. package/lib/esm/utils/getSpecType.js +16 -0
  281. package/lib/esm/utils/getSpecType.js.map +1 -0
  282. package/lib/esm/utils/mapNullableType.js +2 -2
  283. package/lib/esm/utils/mapNullableType.js.map +1 -1
  284. package/lib/esm/utils/mapOpenSpec.js +37 -0
  285. package/lib/esm/utils/mapOpenSpec.js.map +1 -0
  286. package/lib/esm/utils/mapOpenSpec2.js +30 -0
  287. package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
  288. package/lib/esm/utils/mapOpenSpec3.js +22 -0
  289. package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
  290. package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
  291. package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
  292. package/lib/esm/utils/mapRouteOptions.js +1 -1
  293. package/lib/esm/utils/mergeOperation.js +5 -5
  294. package/lib/esm/utils/mergeOperation.js.map +1 -1
  295. package/lib/esm/utils/mergeSpec.js.map +1 -1
  296. package/lib/esm/utils/operationIdFormatter.js +1 -1
  297. package/lib/esm/utils/operationIdFormatter.js.map +1 -1
  298. package/lib/esm/utils/ref.js +2 -2
  299. package/lib/esm/utils/ref.js.map +1 -1
  300. package/lib/esm/utils/serializeEnumValues.js +21 -0
  301. package/lib/esm/utils/serializeEnumValues.js.map +1 -0
  302. package/lib/esm/utils/toJsonMapCollection.js +1 -1
  303. package/lib/esm/utils/transformToOS2.js +504 -0
  304. package/lib/esm/utils/transformToOS2.js.map +1 -0
  305. package/lib/types/constants/httpStatusMessages.d.ts +2 -263
  306. package/lib/types/decorators/common/anyOf.d.ts +4 -0
  307. package/lib/types/decorators/common/ignore.d.ts +1 -1
  308. package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
  309. package/lib/types/decorators/common/oneOf.d.ts +4 -0
  310. package/lib/types/decorators/common/recordOf.d.ts +46 -0
  311. package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
  312. package/lib/types/decorators/operations/in.d.ts +1 -1
  313. package/lib/types/decorators/operations/returns.d.ts +7 -2
  314. package/lib/types/decorators/operations/view.d.ts +23 -0
  315. package/lib/types/domain/JsonEntityStore.d.ts +1 -0
  316. package/lib/types/domain/JsonMap.d.ts +1 -1
  317. package/lib/types/domain/JsonMethodStore.d.ts +56 -4
  318. package/lib/types/domain/JsonOperation.d.ts +2 -2
  319. package/lib/types/domain/JsonOperationPathsMap.d.ts +0 -2
  320. package/lib/types/domain/JsonOperationRoute.d.ts +7 -6
  321. package/lib/types/domain/JsonParameter.d.ts +2 -1
  322. package/lib/types/domain/JsonParameterStore.d.ts +23 -1
  323. package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
  324. package/lib/types/domain/JsonResponse.d.ts +3 -1
  325. package/lib/types/domain/JsonSchema.d.ts +2 -2
  326. package/lib/types/domain/SpecTypes.d.ts +1 -0
  327. package/lib/types/index.d.ts +143 -13
  328. package/lib/types/interfaces/JsonSchemaOptions.d.ts +2 -2
  329. package/lib/types/utils/concatPath.d.ts +1 -1
  330. package/lib/types/utils/generateSpec.d.ts +16 -0
  331. package/lib/types/utils/generics.d.ts +1 -1
  332. package/lib/types/utils/getJsonSchema.d.ts +12 -2
  333. package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
  334. package/lib/types/utils/getSpec.d.ts +5 -4
  335. package/lib/types/utils/getSpecType.d.ts +12 -0
  336. package/lib/types/utils/mapNullableType.d.ts +1 -1
  337. package/lib/types/utils/mapOpenSpec.d.ts +10 -0
  338. package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
  339. package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
  340. package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
  341. package/lib/types/utils/mergeSpec.d.ts +2 -2
  342. package/lib/types/utils/serializeEnumValues.d.ts +5 -0
  343. package/lib/types/utils/transformToOS2.d.ts +25 -0
  344. package/package.json +35 -18
  345. package/readme.md +4 -2
  346. package/tsconfig.compile.esm.json +4 -13
  347. package/benchmark/cold-start.js +0 -17
  348. package/lib/cjs/components/index.js +0 -15
  349. package/lib/cjs/components/index.js.map +0 -1
  350. package/lib/cjs/decorators/index.js +0 -77
  351. package/lib/cjs/decorators/index.js.map +0 -1
  352. package/lib/cjs/domain/index.js +0 -20
  353. package/lib/cjs/domain/index.js.map +0 -1
  354. package/lib/cjs/interfaces/index.js +0 -8
  355. package/lib/cjs/interfaces/index.js.map +0 -1
  356. package/lib/esm/components/index.js +0 -12
  357. package/lib/esm/components/index.js.map +0 -1
  358. package/lib/esm/decorators/index.js +0 -74
  359. package/lib/esm/decorators/index.js.map +0 -1
  360. package/lib/esm/domain/index.js +0 -17
  361. package/lib/esm/domain/index.js.map +0 -1
  362. package/lib/esm/interfaces/index.js +0 -5
  363. package/lib/esm/interfaces/index.js.map +0 -1
  364. package/lib/types/components/index.d.ts +0 -11
  365. package/lib/types/decorators/index.d.ts +0 -68
  366. package/lib/types/domain/index.d.ts +0 -16
  367. package/lib/types/interfaces/index.d.ts +0 -4
@@ -6,12 +6,12 @@ const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperConta
6
6
  const generics_1 = require("../utils/generics");
7
7
  const JsonMap_1 = require("./JsonMap");
8
8
  const JsonParameterTypes_1 = require("./JsonParameterTypes");
9
- const SpecTypes_1 = require("./SpecTypes");
9
+ const ref_1 = require("../utils/ref");
10
10
  class JsonParameter extends JsonMap_1.JsonMap {
11
- constructor() {
12
- super(...arguments);
13
- this.nestedGenerics = [];
14
- }
11
+ nestedGenerics = [];
12
+ groups;
13
+ $schema;
14
+ expression;
15
15
  getName() {
16
16
  const name = this.get("name");
17
17
  if (this.get("in") === "files") {
@@ -58,56 +58,49 @@ class JsonParameter extends JsonMap_1.JsonMap {
58
58
  ...(0, generics_1.popGenerics)(this)
59
59
  });
60
60
  parameter.required = parameter.required || this.get("in") === JsonParameterTypes_1.JsonParameterTypes.PATH;
61
- if (this.get("in") === JsonParameterTypes_1.JsonParameterTypes.FILES) {
62
- const isOpenApi = options.specType === SpecTypes_1.SpecTypes.OPENAPI;
63
- const schema = {
64
- type: isOpenApi ? "string" : "file",
65
- format: isOpenApi ? "binary" : undefined,
66
- oneOf: undefined
67
- };
68
- if (jsonSchema.type === "array") {
69
- jsonSchema.items = (0, core_1.cleanObject)({
70
- ...jsonSchema.items,
71
- ...schema
72
- });
73
- parameter.schema = jsonSchema;
74
- }
75
- else {
76
- parameter.schema = (0, core_1.cleanObject)({
77
- ...jsonSchema,
78
- ...schema
79
- });
80
- }
81
- return parameter;
82
- }
83
- if (["query"].includes(this.get("in")) && jsonSchema.$ref) {
84
- if (!parameter.name) {
85
- return this.refToParameters(parameter, options, schemasContainer);
86
- }
87
- parameter.style = "deepObject";
61
+ switch (this.get("in")) {
62
+ case JsonParameterTypes_1.JsonParameterTypes.FILES:
63
+ return this.getFileSchema(jsonSchema, parameter);
64
+ case JsonParameterTypes_1.JsonParameterTypes.QUERY:
65
+ if (jsonSchema.$ref) {
66
+ if (!parameter.name) {
67
+ return this.refToParameters(parameter, options, schemasContainer);
68
+ }
69
+ parameter.style = "deepObject";
70
+ }
71
+ break;
88
72
  }
89
73
  parameter.schema = jsonSchema;
90
74
  return parameter;
91
75
  }
76
+ getFileSchema(jsonSchema, parameter) {
77
+ const schema = {
78
+ type: "string",
79
+ format: "binary",
80
+ oneOf: undefined
81
+ };
82
+ if (jsonSchema.type === "array") {
83
+ jsonSchema.items = (0, core_1.cleanObject)({
84
+ ...jsonSchema.items,
85
+ ...schema
86
+ });
87
+ parameter.schema = jsonSchema;
88
+ }
89
+ else {
90
+ parameter.schema = (0, core_1.cleanObject)({
91
+ ...jsonSchema,
92
+ ...schema
93
+ });
94
+ }
95
+ return parameter;
96
+ }
92
97
  refToParameters(parameter, options, schemasContainer) {
93
- const schema = options.schemas[this.$schema.getName()];
94
- if (options.schemas[this.$schema.getName()] && !schemasContainer.has(this.$schema.getName())) {
98
+ const name = (0, ref_1.createRefName)(this.$schema.getName(), options);
99
+ const schema = options.schemas[name];
100
+ if (options.schemas[name] && !schemasContainer.has(name)) {
95
101
  delete options.schemas[this.$schema.getName()];
96
102
  }
97
103
  return Object.entries(schema.properties || {}).reduce((params, [key, { description, ...prop }]) => {
98
- if (options.specType === SpecTypes_1.SpecTypes.OPENAPI) {
99
- return [
100
- ...params,
101
- (0, core_1.cleanObject)({
102
- ...parameter,
103
- name: key,
104
- required: (schema.required || []).includes(key),
105
- description,
106
- schema: prop,
107
- style: prop.$ref ? "deepObject" : undefined
108
- })
109
- ];
110
- }
111
104
  return [
112
105
  ...params,
113
106
  (0, core_1.cleanObject)({
@@ -115,7 +108,8 @@ class JsonParameter extends JsonMap_1.JsonMap {
115
108
  name: key,
116
109
  required: (schema.required || []).includes(key),
117
110
  description,
118
- ...prop
111
+ schema: prop,
112
+ style: prop.$ref ? "deepObject" : undefined
119
113
  })
120
114
  ];
121
115
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"JsonParameter.js","sourceRoot":"","sources":["../../../src/domain/JsonParameter.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAGpD,uFAAmE;AACnE,gDAA8D;AAC9D,uCAAkC;AAClC,6DAA8F;AAE9F,2CAAsC;AAEtC,MAAa,aAAc,SAAQ,iBAAiC;IAApE;;QACE,mBAAc,GAAkB,EAAE,CAAC;IAiJrC,CAAC;IA5IC,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE9B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE;YAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC;IACd,CAA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BACH,CAAC;aACH;YAED,OAAO;gBACL,GAAG,MAAM;gBACT,IAAA,kBAAW,EAAC;oBACV,GAAG,SAAS;oBACZ,IAAI,EAAE,GAAG;oBACT,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAC/C,WAAW;oBACX,GAAG,IAAI;iBACR,CAAC;aACH,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AAlJD,sCAkJC","sourcesContent":["import {cleanObject, toMap, Type} from \"@tsed/core\";\nimport {OpenSpecHash, OpenSpecRef, OS3Example, OS3Parameter, OS3Schema} from \"@tsed/openspec\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics, popGenerics} from \"../utils/generics\";\nimport {JsonMap} from \"./JsonMap\";\nimport {formatParameterType, isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {SpecTypes} from \"./SpecTypes\";\n\nexport class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements NestedGenerics {\n nestedGenerics: Type<any>[][] = [];\n groups: string[];\n $schema: JsonSchema;\n expression: string;\n\n getName() {\n const name = this.get(\"name\");\n\n if (this.get(\"in\") === \"files\") {\n return name.split(\".\")[0];\n }\n\n return name;\n }\n\n name(name: string): this {\n this.set(\"name\", name);\n\n return this;\n }\n\n examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n in(inType: string, expression: string | any = \"\"): this {\n this.set(\"in\", formatParameterType(inType));\n this.expression = expression;\n\n return this;\n }\n\n required(required: boolean): this {\n this.set(\"required\", required);\n\n return this;\n }\n\n schema(schema: JsonSchema): this {\n this.$schema = schema;\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n if (!isParameterType(this.get(\"in\"))) {\n return null;\n }\n\n const schemasContainer = toMap<string, OS3Schema>(options.schemas || {});\n\n return this.build({...options, groups: this.groups}, schemasContainer);\n }\n\n private build(options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const {type, schema, ...parameter} = super.toJSON(options);\n\n const jsonSchema = execMapper(\"item\", this.$schema, {\n ...options,\n ...popGenerics(this)\n });\n\n parameter.required = parameter.required || this.get(\"in\") === JsonParameterTypes.PATH;\n\n if (this.get(\"in\") === JsonParameterTypes.FILES) {\n const isOpenApi = options.specType === SpecTypes.OPENAPI;\n\n const schema = {\n type: isOpenApi ? \"string\" : \"file\",\n format: isOpenApi ? \"binary\" : undefined,\n oneOf: undefined\n };\n\n if (jsonSchema.type === \"array\") {\n jsonSchema.items = cleanObject({\n ...jsonSchema.items,\n ...schema\n });\n\n parameter.schema = jsonSchema;\n } else {\n parameter.schema = cleanObject({\n ...jsonSchema,\n ...schema\n });\n }\n\n return parameter;\n }\n\n if ([\"query\"].includes(this.get(\"in\")) && jsonSchema.$ref) {\n if (!parameter.name) {\n return this.refToParameters(parameter, options, schemasContainer);\n }\n\n parameter.style = \"deepObject\";\n }\n\n parameter.schema = jsonSchema;\n\n return parameter;\n }\n\n private refToParameters(parameter: any, options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const schema = options.schemas![this.$schema.getName()];\n\n if (options.schemas![this.$schema.getName()] && !schemasContainer.has(this.$schema.getName())) {\n delete options.schemas![this.$schema.getName()];\n }\n\n return Object.entries(schema.properties || {}).reduce((params, [key, {description, ...prop}]: [string, any]) => {\n if (options.specType === SpecTypes.OPENAPI) {\n return [\n ...params,\n cleanObject({\n ...parameter,\n name: key,\n required: (schema.required || []).includes(key),\n description,\n schema: prop,\n style: prop.$ref ? \"deepObject\" : undefined\n })\n ];\n }\n\n return [\n ...params,\n cleanObject({\n ...parameter,\n name: key,\n required: (schema.required || []).includes(key),\n description,\n ...prop\n })\n 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AC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAC,WAAW,EAAE,GAAG,IAAI,EAAC,CAAgB,EAAE,EAAE;YAC7G,OAAO;gBACL,GAAG,MAAM;gBACT,IAAA,kBAAW,EAAC;oBACV,GAAG,SAAS;oBACZ,IAAI,EAAE,GAAG;oBACT,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAC/C,WAAW;oBACX,MAAM,EAAE,IAAI;oBACZ,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;iBAC5C,CAAC;aACH,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AA1ID,sCA0IC","sourcesContent":["import {cleanObject, toMap, Type} from \"@tsed/core\";\nimport {OpenSpecHash, OpenSpecRef, OS3Example, OS3Parameter, OS3Schema} from \"@tsed/openspec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics, popGenerics} from \"../utils/generics\";\nimport {JsonMap} from \"./JsonMap\";\nimport {formatParameterType, isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {createRefName} from \"../utils/ref\";\n\nexport class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements NestedGenerics {\n nestedGenerics: Type<any>[][] = [];\n groups: string[];\n $schema: JsonSchema;\n expression: string;\n\n getName() {\n const name = this.get(\"name\");\n\n if (this.get(\"in\") === \"files\") {\n return name.split(\".\")[0];\n }\n\n return name;\n }\n\n name(name: string): this {\n this.set(\"name\", name);\n\n return this;\n }\n\n examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n in(inType: string, expression: string | any = \"\"): this {\n this.set(\"in\", formatParameterType(inType));\n this.expression = expression;\n\n return this;\n }\n\n required(required: boolean): this {\n this.set(\"required\", required);\n\n return this;\n }\n\n schema(schema: JsonSchema): this {\n this.$schema = schema;\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n if (!isParameterType(this.get(\"in\"))) {\n return null;\n }\n\n const schemasContainer = toMap<string, OS3Schema>(options.schemas || {});\n\n return this.build({...options, groups: this.groups}, schemasContainer);\n }\n\n private build(options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const {type, schema, ...parameter} = super.toJSON(options);\n\n const jsonSchema = execMapper(\"item\", this.$schema, {\n ...options,\n ...popGenerics(this)\n });\n\n parameter.required = parameter.required || this.get(\"in\") === JsonParameterTypes.PATH;\n\n switch (this.get(\"in\")) {\n case JsonParameterTypes.FILES:\n return this.getFileSchema(jsonSchema, parameter);\n case JsonParameterTypes.QUERY:\n if (jsonSchema.$ref) {\n if (!parameter.name) {\n return this.refToParameters(parameter, options, schemasContainer);\n }\n\n parameter.style = \"deepObject\";\n }\n break;\n }\n\n parameter.schema = jsonSchema;\n\n return parameter;\n }\n\n private getFileSchema(jsonSchema: any, parameter: Pick<any, string | number | symbol>) {\n const schema = {\n type: \"string\",\n format: \"binary\",\n oneOf: undefined\n };\n\n if (jsonSchema.type === \"array\") {\n jsonSchema.items = cleanObject({\n ...jsonSchema.items,\n ...schema\n });\n\n parameter.schema = jsonSchema;\n } else {\n parameter.schema = cleanObject({\n ...jsonSchema,\n ...schema\n });\n }\n\n return parameter;\n }\n\n private refToParameters(parameter: any, options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const name = createRefName(this.$schema.getName(), options);\n const schema = options.schemas![name];\n\n if (options.schemas![name] && !schemasContainer.has(name)) {\n delete options.schemas![this.$schema.getName()];\n }\n\n return Object.entries(schema.properties || {}).reduce((params, [key, {description, ...prop}]: [string, any]) => {\n return [\n ...params,\n cleanObject({\n ...parameter,\n name: key,\n required: (schema.required || []).includes(key),\n description,\n schema: prop,\n style: prop.$ref ? \"deepObject\" : undefined\n })\n ];\n }, []);\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonParameterStore = void 0;
3
+ exports.ParamMetadata = exports.JsonParameterStore = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@tsed/core");
6
6
  const JsonEntityStore_1 = require("./JsonEntityStore");
@@ -8,13 +8,24 @@ const JsonParameter_1 = require("./JsonParameter");
8
8
  const JsonSchema_1 = require("./JsonSchema");
9
9
  const jsonEntityComponent_1 = require("../decorators/config/jsonEntityComponent");
10
10
  let JsonParameterStore = class JsonParameterStore extends JsonEntityStore_1.JsonEntityStore {
11
- constructor() {
12
- super(...arguments);
13
- /**
14
- * Ref to JsonParameter when the decorated object is a parameter.
15
- */
16
- this.parameter = new JsonParameter_1.JsonParameter();
17
- this.parent = JsonEntityStore_1.JsonEntityStore.fromMethod(this.target, this.propertyKey);
11
+ paramType;
12
+ expression;
13
+ dataPath;
14
+ /**
15
+ * Define pipes can be called by the framework to transform input parameter
16
+ */
17
+ pipes;
18
+ /**
19
+ * Ref to JsonParameter when the decorated object is a parameter.
20
+ */
21
+ parameter = new JsonParameter_1.JsonParameter();
22
+ parent = JsonEntityStore_1.JsonEntityStore.fromMethod(this.target, this.propertyKey);
23
+ constructor(options) {
24
+ super(options);
25
+ this.pipes = options.pipes || [];
26
+ this.paramType = options.paramType || this.paramType;
27
+ this.expression = options.expression || this.expression;
28
+ this.dataPath = options.dataPath || this.dataPath;
18
29
  }
19
30
  get nestedGenerics() {
20
31
  return this.parameter.nestedGenerics;
@@ -50,6 +61,9 @@ let JsonParameterStore = class JsonParameterStore extends JsonEntityStore_1.Json
50
61
  }
51
62
  return [];
52
63
  }
64
+ static get(target, propertyKey, index) {
65
+ return JsonEntityStore_1.JsonEntityStore.from((0, core_1.prototypeOf)(target), propertyKey, index);
66
+ }
53
67
  /**
54
68
  * Check precondition between value, required and allowedRequiredValues to know if the entity is required.
55
69
  * @param value
@@ -83,8 +97,10 @@ let JsonParameterStore = class JsonParameterStore extends JsonEntityStore_1.Json
83
97
  }
84
98
  }
85
99
  };
86
- JsonParameterStore = (0, tslib_1.__decorate)([
87
- (0, jsonEntityComponent_1.JsonEntityComponent)(core_1.DecoratorTypes.PARAM)
100
+ JsonParameterStore = tslib_1.__decorate([
101
+ (0, jsonEntityComponent_1.JsonEntityComponent)(core_1.DecoratorTypes.PARAM),
102
+ tslib_1.__metadata("design:paramtypes", [Object])
88
103
  ], JsonParameterStore);
89
104
  exports.JsonParameterStore = JsonParameterStore;
105
+ exports.ParamMetadata = JsonParameterStore;
90
106
  //# sourceMappingURL=JsonParameterStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.ts"],"names":[],"mappings":";;;;AAAA,qCAWoB;AACpB,uDAAkD;AAElD,mDAA8C;AAC9C,6CAAwC;AACxC,kFAA6E;AAG7E,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,iCAAe;IAAvD;;QACE;;WAEG;QACM,cAAS,GAAkB,IAAI,6BAAa,EAAE,CAAC;QAC/C,WAAM,GAAoB,iCAAe,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAwF/F,CAAC;IAtFC,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;IACvC,CAAC;IAED,IAAI,cAAc,CAAC,cAA6B;QAC9C,IAAI,CAAC,SAAS,CAAC,cAAc,GAAG,cAAc,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,QAAQ,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f,\n Store,\n Type\n} from \"@tsed/core\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\n@JsonEntityComponent(DecoratorTypes.PARAM)\nexport class JsonParameterStore extends JsonEntityStore {\n /**\n * Ref to JsonParameter when the decorated object is a parameter.\n */\n readonly parameter: JsonParameter = new JsonParameter();\n readonly parent: JsonMethodStore = JsonEntityStore.fromMethod(this.target, this.propertyKey);\n\n get nestedGenerics(): Type<any>[][] {\n return this.parameter.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.parameter.nestedGenerics = nestedGenerics;\n }\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return !!this.parameter.get(\"required\");\n }\n\n set required(value: boolean) {\n this.parameter.required(value);\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[] {\n const params: T[] = [];\n\n const klass = ancestorsOf(target)\n .reverse()\n .find((target) => {\n return isMethodDescriptor(target, propertyKey) && JsonEntityStore.fromMethod(target, propertyKey).children.size;\n });\n\n if (klass) {\n JsonEntityStore.fromMethod(klass, propertyKey).children.forEach((param: T, index) => {\n params[+index] = param;\n });\n\n return params;\n }\n\n return [];\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected getSchema(type: any) {\n if (isCollection(type) || !isClass(type)) {\n return JsonSchema.from({\n type\n });\n }\n\n return JsonEntityStore.from(type).schema;\n }\n\n protected build() {\n if (!this._type) {\n const type: any = Metadata.getParamTypes(prototypeOf(this.target), this.propertyKey)[this.index!];\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n if (!this._schema) {\n this.parent.children.set(this.index!, this);\n\n this._schema = this.getSchema(this.collectionType || this.type);\n\n this.parameter.schema(this._schema);\n\n if (this.collectionType) {\n this._schema.itemSchema(this.getSchema(this.type));\n }\n\n this.parent.operation.addParameter(this.index as number, this.parameter);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.ts"],"names":[],"mappings":";;;;AAAA,qCAA+H;AAC/H,uDAA0E;AAE1E,mDAA8C;AAC9C,6CAAwC;AACxC,kFAA6E;AAa7E,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,iCAAe;IAC9C,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,QAAQ,CAAS;IACxB;;OAEG;IACI,KAAK,CAAsB;IAClC;;OAEG;IACM,SAAS,GAAkB,IAAI,6BAAa,EAAE,CAAC;IAC/C,MAAM,GAAoB,iCAAe,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAE7F,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;IACpD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;IACvC,CAAC;IAED,IAAI,cAAc,CAAC,cAA6B;QAC9C,IAAI,CAAC,SAAS,CAAC,cAAc,GA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C;aACpD;YAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,KAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;SAC1E;IACH,CAAC;CACF,CAAA;AAhHY,kBAAkB;IAD9B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,KAAK,CAAC;;GAC7B,kBAAkB,CAgH9B;AAhHY,gDAAkB;AAsHlB,QAAA,aAAa,GAAG,kBAAkB,CAAC","sourcesContent":["import {ancestorsOf, DecoratorTypes, isClass, isCollection, isMethodDescriptor, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonParameterStoreOptions extends JsonEntityStoreOptions {\n dataPath?: string;\n paramType?: string;\n expression?: string;\n}\n\nexport interface PipeMethods<T = any, R = any> {\n transform(value: T, metadata: JsonParameterStore): R;\n}\n\n@JsonEntityComponent(DecoratorTypes.PARAM)\nexport class JsonParameterStore extends JsonEntityStore {\n public paramType: string;\n public expression: string;\n public dataPath: string;\n /**\n * Define pipes can be called by the framework to transform input parameter\n */\n public pipes: Type<PipeMethods>[];\n /**\n * Ref to JsonParameter when the decorated object is a parameter.\n */\n readonly parameter: JsonParameter = new JsonParameter();\n readonly parent: JsonMethodStore = JsonEntityStore.fromMethod(this.target, this.propertyKey);\n\n constructor(options: JsonParameterStoreOptions) {\n super(options);\n this.pipes = options.pipes || [];\n this.paramType = options.paramType || this.paramType;\n this.expression = options.expression || this.expression;\n this.dataPath = options.dataPath || this.dataPath;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.parameter.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.parameter.nestedGenerics = nestedGenerics;\n }\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return !!this.parameter.get(\"required\");\n }\n\n set required(value: boolean) {\n this.parameter.required(value);\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[] {\n const params: T[] = [];\n\n const klass = ancestorsOf(target)\n .reverse()\n .find((target) => {\n return isMethodDescriptor(target, propertyKey) && JsonEntityStore.fromMethod(target, propertyKey).children.size;\n });\n\n if (klass) {\n JsonEntityStore.fromMethod(klass, propertyKey).children.forEach((param: T, index) => {\n params[+index] = param;\n });\n\n return params;\n }\n\n return [];\n }\n\n static get(target: Type<any>, propertyKey: string | symbol, index: number) {\n return JsonEntityStore.from<JsonParameterStore>(prototypeOf(target), propertyKey, index);\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected getSchema(type: any) {\n if (isCollection(type) || !isClass(type)) {\n return JsonSchema.from({\n type\n });\n }\n\n return JsonEntityStore.from(type).schema;\n }\n\n protected build() {\n if (!this._type) {\n const type: any = Metadata.getParamTypes(prototypeOf(this.target), this.propertyKey)[this.index!];\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n if (!this._schema) {\n this.parent.children.set(this.index!, this);\n\n this._schema = this.getSchema(this.collectionType || this.type);\n\n this.parameter.schema(this._schema);\n\n if (this.collectionType) {\n this._schema.itemSchema(this.getSchema(this.type));\n }\n\n this.parent.operation.addParameter(this.index as number, this.parameter);\n }\n }\n}\n\n/**\n * @alias JsonParameterStore\n */\nexport type ParamMetadata = JsonParameterStore;\nexport const ParamMetadata = JsonParameterStore;\n"]}
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonPropertyStore = void 0;
3
+ exports.PropertyMetadata = exports.JsonPropertyStore = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@tsed/core");
6
6
  const JsonEntityStore_1 = require("./JsonEntityStore");
7
7
  const JsonSchema_1 = require("./JsonSchema");
8
8
  const jsonEntityComponent_1 = require("../decorators/config/jsonEntityComponent");
9
9
  let JsonPropertyStore = class JsonPropertyStore extends JsonEntityStore_1.JsonEntityStore {
10
- constructor() {
11
- super(...arguments);
12
- this.parent = JsonEntityStore_1.JsonEntityStore.from(this.target);
13
- }
10
+ parent = JsonEntityStore_1.JsonEntityStore.from(this.target);
14
11
  /**
15
12
  * Return the required state.
16
13
  * @returns {boolean}
@@ -60,9 +57,13 @@ let JsonPropertyStore = class JsonPropertyStore extends JsonEntityStore_1.JsonEn
60
57
  this.parent.schema.addProperty(this.propertyName, schema);
61
58
  this._schema = schema;
62
59
  }
60
+ static get(target, propertyKey) {
61
+ return JsonEntityStore_1.JsonEntityStore.from((0, core_1.prototypeOf)(target), propertyKey);
62
+ }
63
63
  };
64
- JsonPropertyStore = (0, tslib_1.__decorate)([
64
+ JsonPropertyStore = tslib_1.__decorate([
65
65
  (0, jsonEntityComponent_1.JsonEntityComponent)(core_1.DecoratorTypes.PROP)
66
66
  ], JsonPropertyStore);
67
67
  exports.JsonPropertyStore = JsonPropertyStore;
68
+ exports.PropertyMetadata = JsonPropertyStore;
68
69
  //# sourceMappingURL=JsonPropertyStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";;;;AAAA,qCAAiE;AACjE,uDAAkD;AAClD,6CAAwC;AACxC,kFAA6E;AAI7E,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,iCAAe;IAAtD;;QACW,WAAM,GAAmB,iCAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IA8DtE,CAAC;IA5DC;;;OAG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AAI,CAAC,CAAC;YAElD,MAAM,GAAG,uBAAU,CAAC,IAAI,CAAC;gBACvB,IAAI,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI;aACvC,CAAC,CAAC;YAEH,IAAI,IAAI,CAAC,cAAc,EAAE;gBACvB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9B;SACF;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;CACF,CAAA;AA/DY,iBAAiB;IAD7B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,IAAI,CAAC;GAC5B,iBAAiB,CA+D7B;AA/DY,8CAAiB","sourcesContent":["import {DecoratorTypes, Metadata, prototypeOf} from \"@tsed/core\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\n\n@JsonEntityComponent(DecoratorTypes.PROP)\nexport class JsonPropertyStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return this.parent.schema.isRequired(this.propertyKey as string);\n }\n\n /**\n * Change the state of the required data.\n * @param value\n */\n set required(value: boolean) {\n if (value) {\n this.parent.schema.addRequired(this.propertyKey as string);\n } else {\n this.parent.schema.removeRequired(this.propertyKey as string);\n }\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected build() {\n if (!this._type) {\n this.buildType(Metadata.getType(prototypeOf(this.target), this.propertyKey));\n }\n\n this._type = this._type || Object;\n\n const properties = this.parent.schema.get(\"properties\");\n\n let schema: JsonSchema = properties[this.propertyName];\n\n if (!schema) {\n this.parent.children.set(this.propertyName, this);\n\n schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n schema.itemSchema(this.type);\n }\n }\n\n this.parent.schema.addProperty(this.propertyName, schema);\n\n this._schema = schema;\n }\n}\n"]}
1
+ {"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";;;;AAAA,qCAAuE;AACvE,uDAAkD;AAClD,6CAAwC;AACxC,kFAA6E;AAI7E,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,iCAAe;IAC3C,MAAM,GAAmB,iCAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpE;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC5D;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC/D;IACH,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,KAAU;QACnB,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,q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AAiB,CAmE7B;AAnEY,8CAAiB;AAyEjB,QAAA,gBAAgB,GAAG,iBAAiB,CAAC","sourcesContent":["import {DecoratorTypes, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\n\n@JsonEntityComponent(DecoratorTypes.PROP)\nexport class JsonPropertyStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return this.parent.schema.isRequired(this.propertyKey as string);\n }\n\n /**\n * Change the state of the required data.\n * @param value\n */\n set required(value: boolean) {\n if (value) {\n this.parent.schema.addRequired(this.propertyKey as string);\n } else {\n this.parent.schema.removeRequired(this.propertyKey as string);\n }\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected build() {\n if (!this._type) {\n this.buildType(Metadata.getType(prototypeOf(this.target), this.propertyKey));\n }\n\n this._type = this._type || Object;\n\n const properties = this.parent.schema.get(\"properties\");\n\n let schema: JsonSchema = properties[this.propertyName];\n\n if (!schema) {\n this.parent.children.set(this.propertyName, this);\n\n schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n schema.itemSchema(this.type);\n }\n }\n\n this.parent.schema.addProperty(this.propertyName, schema);\n\n this._schema = schema;\n }\n\n static get(target: Type<any>, propertyKey: string | symbol) {\n return JsonEntityStore.from<JsonPropertyStore>(prototypeOf(target), propertyKey);\n }\n}\n\n/**\n * @alias JsonPropertyStore\n */\nexport type PropertyMetadata = JsonPropertyStore;\nexport const PropertyMetadata = JsonPropertyStore;\n"]}
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsonResponse = exports.JsonMedia = void 0;
4
- const core_1 = require("@tsed/core");
5
4
  const mapHeaders_1 = require("../utils/mapHeaders");
6
5
  const toJsonMapCollection_1 = require("../utils/toJsonMapCollection");
7
6
  const JsonMap_1 = require("./JsonMap");
8
- const SpecTypes_1 = require("./SpecTypes");
9
7
  class JsonMedia extends JsonMap_1.JsonMap {
10
- constructor() {
11
- super(...arguments);
12
- this.groups = [];
13
- }
8
+ groups = [];
9
+ allowedGroups;
14
10
  schema(schema) {
15
11
  this.set("schema", schema);
16
12
  return this;
@@ -20,11 +16,13 @@ class JsonMedia extends JsonMap_1.JsonMap {
20
16
  return this;
21
17
  }
22
18
  toJSON(options = {}) {
23
- return super.toJSON({ ...options, groups: this.groups });
19
+ let groups = [...(this.groups || [])];
20
+ return super.toJSON({ ...options, groups });
24
21
  }
25
22
  }
26
23
  exports.JsonMedia = JsonMedia;
27
24
  class JsonResponse extends JsonMap_1.JsonMap {
25
+ status;
28
26
  constructor(obj = {}) {
29
27
  super(obj);
30
28
  this.content(obj.content || {});
@@ -45,9 +43,8 @@ class JsonResponse extends JsonMap_1.JsonMap {
45
43
  return this.get("content");
46
44
  }
47
45
  getMedia(mediaType, create = true) {
48
- var _a;
49
46
  create && this.addMedia(mediaType);
50
- return (_a = this.getContent()) === null || _a === void 0 ? void 0 : _a.get(mediaType);
47
+ return this.getContent()?.get(mediaType);
51
48
  }
52
49
  addMedia(mediaType) {
53
50
  const content = this.get("content");
@@ -61,7 +58,7 @@ class JsonResponse extends JsonMap_1.JsonMap {
61
58
  if (this.status === 204) {
62
59
  delete response.content;
63
60
  }
64
- if (options.specType === SpecTypes_1.SpecTypes.OPENAPI && response.headers) {
61
+ if (response.headers) {
65
62
  Object.entries(response.headers).forEach(([key, { type, ...props }]) => {
66
63
  response.headers[key] = {
67
64
  ...props,
@@ -71,14 +68,6 @@ class JsonResponse extends JsonMap_1.JsonMap {
71
68
  };
72
69
  });
73
70
  }
74
- if (options.specType !== SpecTypes_1.SpecTypes.OPENAPI && response.content) {
75
- const key = Object.keys(response.content)[0];
76
- return (0, core_1.cleanObject)({
77
- ...response,
78
- ...response.content[key],
79
- content: undefined
80
- });
81
- }
82
71
  return response;
83
72
  }
84
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAGvC,oDAA+C;AAC/C,sEAAiE;AACjE,uCAAkC;AAElC,2CAAsC;AAItC,MAAa,SAAU,SAAQ,iBAAiC;IAAhE;;QACE,WAAM,GAAa,EAAE,CAAC;IAiBxB,CAAC;IAfC,MAAM,CAAC,MAAkB;QACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAa;QACpB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,OAAO,KAAK,CAAC,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAlBD,8BAkBC;AAED,MAAa,YAAa,SAAQ,iBAA4B;IAG5D,YAAY,MAAoC,EAAE;QAChD,KAAK,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAK,EAAU,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,WAAmB;QAC7B,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,OA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,KAAK,EAAC,CAAgB,EAAE,EAAE;gBAClF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG;oBACtB,GAAG,KAAK;oBACR,MAAM,EAAE;wBACN,IAAI;qBACL;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,IAAI,OAAO,CAAC,QAAQ,KAAK,qBAAS,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE;YAC9D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAE7C,OAAO,IAAA,kBAAW,EAAC;gBACjB,GAAG,QAAQ;gBACX,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC;gBACxB,OAAO,EAAE,SAAS;aACnB,CAAC,CAAC;SACJ;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA7ED,oCA6EC","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport {OS3MediaType, OS3Response} from \"@tsed/openspec\";\nimport {JsonHeader, JsonSchemaOptions} from \"../interfaces\";\nimport {mapHeaders} from \"../utils/mapHeaders\";\nimport {toJsonMapCollection} from \"../utils/toJsonMapCollection\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {SpecTypes} from \"./SpecTypes\";\n\nexport type JsonResponseOptions = OS3Response<JsonSchema, string | JsonHeader>;\n\nexport class JsonMedia extends JsonMap<OS3MediaType<JsonSchema>> {\n groups: string[] = [];\n\n schema(schema: JsonSchema) {\n this.set(\"schema\", schema);\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", examples);\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n return super.toJSON({...options, groups: this.groups});\n }\n}\n\nexport class JsonResponse extends JsonMap<JsonResponseOptions> {\n status: number;\n\n constructor(obj: Partial<JsonResponseOptions> = {}) {\n super(obj);\n\n this.content(obj.content || ({} as any));\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n headers(headers: Record<string, string | JsonHeader>): this {\n this.set(\"headers\", mapHeaders(headers));\n\n return this;\n }\n\n content(content: Record<string, OS3MediaType<JsonSchema>>) {\n this.set(\"content\", toJsonMapCollection(content, JsonMedia));\n\n return this;\n }\n\n getContent(): JsonMap<JsonMedia> {\n return this.get(\"content\")!;\n }\n\n getMedia(mediaType: string, create = true): JsonMedia {\n create && this.addMedia(mediaType);\n\n return this.getContent()?.get(mediaType) as any;\n }\n\n addMedia(mediaType: string) {\n const content = this.get(\"content\");\n\n if (!content.has(mediaType)) {\n content.set(mediaType, new JsonMedia());\n }\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const response = super.toJSON(options);\n\n if (this.status === 204) {\n delete response.content;\n }\n\n if (options.specType === SpecTypes.OPENAPI && response.headers) {\n Object.entries(response.headers).forEach(([key, {type, ...props}]: [string, any]) => {\n response.headers[key] = {\n ...props,\n schema: {\n type\n }\n };\n });\n }\n\n if (options.specType !== SpecTypes.OPENAPI && response.content) {\n const key = Object.keys(response.content)[0];\n\n return cleanObject({\n ...response,\n ...response.content[key],\n content: undefined\n });\n }\n\n return response;\n }\n}\n"]}
1
+ {"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":";;;AAGA,oDAA+C;AAC/C,sEAAiE;AACjE,uCAAkC;AAKlC,MAAa,SAAU,SAAQ,iBAAiC;IAC9D,MAAM,GAAa,EAAE,CAAC;IACtB,aAAa,CAAe;IAE5B,MAAM,CAAC,MAAkB;QACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAa;QACpB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,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AO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;SACzC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE;YACvB,OAAO,QAAQ,CAAC,OAAO,CAAC;SACzB;QAED,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,CAAgB,EAAE,EAAE;gBAClF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG;oBACtB,GAAG,KAAK;oBACR,MAAM,EAAE;wBACN,IAAI;qBACL;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAnED,oCAmEC","sourcesContent":["import {OS3MediaType, OS3Response} from \"@tsed/openspec\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {mapHeaders} from \"../utils/mapHeaders\";\nimport {toJsonMapCollection} from \"../utils/toJsonMapCollection\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonSchema} from \"./JsonSchema\";\n\nexport type JsonResponseOptions = OS3Response<JsonSchema, string | JsonHeader>;\n\nexport class JsonMedia extends JsonMap<OS3MediaType<JsonSchema>> {\n groups: string[] = [];\n allowedGroups?: Set<string>;\n\n schema(schema: JsonSchema) {\n this.set(\"schema\", schema);\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", examples);\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n let groups = [...(this.groups || [])];\n\n return super.toJSON({...options, groups});\n }\n}\n\nexport class JsonResponse extends JsonMap<JsonResponseOptions> {\n status: number;\n\n constructor(obj: Partial<JsonResponseOptions> = {}) {\n super(obj);\n\n this.content(obj.content || ({} as any));\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n headers(headers: Record<string, string | JsonHeader>): this {\n this.set(\"headers\", mapHeaders(headers));\n\n return this;\n }\n\n content(content: Record<string, OS3MediaType<JsonSchema>>) {\n this.set(\"content\", toJsonMapCollection(content, JsonMedia));\n\n return this;\n }\n\n getContent(): JsonMap<JsonMedia> {\n return this.get(\"content\")!;\n }\n\n getMedia(mediaType: string, create = true): JsonMedia {\n create && this.addMedia(mediaType);\n\n return this.getContent()?.get(mediaType) as any;\n }\n\n addMedia(mediaType: string) {\n const content = this.get(\"content\");\n\n if (!content.has(mediaType)) {\n content.set(mediaType, new JsonMedia());\n }\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const response = super.toJSON(options);\n\n if (this.status === 204) {\n delete response.content;\n }\n\n if (response.headers) {\n Object.entries(response.headers).forEach(([key, {type, ...props}]: [string, any]) => {\n response.headers[key] = {\n ...props,\n schema: {\n type\n }\n };\n });\n }\n\n return response;\n }\n}\n"]}