@tsed/schema 7.86.2 → 7.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/lib/browser/schema.umd.min.js +1 -1
  2. package/lib/browser/schema.umd.min.js.map +1 -1
  3. package/lib/cjs/components/default/anyMapper.js +1 -2
  4. package/lib/cjs/components/default/anyMapper.js.map +1 -1
  5. package/lib/cjs/components/default/classMapper.js +2 -22
  6. package/lib/cjs/components/default/classMapper.js.map +1 -1
  7. package/lib/cjs/components/default/discriminatorMappingMapper.js.map +1 -1
  8. package/lib/cjs/components/default/genericsMapper.js +61 -47
  9. package/lib/cjs/components/default/genericsMapper.js.map +1 -1
  10. package/lib/cjs/components/default/inheritedClassMapper.js.map +1 -1
  11. package/lib/cjs/components/default/lazyRefMapper.js +1 -2
  12. package/lib/cjs/components/default/lazyRefMapper.js.map +1 -1
  13. package/lib/cjs/components/default/mapMapper.js +0 -2
  14. package/lib/cjs/components/default/mapMapper.js.map +1 -1
  15. package/lib/cjs/components/default/nextMapper.js +80 -0
  16. package/lib/cjs/components/default/nextMapper.js.map +1 -0
  17. package/lib/cjs/components/default/nullableMapper.js.map +1 -1
  18. package/lib/cjs/components/default/objectMapper.js +8 -3
  19. package/lib/cjs/components/default/objectMapper.js.map +1 -1
  20. package/lib/cjs/components/default/ofMapper.js +2 -5
  21. package/lib/cjs/components/default/ofMapper.js.map +1 -1
  22. package/lib/cjs/components/default/requiredMapper.js +2 -2
  23. package/lib/cjs/components/default/requiredMapper.js.map +1 -1
  24. package/lib/cjs/components/default/schemaMapper.js +6 -7
  25. package/lib/cjs/components/default/schemaMapper.js.map +1 -1
  26. package/lib/cjs/components/index.js +1 -7
  27. package/lib/cjs/components/index.js.map +1 -1
  28. package/lib/cjs/components/open-spec/enumsMapper.js.map +1 -1
  29. package/lib/cjs/components/open-spec/generate.js.map +1 -1
  30. package/lib/cjs/components/open-spec/nullableMapper.js +5 -1
  31. package/lib/cjs/components/open-spec/nullableMapper.js.map +1 -1
  32. package/lib/cjs/components/open-spec/operationInFilesMapper.js.map +1 -1
  33. package/lib/cjs/components/open-spec/operationInParameterMapper.js +3 -7
  34. package/lib/cjs/components/open-spec/operationInParameterMapper.js.map +1 -1
  35. package/lib/cjs/components/open-spec/operationInQueryMapper.js +21 -16
  36. package/lib/cjs/components/open-spec/operationInQueryMapper.js.map +1 -1
  37. package/lib/cjs/components/open-spec/operationMediaMapper.js +5 -2
  38. package/lib/cjs/components/open-spec/operationMediaMapper.js.map +1 -1
  39. package/lib/cjs/components/open-spec/operationRequestBodyMapper.js +4 -3
  40. package/lib/cjs/components/open-spec/operationRequestBodyMapper.js.map +1 -1
  41. package/lib/cjs/components/open-spec/pathsMapper.js +1 -0
  42. package/lib/cjs/components/open-spec/pathsMapper.js.map +1 -1
  43. package/lib/cjs/constants/VendorKeys.js +15 -0
  44. package/lib/cjs/constants/VendorKeys.js.map +1 -0
  45. package/lib/cjs/constants/httpStatusMessages.js +1 -1
  46. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  47. package/lib/cjs/decorators/class/children.js.map +1 -1
  48. package/lib/cjs/decorators/collections/collectionOf.js +29 -0
  49. package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
  50. package/lib/cjs/decorators/common/allow.js.map +1 -1
  51. package/lib/cjs/decorators/common/any.js.map +1 -1
  52. package/lib/cjs/decorators/common/defaultMsg.js.map +1 -1
  53. package/lib/cjs/decorators/common/description.js +8 -11
  54. package/lib/cjs/decorators/common/description.js.map +1 -1
  55. package/lib/cjs/decorators/common/discriminatorKey.js +1 -1
  56. package/lib/cjs/decorators/common/discriminatorKey.js.map +1 -1
  57. package/lib/cjs/decorators/common/enum.js.map +1 -1
  58. package/lib/cjs/decorators/common/examples.js.map +1 -1
  59. package/lib/cjs/decorators/common/format.js.map +1 -1
  60. package/lib/cjs/decorators/common/forwardGroups.js +1 -1
  61. package/lib/cjs/decorators/common/forwardGroups.js.map +1 -1
  62. package/lib/cjs/decorators/common/groups.js +15 -26
  63. package/lib/cjs/decorators/common/groups.js.map +1 -1
  64. package/lib/cjs/decorators/common/integer.js.map +1 -1
  65. package/lib/cjs/decorators/common/oneOf.js +1 -2
  66. package/lib/cjs/decorators/common/oneOf.js.map +1 -1
  67. package/lib/cjs/decorators/common/optional.js.map +1 -1
  68. package/lib/cjs/decorators/config/jsonEntityComponent.js.map +1 -1
  69. package/lib/cjs/decorators/generics/genericOf.js +7 -16
  70. package/lib/cjs/decorators/generics/genericOf.js.map +1 -1
  71. package/lib/cjs/decorators/generics/generics.js +3 -3
  72. package/lib/cjs/decorators/generics/generics.js.map +1 -1
  73. package/lib/cjs/decorators/operations/acceptMime.js.map +1 -1
  74. package/lib/cjs/decorators/operations/consumes.js.map +1 -1
  75. package/lib/cjs/decorators/operations/deprecated.js.map +1 -1
  76. package/lib/cjs/decorators/operations/header.js.map +1 -1
  77. package/lib/cjs/decorators/operations/in.js.map +1 -1
  78. package/lib/cjs/decorators/operations/inFile.js +2 -2
  79. package/lib/cjs/decorators/operations/inFile.js.map +1 -1
  80. package/lib/cjs/decorators/operations/operation.js +5 -1
  81. package/lib/cjs/decorators/operations/operation.js.map +1 -1
  82. package/lib/cjs/decorators/operations/operationId.js.map +1 -1
  83. package/lib/cjs/decorators/operations/operationPath.js +1 -1
  84. package/lib/cjs/decorators/operations/operationPath.js.map +1 -1
  85. package/lib/cjs/decorators/operations/path.js.map +1 -1
  86. package/lib/cjs/decorators/operations/produces.js.map +1 -1
  87. package/lib/cjs/decorators/operations/redirect.js +1 -1
  88. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  89. package/lib/cjs/decorators/operations/returns.js +39 -62
  90. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  91. package/lib/cjs/decorators/operations/security.js.map +1 -1
  92. package/lib/cjs/decorators/operations/status.js.map +1 -1
  93. package/lib/cjs/decorators/operations/summary.js.map +1 -1
  94. package/lib/cjs/decorators/operations/tags.js +10 -1
  95. package/lib/cjs/decorators/operations/tags.js.map +1 -1
  96. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  97. package/lib/cjs/domain/JsonClassStore.js +1 -1
  98. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  99. package/lib/cjs/domain/JsonEntityStore.js +40 -35
  100. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  101. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  102. package/lib/cjs/domain/JsonMap.js.map +1 -1
  103. package/lib/cjs/domain/JsonMedia.js +27 -6
  104. package/lib/cjs/domain/JsonMedia.js.map +1 -1
  105. package/lib/cjs/domain/JsonMethodStore.js +27 -8
  106. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  107. package/lib/cjs/domain/JsonOperation.js +36 -8
  108. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  109. package/lib/cjs/domain/JsonParameter.js +20 -5
  110. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  111. package/lib/cjs/domain/JsonParameterStore.js +15 -25
  112. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  113. package/lib/cjs/domain/JsonPropertyStore.js +14 -45
  114. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  115. package/lib/cjs/domain/JsonSchema.js +286 -79
  116. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  117. package/lib/cjs/domain/__fixtures__/inspectOperationsPaths.js +11 -0
  118. package/lib/cjs/domain/__fixtures__/inspectOperationsPaths.js.map +1 -0
  119. package/lib/cjs/fn/email.js +2 -2
  120. package/lib/cjs/fn/email.js.map +1 -1
  121. package/lib/cjs/fn/uri.js +2 -2
  122. package/lib/cjs/fn/uri.js.map +1 -1
  123. package/lib/cjs/fn/url.js +2 -2
  124. package/lib/cjs/fn/url.js.map +1 -1
  125. package/lib/cjs/index.js +4 -8
  126. package/lib/cjs/index.js.map +1 -1
  127. package/lib/cjs/utils/generics.js +5 -36
  128. package/lib/cjs/utils/generics.js.map +1 -1
  129. package/lib/cjs/utils/getJsonEntityStore.js +3 -3
  130. package/lib/cjs/utils/getJsonEntityStore.js.map +1 -1
  131. package/lib/cjs/utils/getJsonSchema.js +24 -17
  132. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  133. package/lib/cjs/utils/getOperationsStores.js.map +1 -1
  134. package/lib/cjs/utils/getPropertiesStores.js.map +1 -1
  135. package/lib/cjs/utils/getSpec.js.map +1 -1
  136. package/lib/cjs/utils/mergeSchema.js +103 -0
  137. package/lib/cjs/utils/mergeSchema.js.map +1 -0
  138. package/lib/cjs/utils/ref.js +15 -13
  139. package/lib/cjs/utils/ref.js.map +1 -1
  140. package/lib/esm/components/default/anyMapper.js +1 -2
  141. package/lib/esm/components/default/anyMapper.js.map +1 -1
  142. package/lib/esm/components/default/classMapper.js +2 -22
  143. package/lib/esm/components/default/classMapper.js.map +1 -1
  144. package/lib/esm/components/default/discriminatorMappingMapper.js.map +1 -1
  145. package/lib/esm/components/default/genericsMapper.js +62 -48
  146. package/lib/esm/components/default/genericsMapper.js.map +1 -1
  147. package/lib/esm/components/default/inheritedClassMapper.js.map +1 -1
  148. package/lib/esm/components/default/lazyRefMapper.js +1 -2
  149. package/lib/esm/components/default/lazyRefMapper.js.map +1 -1
  150. package/lib/esm/components/default/mapMapper.js +0 -2
  151. package/lib/esm/components/default/mapMapper.js.map +1 -1
  152. package/lib/esm/components/default/nextMapper.js +75 -0
  153. package/lib/esm/components/default/nextMapper.js.map +1 -0
  154. package/lib/esm/components/default/nullableMapper.js.map +1 -1
  155. package/lib/esm/components/default/objectMapper.js +8 -3
  156. package/lib/esm/components/default/objectMapper.js.map +1 -1
  157. package/lib/esm/components/default/ofMapper.js +2 -5
  158. package/lib/esm/components/default/ofMapper.js.map +1 -1
  159. package/lib/esm/components/default/requiredMapper.js +2 -2
  160. package/lib/esm/components/default/requiredMapper.js.map +1 -1
  161. package/lib/esm/components/default/schemaMapper.js +7 -8
  162. package/lib/esm/components/default/schemaMapper.js.map +1 -1
  163. package/lib/esm/components/index.js +1 -7
  164. package/lib/esm/components/index.js.map +1 -1
  165. package/lib/esm/components/open-spec/enumsMapper.js.map +1 -1
  166. package/lib/esm/components/open-spec/generate.js.map +1 -1
  167. package/lib/esm/components/open-spec/nullableMapper.js +5 -1
  168. package/lib/esm/components/open-spec/nullableMapper.js.map +1 -1
  169. package/lib/esm/components/open-spec/operationInFilesMapper.js.map +1 -1
  170. package/lib/esm/components/open-spec/operationInParameterMapper.js +3 -7
  171. package/lib/esm/components/open-spec/operationInParameterMapper.js.map +1 -1
  172. package/lib/esm/components/open-spec/operationInQueryMapper.js +22 -17
  173. package/lib/esm/components/open-spec/operationInQueryMapper.js.map +1 -1
  174. package/lib/esm/components/open-spec/operationMediaMapper.js +5 -2
  175. package/lib/esm/components/open-spec/operationMediaMapper.js.map +1 -1
  176. package/lib/esm/components/open-spec/operationRequestBodyMapper.js +4 -3
  177. package/lib/esm/components/open-spec/operationRequestBodyMapper.js.map +1 -1
  178. package/lib/esm/components/open-spec/pathsMapper.js +1 -0
  179. package/lib/esm/components/open-spec/pathsMapper.js.map +1 -1
  180. package/lib/esm/constants/VendorKeys.js +12 -0
  181. package/lib/esm/constants/VendorKeys.js.map +1 -0
  182. package/lib/esm/constants/httpStatusMessages.js +1 -1
  183. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  184. package/lib/esm/decorators/class/children.js.map +1 -1
  185. package/lib/esm/decorators/collections/collectionOf.js +29 -0
  186. package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
  187. package/lib/esm/decorators/common/allow.js.map +1 -1
  188. package/lib/esm/decorators/common/any.js.map +1 -1
  189. package/lib/esm/decorators/common/defaultMsg.js.map +1 -1
  190. package/lib/esm/decorators/common/description.js +9 -12
  191. package/lib/esm/decorators/common/description.js.map +1 -1
  192. package/lib/esm/decorators/common/discriminatorKey.js +1 -1
  193. package/lib/esm/decorators/common/discriminatorKey.js.map +1 -1
  194. package/lib/esm/decorators/common/enum.js.map +1 -1
  195. package/lib/esm/decorators/common/examples.js.map +1 -1
  196. package/lib/esm/decorators/common/format.js.map +1 -1
  197. package/lib/esm/decorators/common/forwardGroups.js +1 -1
  198. package/lib/esm/decorators/common/forwardGroups.js.map +1 -1
  199. package/lib/esm/decorators/common/groups.js +15 -26
  200. package/lib/esm/decorators/common/groups.js.map +1 -1
  201. package/lib/esm/decorators/common/integer.js.map +1 -1
  202. package/lib/esm/decorators/common/oneOf.js +1 -2
  203. package/lib/esm/decorators/common/oneOf.js.map +1 -1
  204. package/lib/esm/decorators/common/optional.js.map +1 -1
  205. package/lib/esm/decorators/config/jsonEntityComponent.js.map +1 -1
  206. package/lib/esm/decorators/generics/genericOf.js +8 -17
  207. package/lib/esm/decorators/generics/genericOf.js.map +1 -1
  208. package/lib/esm/decorators/generics/generics.js +3 -3
  209. package/lib/esm/decorators/generics/generics.js.map +1 -1
  210. package/lib/esm/decorators/operations/acceptMime.js.map +1 -1
  211. package/lib/esm/decorators/operations/consumes.js.map +1 -1
  212. package/lib/esm/decorators/operations/deprecated.js.map +1 -1
  213. package/lib/esm/decorators/operations/header.js.map +1 -1
  214. package/lib/esm/decorators/operations/in.js.map +1 -1
  215. package/lib/esm/decorators/operations/inFile.js +2 -2
  216. package/lib/esm/decorators/operations/inFile.js.map +1 -1
  217. package/lib/esm/decorators/operations/operation.js +5 -1
  218. package/lib/esm/decorators/operations/operation.js.map +1 -1
  219. package/lib/esm/decorators/operations/operationId.js.map +1 -1
  220. package/lib/esm/decorators/operations/operationPath.js +1 -1
  221. package/lib/esm/decorators/operations/operationPath.js.map +1 -1
  222. package/lib/esm/decorators/operations/path.js.map +1 -1
  223. package/lib/esm/decorators/operations/produces.js.map +1 -1
  224. package/lib/esm/decorators/operations/redirect.js +1 -1
  225. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  226. package/lib/esm/decorators/operations/returns.js +40 -63
  227. package/lib/esm/decorators/operations/returns.js.map +1 -1
  228. package/lib/esm/decorators/operations/security.js.map +1 -1
  229. package/lib/esm/decorators/operations/status.js.map +1 -1
  230. package/lib/esm/decorators/operations/summary.js.map +1 -1
  231. package/lib/esm/decorators/operations/tags.js +10 -1
  232. package/lib/esm/decorators/operations/tags.js.map +1 -1
  233. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  234. package/lib/esm/domain/JsonClassStore.js +1 -1
  235. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  236. package/lib/esm/domain/JsonEntityStore.js +40 -35
  237. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  238. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  239. package/lib/esm/domain/JsonMap.js.map +1 -1
  240. package/lib/esm/domain/JsonMedia.js +27 -6
  241. package/lib/esm/domain/JsonMedia.js.map +1 -1
  242. package/lib/esm/domain/JsonMethodStore.js +28 -9
  243. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  244. package/lib/esm/domain/JsonOperation.js +34 -7
  245. package/lib/esm/domain/JsonOperation.js.map +1 -1
  246. package/lib/esm/domain/JsonParameter.js +20 -5
  247. package/lib/esm/domain/JsonParameter.js.map +1 -1
  248. package/lib/esm/domain/JsonParameterStore.js +16 -26
  249. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  250. package/lib/esm/domain/JsonPropertyStore.js +15 -46
  251. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  252. package/lib/esm/domain/JsonSchema.js +287 -80
  253. package/lib/esm/domain/JsonSchema.js.map +1 -1
  254. package/lib/esm/domain/__fixtures__/inspectOperationsPaths.js +7 -0
  255. package/lib/esm/domain/__fixtures__/inspectOperationsPaths.js.map +1 -0
  256. package/lib/esm/fn/email.js +2 -2
  257. package/lib/esm/fn/email.js.map +1 -1
  258. package/lib/esm/fn/uri.js +2 -2
  259. package/lib/esm/fn/uri.js.map +1 -1
  260. package/lib/esm/fn/url.js +2 -2
  261. package/lib/esm/fn/url.js.map +1 -1
  262. package/lib/esm/index.js +4 -8
  263. package/lib/esm/index.js.map +1 -1
  264. package/lib/esm/utils/generics.js +3 -32
  265. package/lib/esm/utils/generics.js.map +1 -1
  266. package/lib/esm/utils/getJsonEntityStore.js +3 -3
  267. package/lib/esm/utils/getJsonEntityStore.js.map +1 -1
  268. package/lib/esm/utils/getJsonSchema.js +24 -17
  269. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  270. package/lib/esm/utils/getOperationsStores.js.map +1 -1
  271. package/lib/esm/utils/getPropertiesStores.js.map +1 -1
  272. package/lib/esm/utils/getSpec.js.map +1 -1
  273. package/lib/esm/utils/mergeSchema.js +99 -0
  274. package/lib/esm/utils/mergeSchema.js.map +1 -0
  275. package/lib/esm/utils/ref.js +14 -13
  276. package/lib/esm/utils/ref.js.map +1 -1
  277. package/lib/types/components/default/classMapper.d.ts +1 -1
  278. package/lib/types/components/default/genericsMapper.d.ts +9 -2
  279. package/lib/types/components/default/lazyRefMapper.d.ts +1 -1
  280. package/lib/types/components/default/nextMapper.d.ts +5 -0
  281. package/lib/types/components/default/ofMapper.d.ts +1 -1
  282. package/lib/types/components/index.d.ts +1 -7
  283. package/lib/types/components/open-spec/nullableMapper.d.ts +2 -1
  284. package/lib/types/components/open-spec/operationInQueryMapper.d.ts +1 -1
  285. package/lib/types/constants/VendorKeys.d.ts +10 -0
  286. package/lib/types/decorators/collections/collectionOf.d.ts +6 -0
  287. package/lib/types/decorators/generics/genericOf.d.ts +3 -0
  288. package/lib/types/decorators/generics/generics.d.ts +2 -2
  289. package/lib/types/decorators/operations/acceptMime.d.ts +1 -1
  290. package/lib/types/decorators/operations/consumes.d.ts +1 -1
  291. package/lib/types/decorators/operations/header.d.ts +1 -1
  292. package/lib/types/decorators/operations/operationId.d.ts +1 -1
  293. package/lib/types/decorators/operations/operationPath.d.ts +1 -1
  294. package/lib/types/decorators/operations/path.d.ts +1 -1
  295. package/lib/types/decorators/operations/returns.d.ts +11 -9
  296. package/lib/types/decorators/operations/tags.d.ts +11 -2
  297. package/lib/types/domain/JsonClassStore.d.ts +1 -1
  298. package/lib/types/domain/JsonEntityStore.d.ts +20 -16
  299. package/lib/types/domain/JsonMedia.d.ts +4 -5
  300. package/lib/types/domain/JsonMethodStore.d.ts +9 -2
  301. package/lib/types/domain/JsonOperation.d.ts +7 -4
  302. package/lib/types/domain/JsonParameter.d.ts +4 -7
  303. package/lib/types/domain/JsonParameterStore.d.ts +1 -4
  304. package/lib/types/domain/JsonPropertyStore.d.ts +2 -21
  305. package/lib/types/domain/JsonSchema.d.ts +83 -40
  306. package/lib/types/domain/__fixtures__/inspectOperationsPaths.d.ts +5 -0
  307. package/lib/types/index.d.ts +4 -8
  308. package/lib/types/interfaces/JsonSchemaOptions.d.ts +16 -2
  309. package/lib/types/utils/generics.d.ts +7 -48
  310. package/lib/types/utils/getJsonEntityStore.d.ts +3 -3
  311. package/lib/types/utils/getJsonSchema.d.ts +3 -2
  312. package/lib/types/utils/mergeSchema.d.ts +2 -0
  313. package/lib/types/utils/ref.d.ts +4 -2
  314. package/lib/types-esm/components/default/classMapper.d.ts +1 -1
  315. package/lib/types-esm/components/default/genericsMapper.d.ts +9 -2
  316. package/lib/types-esm/components/default/lazyRefMapper.d.ts +1 -1
  317. package/lib/types-esm/components/default/nextMapper.d.ts +5 -0
  318. package/lib/types-esm/components/default/ofMapper.d.ts +1 -1
  319. package/lib/types-esm/components/index.d.ts +1 -7
  320. package/lib/types-esm/components/open-spec/nullableMapper.d.ts +2 -1
  321. package/lib/types-esm/components/open-spec/operationInQueryMapper.d.ts +1 -1
  322. package/lib/types-esm/constants/VendorKeys.d.ts +10 -0
  323. package/lib/types-esm/decorators/collections/collectionOf.d.ts +6 -0
  324. package/lib/types-esm/decorators/generics/genericOf.d.ts +3 -0
  325. package/lib/types-esm/decorators/generics/generics.d.ts +2 -2
  326. package/lib/types-esm/decorators/operations/acceptMime.d.ts +1 -1
  327. package/lib/types-esm/decorators/operations/consumes.d.ts +1 -1
  328. package/lib/types-esm/decorators/operations/header.d.ts +1 -1
  329. package/lib/types-esm/decorators/operations/operationId.d.ts +1 -1
  330. package/lib/types-esm/decorators/operations/operationPath.d.ts +1 -1
  331. package/lib/types-esm/decorators/operations/path.d.ts +1 -1
  332. package/lib/types-esm/decorators/operations/returns.d.ts +11 -9
  333. package/lib/types-esm/decorators/operations/tags.d.ts +11 -2
  334. package/lib/types-esm/domain/JsonClassStore.d.ts +1 -1
  335. package/lib/types-esm/domain/JsonEntityStore.d.ts +20 -16
  336. package/lib/types-esm/domain/JsonMedia.d.ts +4 -5
  337. package/lib/types-esm/domain/JsonMethodStore.d.ts +9 -2
  338. package/lib/types-esm/domain/JsonOperation.d.ts +7 -4
  339. package/lib/types-esm/domain/JsonParameter.d.ts +4 -7
  340. package/lib/types-esm/domain/JsonParameterStore.d.ts +1 -4
  341. package/lib/types-esm/domain/JsonPropertyStore.d.ts +2 -21
  342. package/lib/types-esm/domain/JsonSchema.d.ts +83 -40
  343. package/lib/types-esm/domain/__fixtures__/inspectOperationsPaths.d.ts +5 -0
  344. package/lib/types-esm/index.d.ts +4 -8
  345. package/lib/types-esm/interfaces/JsonSchemaOptions.d.ts +16 -2
  346. package/lib/types-esm/utils/generics.d.ts +7 -48
  347. package/lib/types-esm/utils/getJsonEntityStore.d.ts +3 -3
  348. package/lib/types-esm/utils/getJsonSchema.d.ts +3 -2
  349. package/lib/types-esm/utils/mergeSchema.d.ts +2 -0
  350. package/lib/types-esm/utils/ref.d.ts +4 -2
  351. package/package.json +6 -6
  352. package/lib/cjs/components/async-api/channelsMapper.js +0 -62
  353. package/lib/cjs/components/async-api/channelsMapper.js.map +0 -1
  354. package/lib/cjs/components/async-api/generate.js +0 -20
  355. package/lib/cjs/components/async-api/generate.js.map +0 -1
  356. package/lib/cjs/components/async-api/messageMapper.js +0 -44
  357. package/lib/cjs/components/async-api/messageMapper.js.map +0 -1
  358. package/lib/cjs/components/async-api/payloadMapper.js +0 -52
  359. package/lib/cjs/components/async-api/payloadMapper.js.map +0 -1
  360. package/lib/cjs/components/async-api/responseMapper.js +0 -58
  361. package/lib/cjs/components/async-api/responseMapper.js.map +0 -1
  362. package/lib/cjs/components/default/itemMapper.js +0 -10
  363. package/lib/cjs/components/default/itemMapper.js.map +0 -1
  364. package/lib/cjs/components/default/propertiesMapper.js +0 -25
  365. package/lib/cjs/components/default/propertiesMapper.js.map +0 -1
  366. package/lib/cjs/utils/somethingOf.js +0 -16
  367. package/lib/cjs/utils/somethingOf.js.map +0 -1
  368. package/lib/esm/components/async-api/channelsMapper.js +0 -58
  369. package/lib/esm/components/async-api/channelsMapper.js.map +0 -1
  370. package/lib/esm/components/async-api/generate.js +0 -18
  371. package/lib/esm/components/async-api/generate.js.map +0 -1
  372. package/lib/esm/components/async-api/messageMapper.js +0 -40
  373. package/lib/esm/components/async-api/messageMapper.js.map +0 -1
  374. package/lib/esm/components/async-api/payloadMapper.js +0 -48
  375. package/lib/esm/components/async-api/payloadMapper.js.map +0 -1
  376. package/lib/esm/components/async-api/responseMapper.js +0 -54
  377. package/lib/esm/components/async-api/responseMapper.js.map +0 -1
  378. package/lib/esm/components/default/itemMapper.js +0 -6
  379. package/lib/esm/components/default/itemMapper.js.map +0 -1
  380. package/lib/esm/components/default/propertiesMapper.js +0 -21
  381. package/lib/esm/components/default/propertiesMapper.js.map +0 -1
  382. package/lib/esm/utils/somethingOf.js +0 -12
  383. package/lib/esm/utils/somethingOf.js.map +0 -1
  384. package/lib/types/components/async-api/channelsMapper.d.ts +0 -2
  385. package/lib/types/components/async-api/generate.d.ts +0 -1
  386. package/lib/types/components/async-api/messageMapper.d.ts +0 -6
  387. package/lib/types/components/async-api/payloadMapper.d.ts +0 -4
  388. package/lib/types/components/async-api/responseMapper.d.ts +0 -6
  389. package/lib/types/components/default/itemMapper.d.ts +0 -2
  390. package/lib/types/components/default/propertiesMapper.d.ts +0 -3
  391. package/lib/types/utils/somethingOf.d.ts +0 -1
  392. package/lib/types-esm/components/async-api/channelsMapper.d.ts +0 -2
  393. package/lib/types-esm/components/async-api/generate.d.ts +0 -1
  394. package/lib/types-esm/components/async-api/messageMapper.d.ts +0 -6
  395. package/lib/types-esm/components/async-api/payloadMapper.d.ts +0 -4
  396. package/lib/types-esm/components/async-api/responseMapper.d.ts +0 -6
  397. package/lib/types-esm/components/default/itemMapper.d.ts +0 -2
  398. package/lib/types-esm/components/default/propertiesMapper.d.ts +0 -3
  399. package/lib/types-esm/utils/somethingOf.d.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,mBAAmB,EAAC,MAAM,6CAA6C,CAAC;AAIzE,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,eAAe;IAA/C;;QACI,WAAM,GAAmB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IA4EtE,CAAC;IA1EC;;;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,gBAAgB;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAA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,GAAG,iBAAiB,CAAC"}
@@ -1,8 +1,10 @@
1
- import { ancestorsOf, classOf, Hooks, isArray, isClass, isFunction, isObject, isPrimitiveClass, nameOf, uniq } from "@tsed/core";
1
+ import { ancestorOf, ancestorsOf, classOf, isArray, isClass, isFunction, isObject, isPlainObject, isPrimitiveClass, nameOf, uniq, Hooks } from "@tsed/core";
2
+ import { VendorKeys } from "../constants/VendorKeys.js";
2
3
  import { enumsRegistry } from "../registries/enumRegistries.js";
3
4
  import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
4
5
  import { getComputedType } from "../utils/getComputedType.js";
5
6
  import { getJsonType } from "../utils/getJsonType.js";
7
+ import { matchGroups } from "../utils/matchGroups.js";
6
8
  import { serializeEnumValues } from "../utils/serializeEnumValues.js";
7
9
  import { toJsonRegex } from "../utils/toJsonRegex.js";
8
10
  import { Discriminator } from "./JsonDiscriminator.js";
@@ -14,6 +16,9 @@ function mapProperties(properties) {
14
16
  }
15
17
  return Object.entries(properties).reduce((properties, [key, schema]) => {
16
18
  properties[toJsonRegex(key)] = mapToJsonSchema(schema);
19
+ if (schema instanceof JsonSchema) {
20
+ schema.propertyKey(toJsonRegex(key));
21
+ }
17
22
  return properties;
18
23
  }, {});
19
24
  }
@@ -35,35 +40,83 @@ function mapToJsonSchema(item) {
35
40
  }
36
41
  return item;
37
42
  }
43
+ function isEnum(type) {
44
+ return isObject(type) && !("toJSON" in type);
45
+ }
46
+ function mapGenerics(jsonSchema, generics) {
47
+ const genericLabels = jsonSchema.getGenericLabels();
48
+ if (!genericLabels) {
49
+ return {};
50
+ }
51
+ const [types, ...nextTypes] = generics;
52
+ return types.reduce((mapping, type, index) => {
53
+ const label = genericLabels[index];
54
+ if (label) {
55
+ if (isEnum(type)) {
56
+ mapping[label] = [JsonSchema.from({ type: "string", enum: Object.values(type) })];
57
+ }
58
+ else if (nextTypes.length) {
59
+ const nextSchema = mapToJsonSchema(type);
60
+ mapping[label] = [nextSchema, mapGenerics(nextSchema, nextTypes)];
61
+ }
62
+ else {
63
+ mapping[label] = [mapToJsonSchema(type)];
64
+ }
65
+ }
66
+ return mapping;
67
+ }, {});
68
+ }
38
69
  export class JsonSchema extends Map {
39
- #nullable;
70
+ /**
71
+ * All required fields are stored here
72
+ * @private
73
+ */
74
+ #required;
75
+ /**
76
+ * Internal custom props
77
+ * @private
78
+ */
79
+ #vendors;
40
80
  #discriminator;
41
- #genericLabels;
42
- #nestedGenerics;
43
81
  #alias;
44
82
  #itemSchema;
83
+ /**
84
+ * This flag is used to know if the schema is created to link property/param to a class schema.
85
+ * @private
86
+ */
87
+ #isLocalSchema;
45
88
  #target;
46
- #isGeneric;
47
89
  #isCollection;
48
- #ref;
90
+ #useRefLabel;
91
+ #propertyKey;
49
92
  constructor(obj = {}) {
50
93
  super();
51
94
  this.$kind = "schema";
52
95
  this.$isJsonDocument = true;
53
96
  this.$hooks = new Hooks();
54
- this.$required = new Set();
55
97
  this.$allow = [];
56
- this.$forwardGroups = false;
57
98
  this.$ignore = false;
58
99
  this.isDiscriminatorKey = false;
59
100
  this.isDiscriminator = false;
60
- this.#nullable = false;
101
+ /**
102
+ * All required fields are stored here
103
+ * @private
104
+ */
105
+ this.#required = new Set();
106
+ /**
107
+ * Internal custom props
108
+ * @private
109
+ */
110
+ this.#vendors = new Map();
61
111
  this.#discriminator = null;
62
- this.#nestedGenerics = [];
63
112
  this.#alias = new Map();
64
- this.#isGeneric = false;
113
+ /**
114
+ * This flag is used to know if the schema is created to link property/param to a class schema.
115
+ * @private
116
+ */
117
+ this.#isLocalSchema = false;
65
118
  this.#isCollection = false;
66
- this.#ref = false;
119
+ this.#useRefLabel = false;
67
120
  if (obj) {
68
121
  this.assign(obj);
69
122
  }
@@ -71,32 +124,27 @@ export class JsonSchema extends Map {
71
124
  get alias() {
72
125
  return this.#alias;
73
126
  }
74
- get nestedGenerics() {
75
- return this.#nestedGenerics;
76
- }
77
- set nestedGenerics(value) {
78
- this.#nestedGenerics = value;
79
- }
80
- get genericLabels() {
81
- return this.#genericLabels;
82
- }
83
- set genericLabels(value) {
84
- this.#genericLabels = value;
85
- }
86
127
  get isClass() {
87
- return isClass(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this.#target);
128
+ return isClass(this.class) && !this.isCollection;
88
129
  }
89
130
  /**
90
- * Current schema is a collection
131
+ * The current schema is a collection
91
132
  */
92
133
  get isCollection() {
93
134
  return this.#isCollection;
94
135
  }
136
+ /**
137
+ * The current schema is a reference to another schema
138
+ * to link property/param to a class schema (if the reference exists).
139
+ */
140
+ get isLocalSchema() {
141
+ return this.#isLocalSchema;
142
+ }
95
143
  /**
96
144
  * Current schema is a generic
97
145
  */
98
146
  get isGeneric() {
99
- return this.#isGeneric;
147
+ return this.has(VendorKeys.GENERIC_LABEL);
100
148
  }
101
149
  get discriminatorAncestor() {
102
150
  const ancestors = ancestorsOf(this.#target);
@@ -104,22 +152,27 @@ export class JsonSchema extends Map {
104
152
  return ancestor && JsonEntityStore.from(ancestor).schema;
105
153
  }
106
154
  /**
107
- * Current schema has generics items
155
+ * Return the itemSchema computed type.
156
+ * If the type is a function used for a recursive model,
157
+ * the function will be called to get the right type.
108
158
  */
109
- get hasGenerics() {
110
- return !!(this.nestedGenerics && this.nestedGenerics.length);
111
- }
112
- get genericType() {
113
- return this.get("$ref");
114
- }
115
159
  get class() {
116
- return this.getComputedType();
160
+ if (this.#isLocalSchema) {
161
+ return this.#itemSchema?.getTarget();
162
+ }
163
+ return getComputedType(this.#target);
164
+ }
165
+ /**
166
+ * Return the itemSchema computed type.
167
+ */
168
+ get collectionClass() {
169
+ return this.isCollection && this.#itemSchema ? this.#itemSchema.class : this.class;
117
170
  }
118
171
  get canRef() {
119
- return this.#ref;
172
+ return this.#useRefLabel;
120
173
  }
121
174
  get isNullable() {
122
- return this.#nullable;
175
+ return !!this.get("nullable");
123
176
  }
124
177
  get isReadOnly() {
125
178
  return this.get("readOnly");
@@ -130,15 +183,105 @@ export class JsonSchema extends Map {
130
183
  get hasDiscriminator() {
131
184
  return !!this.#discriminator;
132
185
  }
133
- static from(obj = {}) {
134
- return new JsonSchema(obj);
186
+ static from(item = {}) {
187
+ if (item instanceof JsonSchema) {
188
+ return item;
189
+ }
190
+ if (classOf(item) !== Object && isClass(item)) {
191
+ return JsonEntityStore.from(item).schema;
192
+ }
193
+ if (isPrimitiveClass(item)) {
194
+ return new JsonSchema({ type: item });
195
+ }
196
+ return new JsonSchema(item);
197
+ }
198
+ /**
199
+ * Check if the schema as key, #key or x-key
200
+ * @param key
201
+ */
202
+ has(key) {
203
+ if (super.has(key)) {
204
+ return true;
205
+ }
206
+ if (super.has(`#${key}`)) {
207
+ return true;
208
+ }
209
+ return this.#vendors.has(key);
210
+ }
211
+ get(key, defaultValue) {
212
+ if (this.#vendors.has(key)) {
213
+ return this.#vendors.get(key);
214
+ }
215
+ if (super.has(key)) {
216
+ return super.get(key);
217
+ }
218
+ if (super.has(`#${key}`)) {
219
+ return super.get(`#${key}`);
220
+ }
221
+ return defaultValue;
222
+ }
223
+ forwardGroups(bool = true) {
224
+ this.vendorKey(VendorKeys.FORWARD_GROUPS, bool);
225
+ return this;
226
+ }
227
+ groups(groups, isProperty) {
228
+ if (groups) {
229
+ this.vendorKey(VendorKeys.GROUPS, groups);
230
+ // this.customKey("x-groups", groups);
231
+ if (isProperty) {
232
+ this.$hooks.on("groups", (prev, givenGroups) => {
233
+ if (!prev) {
234
+ if (matchGroups(groups, givenGroups)) {
235
+ return true;
236
+ }
237
+ }
238
+ return prev;
239
+ });
240
+ }
241
+ }
242
+ return this;
243
+ }
244
+ groupsName(groupsName) {
245
+ groupsName && this.vendorKey(VendorKeys.GROUPS_NAME, groupsName);
246
+ return this;
247
+ }
248
+ allowedGroups(groups) {
249
+ groups && this.vendorKey(VendorKeys.ALLOWED_GROUPS, groups);
250
+ return this;
251
+ }
252
+ /**
253
+ * Assign the Generic Labels used over a class or a schema.
254
+ * @param genericLabels
255
+ */
256
+ genericLabels(genericLabels) {
257
+ this.vendorKey(VendorKeys.GENERIC_LABELS, genericLabels);
258
+ return this;
259
+ }
260
+ genericLabel(genericLabel) {
261
+ this.vendorKey(VendorKeys.GENERIC_LABEL, genericLabel);
262
+ return this;
263
+ }
264
+ /**
265
+ * Assign the types of the generics that must be used for the property
266
+ * @param generics
267
+ */
268
+ genericOf(...generics) {
269
+ const mapped = mapGenerics(this.#itemSchema || mapToJsonSchema(this.getTarget()), generics);
270
+ this.vendorKey(VendorKeys.GENERIC_OF, mapped);
271
+ return this;
135
272
  }
136
273
  nullable(value) {
137
- this.#nullable = value;
274
+ this.vendorKey(VendorKeys.NULLABLE, value);
275
+ return this;
138
276
  }
139
277
  itemSchema(obj = {}) {
140
278
  this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);
141
- this.#itemSchema.assign(obj);
279
+ if (isPlainObject(obj)) {
280
+ this.#itemSchema.assign(obj);
281
+ }
282
+ if (!this.isCollection && this.#itemSchema?.isClass) {
283
+ this.#isLocalSchema = true;
284
+ }
142
285
  return this.#itemSchema;
143
286
  }
144
287
  getAliasOf(property) {
@@ -172,7 +315,7 @@ export class JsonSchema extends Map {
172
315
  * @param name
173
316
  */
174
317
  label(name) {
175
- this.#ref = true;
318
+ this.#useRefLabel = true;
176
319
  super.set("name", name);
177
320
  return this;
178
321
  }
@@ -224,6 +367,15 @@ export class JsonSchema extends Map {
224
367
  discriminatorKey(propertyName) {
225
368
  this.discriminator().propertyName = propertyName;
226
369
  this.isDiscriminator = true;
370
+ const propertySchema = this.get("properties")[propertyName];
371
+ if (propertySchema) {
372
+ if (propertySchema.isCollection) {
373
+ propertySchema.itemSchema().isDiscriminatorKey = true;
374
+ }
375
+ else {
376
+ propertySchema.isDiscriminatorKey = true;
377
+ }
378
+ }
227
379
  return this;
228
380
  }
229
381
  discriminatorValue(...values) {
@@ -367,8 +519,8 @@ export class JsonSchema extends Map {
367
519
  */
368
520
  required(required = true) {
369
521
  if (isArray(required)) {
370
- this.$required.clear();
371
- required.forEach((value) => this.$required.add(value));
522
+ this.#required.clear();
523
+ required.forEach((value) => this.#required.add(value));
372
524
  }
373
525
  else {
374
526
  const schema = this.clone();
@@ -381,15 +533,18 @@ export class JsonSchema extends Map {
381
533
  return this;
382
534
  }
383
535
  addRequired(property) {
384
- this.$required.add(property);
536
+ this.#required.add(property);
385
537
  return this;
386
538
  }
387
539
  removeRequired(property) {
388
- this.$required.delete(property);
540
+ this.#required.delete(property);
389
541
  return this;
390
542
  }
391
543
  isRequired(property) {
392
- return this.$required.has(property);
544
+ return this.#required.has(property);
545
+ }
546
+ getRequiredFields() {
547
+ return [...this.#required];
393
548
  }
394
549
  /**
395
550
  * This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.
@@ -507,7 +662,12 @@ export class JsonSchema extends Map {
507
662
  * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
508
663
  */
509
664
  oneOf(oneOf) {
510
- this.setManyOf("oneOf", oneOf);
665
+ if (this.isCollection) {
666
+ this.itemSchema().oneOf(oneOf);
667
+ }
668
+ else {
669
+ this.setManyOf("oneOf", oneOf);
670
+ }
511
671
  return this;
512
672
  }
513
673
  /**
@@ -605,7 +765,7 @@ export class JsonSchema extends Map {
605
765
  case "map":
606
766
  case Map:
607
767
  super.set("type", getJsonType(type));
608
- this.#target = type;
768
+ this.target(type);
609
769
  this.#isCollection = true;
610
770
  if (!this.has("additionalProperties")) {
611
771
  super.set("additionalProperties", this.itemSchema({}));
@@ -614,7 +774,7 @@ export class JsonSchema extends Map {
614
774
  case "array":
615
775
  case Array:
616
776
  super.set("type", getJsonType(type));
617
- this.#target = type;
777
+ this.target(type);
618
778
  this.#isCollection = true;
619
779
  if (!this.has("items")) {
620
780
  super.set("items", this.itemSchema({}));
@@ -623,7 +783,7 @@ export class JsonSchema extends Map {
623
783
  case "set":
624
784
  case Set:
625
785
  super.set("type", getJsonType(type));
626
- this.#target = type;
786
+ this.target(type);
627
787
  this.#isCollection = true;
628
788
  this.uniqueItems(true);
629
789
  if (!this.has("items")) {
@@ -643,7 +803,7 @@ export class JsonSchema extends Map {
643
803
  case Number:
644
804
  case String:
645
805
  super.set("type", getJsonType(type));
646
- this.#target = type;
806
+ this.target(type);
647
807
  if (!this.has("properties")) {
648
808
  super.set("properties", {});
649
809
  }
@@ -651,7 +811,7 @@ export class JsonSchema extends Map {
651
811
  default:
652
812
  if (isClass(type) || isFunction(type)) {
653
813
  super.set("type", undefined);
654
- this.#target = type;
814
+ this.target(type);
655
815
  if (!this.has("properties")) {
656
816
  super.set("properties", {});
657
817
  }
@@ -659,8 +819,7 @@ export class JsonSchema extends Map {
659
819
  else {
660
820
  const jsonType = getJsonType(type);
661
821
  if (jsonType === "generic") {
662
- this.#isGeneric = true;
663
- super.set("$ref", type);
822
+ this.genericLabel(type);
664
823
  }
665
824
  else {
666
825
  super.set("type", jsonType);
@@ -708,6 +867,10 @@ export class JsonSchema extends Map {
708
867
  super.set(`#${key}`, value);
709
868
  return this;
710
869
  }
870
+ vendorKey(key, value) {
871
+ this.#vendors.set(key, value);
872
+ return this;
873
+ }
711
874
  toObject(options) {
712
875
  return this.toJSON(options);
713
876
  }
@@ -722,21 +885,16 @@ export class JsonSchema extends Map {
722
885
  if (obj instanceof JsonSchema) {
723
886
  this.$selfRequired = obj.$selfRequired;
724
887
  this.$allow.push(...obj.$allow);
725
- obj.$required.forEach((key) => {
726
- this.$required.add(key);
727
- });
888
+ this.#required = new Set(obj.#required.keys());
889
+ this.#alias = new Map(this.#alias.entries());
890
+ this.#vendors = new Map(obj.#vendors.entries());
728
891
  this.#discriminator = this.#discriminator ? new Discriminator(this.#discriminator) : null;
729
892
  this.isDiscriminator = obj.isDiscriminator;
730
893
  this.isDiscriminatorKey = obj.isDiscriminatorKey;
731
- this.#ref = obj.#ref;
732
- this.#alias = new Map(this.#alias.entries());
733
- obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);
734
- this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);
894
+ this.#useRefLabel = obj.#useRefLabel;
735
895
  this.#target = obj.#target;
736
- this.#isGeneric = obj.#isGeneric;
737
896
  this.#isCollection = obj.#isCollection;
738
- this.#ref = obj.#ref;
739
- this.#nullable = obj.#nullable;
897
+ this.#isLocalSchema = obj.#isLocalSchema;
740
898
  super.set("type", obj.get("type"));
741
899
  }
742
900
  return this;
@@ -750,17 +908,6 @@ export class JsonSchema extends Map {
750
908
  }
751
909
  return this;
752
910
  }
753
- /**
754
- * Return the itemSchema computed type.
755
- * If the type is a function used for recursive model,
756
- * the function will be called to get the right type.
757
- */
758
- getComputedType() {
759
- return getComputedType(this.#target);
760
- }
761
- getComputedItemType() {
762
- return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();
763
- }
764
911
  /**
765
912
  * Return the Json type as string
766
913
  */
@@ -770,24 +917,84 @@ export class JsonSchema extends Map {
770
917
  return o.getJsonType();
771
918
  });
772
919
  }
773
- return this.get("type") || getJsonType(this.getComputedType());
920
+ return this.get("type") || getJsonType(this.class);
774
921
  }
775
922
  getTarget() {
776
923
  return this.#target;
777
924
  }
925
+ getAllowedGroups() {
926
+ return this.get(VendorKeys.ALLOWED_GROUPS);
927
+ }
928
+ getAllowedRequiredValues() {
929
+ return this.$allow;
930
+ }
931
+ getGroups() {
932
+ return this.get(VendorKeys.GROUPS);
933
+ }
934
+ getGroupsName() {
935
+ return this.get(VendorKeys.GROUPS_NAME);
936
+ }
778
937
  /**
779
938
  * Get the symbolic name of the entity
780
939
  */
781
940
  getName() {
782
- return this.get("name") || (isClass(this.#target) ? nameOf(classOf(this.getComputedType())) : "");
941
+ return this.get("name") || (isClass(this.#target) ? nameOf(classOf(this.class)) : "");
783
942
  }
784
943
  clone() {
785
944
  return new JsonSchema(this);
786
945
  }
946
+ getGenericLabels() {
947
+ const labels = this.get(VendorKeys.GENERIC_LABELS);
948
+ if (this.isClass && !labels) {
949
+ const ancestor = ancestorOf(this.class);
950
+ return ancestor === Object ? undefined : JsonSchema.from(ancestor).getGenericLabels();
951
+ }
952
+ return this.get(VendorKeys.GENERIC_LABELS);
953
+ }
954
+ getGenericOf() {
955
+ return this.get(VendorKeys.GENERIC_OF);
956
+ }
957
+ /**
958
+ * Returns the reference schema for class-based schemas.
959
+ * Used to get the original schema definition when this schema is a local reference.
960
+ * @returns The reference schema or undefined if not applicable
961
+ */
962
+ getRefSchema() {
963
+ if (!this.isLocalSchema && this.isClass) {
964
+ const refSchema = JsonSchema.from(this.class);
965
+ if (refSchema !== this) {
966
+ return refSchema;
967
+ }
968
+ }
969
+ }
970
+ propertyKey(s) {
971
+ this.#propertyKey = s;
972
+ return this;
973
+ }
974
+ getPropertyKey() {
975
+ return this.#propertyKey;
976
+ }
977
+ target(target) {
978
+ if (target === "object") {
979
+ this.#target = Object;
980
+ }
981
+ else {
982
+ this.#target = target;
983
+ }
984
+ }
985
+ isRequiredValue(property, value) {
986
+ if (this.isRequired(property) && [undefined, null, ""].includes(value)) {
987
+ const propertySchema = this.get("properties")?.[property];
988
+ if (propertySchema) {
989
+ return !propertySchema.getAllowedRequiredValues().includes(value);
990
+ }
991
+ }
992
+ return false;
993
+ }
787
994
  setManyOf(keyword, value) {
788
995
  let resolved = value
789
996
  .filter((o) => {
790
- if (o?.type === "null") {
997
+ if (o && "type" in o && o.type === "null") {
791
998
  this.nullable(true);
792
999
  return false;
793
1000
  }
@@ -806,7 +1013,7 @@ export class JsonSchema extends Map {
806
1013
  }
807
1014
  super.set(keyword, resolved);
808
1015
  const jsonSchema = resolved[0];
809
- if (jsonSchema.isDiscriminator) {
1016
+ if (jsonSchema?.isDiscriminator) {
810
1017
  const discriminator = jsonSchema.discriminatorAncestor.discriminator();
811
1018
  const { propertyName } = discriminator;
812
1019
  super.set("discriminator", {