@tsed/schema 7.0.0-beta.3 → 7.0.0-beta.4

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 (299) hide show
  1. package/jest.config.js +4 -4
  2. package/lib/cjs/components/schemaMapper.js +1 -1
  3. package/lib/cjs/components/schemaMapper.js.map +1 -1
  4. package/lib/cjs/constants/httpStatusMessages.js +12 -96
  5. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  6. package/lib/cjs/decorators/common/anyOf.js +4 -0
  7. package/lib/cjs/decorators/common/anyOf.js.map +1 -1
  8. package/lib/cjs/decorators/common/description.js.map +1 -1
  9. package/lib/cjs/decorators/common/enum.js +1 -20
  10. package/lib/cjs/decorators/common/enum.js.map +1 -1
  11. package/lib/cjs/decorators/common/ignore.js.map +1 -1
  12. package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -1
  13. package/lib/cjs/decorators/common/oneOf.js +4 -0
  14. package/lib/cjs/decorators/common/oneOf.js.map +1 -1
  15. package/lib/cjs/decorators/common/recordOf.js +63 -0
  16. package/lib/cjs/decorators/common/recordOf.js.map +1 -0
  17. package/lib/cjs/decorators/operations/acceptMime.js +28 -0
  18. package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
  19. package/lib/cjs/decorators/operations/in.js +6 -4
  20. package/lib/cjs/decorators/operations/in.js.map +1 -1
  21. package/lib/cjs/decorators/operations/view.js +31 -0
  22. package/lib/cjs/decorators/operations/view.js.map +1 -0
  23. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  24. package/lib/cjs/domain/JsonClassStore.js +1 -1
  25. package/lib/cjs/domain/JsonMap.js.map +1 -1
  26. package/lib/cjs/domain/JsonMethodStore.js +66 -24
  27. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  28. package/lib/cjs/domain/JsonOperation.js +11 -26
  29. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  30. package/lib/cjs/domain/JsonOperationRoute.js +4 -0
  31. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  32. package/lib/cjs/domain/JsonParameter.js +38 -44
  33. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  34. package/lib/cjs/domain/JsonParameterStore.js +14 -5
  35. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  36. package/lib/cjs/domain/JsonPropertyStore.js +6 -2
  37. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  38. package/lib/cjs/domain/JsonResponse.js +1 -11
  39. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  40. package/lib/cjs/domain/JsonSchema.js +47 -54
  41. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  42. package/lib/cjs/domain/SpecTypes.js +1 -0
  43. package/lib/cjs/domain/SpecTypes.js.map +1 -1
  44. package/lib/cjs/index.js +149 -20
  45. package/lib/cjs/index.js.map +1 -1
  46. package/lib/cjs/interfaces/JsonSchemaOptions.js.map +1 -1
  47. package/lib/cjs/package.json +3 -0
  48. package/lib/cjs/utils/from.js +9 -8
  49. package/lib/cjs/utils/from.js.map +1 -1
  50. package/lib/cjs/utils/generateSpec.js +55 -0
  51. package/lib/cjs/utils/generateSpec.js.map +1 -0
  52. package/lib/cjs/utils/generics.js.map +1 -1
  53. package/lib/cjs/utils/getJsonSchema.js +11 -1
  54. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  55. package/lib/cjs/utils/getJsonType.js +1 -1
  56. package/lib/cjs/utils/getJsonType.js.map +1 -1
  57. package/lib/cjs/utils/getOperationsRoutes.js +2 -1
  58. package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
  59. package/lib/cjs/utils/getSpec.js +58 -43
  60. package/lib/cjs/utils/getSpec.js.map +1 -1
  61. package/lib/cjs/utils/getSpecType.js +21 -0
  62. package/lib/cjs/utils/getSpecType.js.map +1 -0
  63. package/lib/cjs/utils/mapNullableType.js +1 -1
  64. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  65. package/lib/cjs/utils/mapOpenSpec.js +41 -0
  66. package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
  67. package/lib/cjs/utils/mapOpenSpec2.js +34 -0
  68. package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
  69. package/lib/cjs/utils/mapOpenSpec3.js +26 -0
  70. package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
  71. package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
  72. package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
  73. package/lib/cjs/utils/matchGroups.js +1 -1
  74. package/lib/cjs/utils/matchGroups.js.map +1 -1
  75. package/lib/cjs/utils/mergeOperation.js +1 -0
  76. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  77. package/lib/cjs/utils/mergeSpec.js.map +1 -1
  78. package/lib/cjs/utils/serializeEnumValues.js +26 -0
  79. package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
  80. package/lib/esm/components/anyMapper.js +4 -4
  81. package/lib/esm/components/classMapper.js +4 -4
  82. package/lib/esm/components/genericsMapper.js +4 -4
  83. package/lib/esm/components/inheritedClassMapper.js +2 -2
  84. package/lib/esm/components/itemMapper.js +1 -1
  85. package/lib/esm/components/lazyRefMapper.js +3 -3
  86. package/lib/esm/components/mapMapper.js +2 -2
  87. package/lib/esm/components/objectMapper.js +3 -3
  88. package/lib/esm/components/ofMapper.js +1 -1
  89. package/lib/esm/components/propertiesMapper.js +1 -1
  90. package/lib/esm/components/schemaMapper.js +7 -7
  91. package/lib/esm/components/schemaMapper.js.map +1 -1
  92. package/lib/esm/constants/httpStatusMessages.js +11 -96
  93. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  94. package/lib/esm/decorators/class/children.js +1 -1
  95. package/lib/esm/decorators/collections/collectionContains.js +1 -1
  96. package/lib/esm/decorators/collections/collectionOf.js +1 -1
  97. package/lib/esm/decorators/collections/maxItems.js +1 -1
  98. package/lib/esm/decorators/collections/maxProperties.js +1 -1
  99. package/lib/esm/decorators/collections/minItems.js +1 -1
  100. package/lib/esm/decorators/collections/minProperties.js +1 -1
  101. package/lib/esm/decorators/collections/uniqueItems.js +1 -1
  102. package/lib/esm/decorators/common/additionalProperties.js +1 -1
  103. package/lib/esm/decorators/common/allOf.js +1 -1
  104. package/lib/esm/decorators/common/allow.js +2 -2
  105. package/lib/esm/decorators/common/any.js +1 -1
  106. package/lib/esm/decorators/common/anyOf.js +5 -1
  107. package/lib/esm/decorators/common/anyOf.js.map +1 -1
  108. package/lib/esm/decorators/common/const.js +1 -1
  109. package/lib/esm/decorators/common/customKey.js +1 -1
  110. package/lib/esm/decorators/common/default.js +1 -1
  111. package/lib/esm/decorators/common/description.js +1 -1
  112. package/lib/esm/decorators/common/description.js.map +1 -1
  113. package/lib/esm/decorators/common/enum.js +2 -21
  114. package/lib/esm/decorators/common/enum.js.map +1 -1
  115. package/lib/esm/decorators/common/example.js +1 -1
  116. package/lib/esm/decorators/common/examples.js +1 -1
  117. package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
  118. package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
  119. package/lib/esm/decorators/common/format.js +2 -2
  120. package/lib/esm/decorators/common/forwardGroups.js +1 -1
  121. package/lib/esm/decorators/common/groups.js +2 -2
  122. package/lib/esm/decorators/common/ignore.js +1 -1
  123. package/lib/esm/decorators/common/ignore.js.map +1 -1
  124. package/lib/esm/decorators/common/integer.js +1 -1
  125. package/lib/esm/decorators/common/jsonEntityFn.js +1 -1
  126. package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -1
  127. package/lib/esm/decorators/common/maxLength.js +1 -1
  128. package/lib/esm/decorators/common/maximum.js +1 -1
  129. package/lib/esm/decorators/common/minLength.js +1 -1
  130. package/lib/esm/decorators/common/minimum.js +1 -1
  131. package/lib/esm/decorators/common/multipleOf.js +1 -1
  132. package/lib/esm/decorators/common/name.js +1 -1
  133. package/lib/esm/decorators/common/nullable.js +2 -2
  134. package/lib/esm/decorators/common/oneOf.js +5 -1
  135. package/lib/esm/decorators/common/oneOf.js.map +1 -1
  136. package/lib/esm/decorators/common/optional.js +1 -1
  137. package/lib/esm/decorators/common/pattern.js +1 -1
  138. package/lib/esm/decorators/common/property.js +1 -1
  139. package/lib/esm/decorators/common/readOnly.js +1 -1
  140. package/lib/esm/decorators/common/recordOf.js +59 -0
  141. package/lib/esm/decorators/common/recordOf.js.map +1 -0
  142. package/lib/esm/decorators/common/required.js +2 -2
  143. package/lib/esm/decorators/common/requiredGroups.js +2 -2
  144. package/lib/esm/decorators/common/schema.js +1 -1
  145. package/lib/esm/decorators/common/title.js +1 -1
  146. package/lib/esm/decorators/common/writeOnly.js +1 -1
  147. package/lib/esm/decorators/config/jsonEntityComponent.js +1 -1
  148. package/lib/esm/decorators/generics/genericOf.js +2 -2
  149. package/lib/esm/decorators/generics/generics.js +1 -1
  150. package/lib/esm/decorators/operations/acceptMime.js +24 -0
  151. package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
  152. package/lib/esm/decorators/operations/consumes.js +1 -1
  153. package/lib/esm/decorators/operations/contentType.js +1 -1
  154. package/lib/esm/decorators/operations/deprecated.js +1 -1
  155. package/lib/esm/decorators/operations/header.js +1 -1
  156. package/lib/esm/decorators/operations/in.js +3 -1
  157. package/lib/esm/decorators/operations/in.js.map +1 -1
  158. package/lib/esm/decorators/operations/inFile.js +5 -5
  159. package/lib/esm/decorators/operations/location.js +1 -1
  160. package/lib/esm/decorators/operations/operationId.js +1 -1
  161. package/lib/esm/decorators/operations/operationPath.js +1 -1
  162. package/lib/esm/decorators/operations/partial.js +1 -1
  163. package/lib/esm/decorators/operations/path.js +1 -1
  164. package/lib/esm/decorators/operations/produces.js +1 -1
  165. package/lib/esm/decorators/operations/redirect.js +2 -2
  166. package/lib/esm/decorators/operations/returns.js +8 -8
  167. package/lib/esm/decorators/operations/route.js +3 -3
  168. package/lib/esm/decorators/operations/security.js +1 -1
  169. package/lib/esm/decorators/operations/status.js +1 -1
  170. package/lib/esm/decorators/operations/summary.js +1 -1
  171. package/lib/esm/decorators/operations/tags.js +1 -1
  172. package/lib/esm/decorators/operations/view.js +27 -0
  173. package/lib/esm/decorators/operations/view.js.map +1 -0
  174. package/lib/esm/domain/DecoratorContext.js +1 -1
  175. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  176. package/lib/esm/domain/JsonClassStore.js +3 -3
  177. package/lib/esm/domain/JsonLazyRef.js +2 -2
  178. package/lib/esm/domain/JsonMap.js +1 -1
  179. package/lib/esm/domain/JsonMap.js.map +1 -1
  180. package/lib/esm/domain/JsonMethodStore.js +68 -26
  181. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  182. package/lib/esm/domain/JsonOperation.js +10 -25
  183. package/lib/esm/domain/JsonOperation.js.map +1 -1
  184. package/lib/esm/domain/JsonOperationPathsMap.js +1 -1
  185. package/lib/esm/domain/JsonOperationRoute.js +5 -1
  186. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  187. package/lib/esm/domain/JsonParameter.js +42 -48
  188. package/lib/esm/domain/JsonParameter.js.map +1 -1
  189. package/lib/esm/domain/JsonParameterStore.js +17 -8
  190. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  191. package/lib/esm/domain/JsonPropertyStore.js +7 -3
  192. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  193. package/lib/esm/domain/JsonRequestBody.js +2 -2
  194. package/lib/esm/domain/JsonResponse.js +4 -14
  195. package/lib/esm/domain/JsonResponse.js.map +1 -1
  196. package/lib/esm/domain/JsonSchema.js +9 -16
  197. package/lib/esm/domain/JsonSchema.js.map +1 -1
  198. package/lib/esm/domain/SpecTypes.js +1 -0
  199. package/lib/esm/domain/SpecTypes.js.map +1 -1
  200. package/lib/esm/index.js +149 -20
  201. package/lib/esm/index.js.map +1 -1
  202. package/lib/esm/interfaces/JsonSchemaOptions.js.map +1 -1
  203. package/lib/esm/package.json +3 -0
  204. package/lib/esm/utils/from.js +5 -4
  205. package/lib/esm/utils/from.js.map +1 -1
  206. package/lib/esm/utils/generateSpec.js +50 -0
  207. package/lib/esm/utils/generateSpec.js.map +1 -0
  208. package/lib/esm/utils/generics.js.map +1 -1
  209. package/lib/esm/utils/getInheritedStores.js +1 -1
  210. package/lib/esm/utils/getJsonEntityStore.js +5 -5
  211. package/lib/esm/utils/getJsonSchema.js +14 -4
  212. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  213. package/lib/esm/utils/getJsonType.js +2 -2
  214. package/lib/esm/utils/getJsonType.js.map +1 -1
  215. package/lib/esm/utils/getOperationsRoutes.js +5 -4
  216. package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
  217. package/lib/esm/utils/getOperationsStores.js +4 -4
  218. package/lib/esm/utils/getPropertiesStores.js +3 -3
  219. package/lib/esm/utils/getRequiredProperties.js +1 -1
  220. package/lib/esm/utils/getSpec.js +65 -50
  221. package/lib/esm/utils/getSpec.js.map +1 -1
  222. package/lib/esm/utils/getSpecType.js +16 -0
  223. package/lib/esm/utils/getSpecType.js.map +1 -0
  224. package/lib/esm/utils/mapNullableType.js +2 -2
  225. package/lib/esm/utils/mapNullableType.js.map +1 -1
  226. package/lib/esm/utils/mapOpenSpec.js +37 -0
  227. package/lib/esm/utils/mapOpenSpec.js.map +1 -0
  228. package/lib/esm/utils/mapOpenSpec2.js +30 -0
  229. package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
  230. package/lib/esm/utils/mapOpenSpec3.js +22 -0
  231. package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
  232. package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
  233. package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
  234. package/lib/esm/utils/mapRouteOptions.js +1 -1
  235. package/lib/esm/utils/mergeOperation.js +4 -3
  236. package/lib/esm/utils/mergeOperation.js.map +1 -1
  237. package/lib/esm/utils/mergeSpec.js.map +1 -1
  238. package/lib/esm/utils/ref.js +1 -1
  239. package/lib/esm/utils/serializeEnumValues.js +21 -0
  240. package/lib/esm/utils/serializeEnumValues.js.map +1 -0
  241. package/lib/esm/utils/toJsonMapCollection.js +1 -1
  242. package/lib/types/constants/httpStatusMessages.d.ts +2 -263
  243. package/lib/types/decorators/common/anyOf.d.ts +4 -0
  244. package/lib/types/decorators/common/ignore.d.ts +1 -1
  245. package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
  246. package/lib/types/decorators/common/oneOf.d.ts +4 -0
  247. package/lib/types/decorators/common/recordOf.d.ts +46 -0
  248. package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
  249. package/lib/types/decorators/operations/in.d.ts +1 -1
  250. package/lib/types/decorators/operations/view.d.ts +23 -0
  251. package/lib/types/domain/JsonMap.d.ts +1 -1
  252. package/lib/types/domain/JsonMethodStore.d.ts +51 -2
  253. package/lib/types/domain/JsonOperation.d.ts +2 -1
  254. package/lib/types/domain/JsonOperationRoute.d.ts +5 -3
  255. package/lib/types/domain/JsonParameter.d.ts +2 -1
  256. package/lib/types/domain/JsonParameterStore.d.ts +23 -1
  257. package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
  258. package/lib/types/domain/JsonResponse.d.ts +2 -1
  259. package/lib/types/domain/JsonSchema.d.ts +2 -2
  260. package/lib/types/domain/SpecTypes.d.ts +1 -0
  261. package/lib/types/index.d.ts +142 -13
  262. package/lib/types/interfaces/JsonSchemaOptions.d.ts +2 -2
  263. package/lib/types/utils/generateSpec.d.ts +16 -0
  264. package/lib/types/utils/generics.d.ts +1 -1
  265. package/lib/types/utils/getJsonSchema.d.ts +12 -2
  266. package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
  267. package/lib/types/utils/getSpec.d.ts +5 -4
  268. package/lib/types/utils/getSpecType.d.ts +12 -0
  269. package/lib/types/utils/mapNullableType.d.ts +1 -1
  270. package/lib/types/utils/mapOpenSpec.d.ts +10 -0
  271. package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
  272. package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
  273. package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
  274. package/lib/types/utils/mergeSpec.d.ts +2 -2
  275. package/lib/types/utils/serializeEnumValues.d.ts +5 -0
  276. package/package.json +30 -15
  277. package/readme.md +1 -0
  278. package/tsconfig.compile.esm.json +2 -12
  279. package/benchmark/cold-start.js +0 -17
  280. package/lib/cjs/components/index.js +0 -15
  281. package/lib/cjs/components/index.js.map +0 -1
  282. package/lib/cjs/decorators/index.js +0 -77
  283. package/lib/cjs/decorators/index.js.map +0 -1
  284. package/lib/cjs/domain/index.js +0 -20
  285. package/lib/cjs/domain/index.js.map +0 -1
  286. package/lib/cjs/interfaces/index.js +0 -8
  287. package/lib/cjs/interfaces/index.js.map +0 -1
  288. package/lib/esm/components/index.js +0 -12
  289. package/lib/esm/components/index.js.map +0 -1
  290. package/lib/esm/decorators/index.js +0 -74
  291. package/lib/esm/decorators/index.js.map +0 -1
  292. package/lib/esm/domain/index.js +0 -17
  293. package/lib/esm/domain/index.js.map +0 -1
  294. package/lib/esm/interfaces/index.js +0 -5
  295. package/lib/esm/interfaces/index.js.map +0 -1
  296. package/lib/types/components/index.d.ts +0 -11
  297. package/lib/types/decorators/index.d.ts +0 -68
  298. package/lib/types/domain/index.d.ts +0 -16
  299. package/lib/types/interfaces/index.d.ts +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateSpec.js","sourceRoot":"","sources":["../../../src/utils/generateSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,OAAO,EAA0C,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAW9C,KAAK,UAAU,QAAQ,CAAC,IAAY;IAClC,IAAI,EA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ED,OAAO,SAAS,CAAC,WAAW,EAAE,eAAe,CAAQ,CAAC;AACxD,CAAC","sourcesContent":["import fs from \"fs-extra\";\nimport {getValue} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {mapOpenSpec} from \"./mapOpenSpec\";\nimport {getSpec, JsonTokenOptions, SpecSerializerOptions} from \"./getSpec\";\nimport {getSpecTypeFromSpec} from \"./getSpecType\";\nimport {mergeSpec} from \"./mergeSpec\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\n\nexport interface GenerateSpecOptions extends Omit<SpecSerializerOptions, \"specType\"> {\n tokens: JsonTokenOptions;\n version?: string;\n acceptMimes?: string;\n specPath?: string;\n specVersion?: string;\n spec?: any;\n}\n\nasync function readSpec(path: string) {\n if (fs.existsSync(path)) {\n try {\n return await fs.readJSON(path, {encoding: \"utf8\"});\n } catch (e) {}\n }\n\n /* istanbul ignore next */\n return {};\n}\n\n/**\n * Generate OpenAPI spec from multiple sources (models, files, conf)\n * @param tokens\n * @param options\n */\nexport async function generateSpec({tokens, ...options}: GenerateSpecOptions): Promise<OpenSpec2 | OpenSpec3> {\n const {version = \"1.0.0\", acceptMimes, specPath, specVersion} = options;\n const fileSpec: Partial<OpenSpec2 | OpenSpec3> = specPath ? await readSpec(specPath) : {};\n\n const defaultSpec = mapOpenSpec(getValue(options, \"spec\", {}), {\n fileSpec,\n version,\n specVersion,\n acceptMimes\n });\n\n const specType = getSpecTypeFromSpec(defaultSpec);\n\n let controllersSpec = getSpec(tokens, options);\n\n if (specType === SpecTypes.SWAGGER) {\n // @ts-ignore\n const {convert} = await import(\"api-spec-converter\");\n const {spec} = await convert({\n from: \"openapi_3\",\n to: \"swagger_2\",\n source: {\n ...controllersSpec,\n openapi: \"3.0.1\"\n }\n });\n controllersSpec = spec;\n delete (controllersSpec as any)[\"x-components\"];\n }\n\n return mergeSpec(defaultSpec, controllersSpec) as any;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"generics.js","sourceRoot":"","sources":["../../../src/utils/generics.ts"],"names":[],"mappings":"AA4CA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,aAAuB,EAAE,YAA4B;IAClF,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,GAAqB,EAAE,IAAY,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACrI,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA8C;IAC/E,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,YAAY,EAAE;QACjD,MAAM,EAAC,aAAa,EAAE,YAAY,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;QAEtD,OAAO;YACL,GAAG,GAAG;YACN,QAAQ,EAAE,cAAc,CAAC,aAAa,EAAE,YAAY,CAAC;SACtD,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAqB;IAC/C,MAAM,CAAC,YAAY,EAAE,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC;IAEpD,OAAO;QACL,YAAY;QACZ,cAAc,EAAE,GAAG;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain\";\n\nexport type GenericValue = Type<any> | JsonSchema | any;\n\n/**\n * @ignore\n */\nexport type GenericsMap = Map<string, GenericValue>;\n\n/**\n * @ignore\n */\nexport interface GenericTypes {\n genericTypes: Type<any>[];\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nexport interface GenericLabels {\n genericLabels: string[];\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nexport interface NestedGenerics {\n nestedGenerics: GenericValue[][];\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nexport interface GenericsContext extends GenericTypes, GenericLabels, NestedGenerics {\n generics: GenericsMap;\n}\n\n/**\n * @ignore\n * @param genericLabels\n * @param genericTypes\n */\nexport function getGenericsMap(genericLabels: string[], genericTypes: GenericValue[]): GenericsMap {\n return genericLabels.reduce((map: Map<string, any>, item: string, index: number) => map.set(item, genericTypes[index]), new Map());\n}\n\n/**\n * @ignore\n * @param options\n */\nexport function mapGenericsOptions(options: Partial<GenericTypes & GenericLabels>) {\n if (options.genericLabels && options.genericTypes) {\n const {genericLabels, genericTypes, ...ops} = options;\n\n return {\n ...ops,\n generics: getGenericsMap(genericLabels, genericTypes)\n };\n }\n\n return options;\n}\n\n/**\n * @ignore\n * @param value\n */\nexport function popGenerics(value: NestedGenerics): NestedGenerics & GenericTypes {\n const [genericTypes, ...out] = value.nestedGenerics;\n\n return {\n genericTypes,\n nestedGenerics: out\n };\n}\n"]}
1
+ {"version":3,"file":"generics.js","sourceRoot":"","sources":["../../../src/utils/generics.ts"],"names":[],"mappings":"AA4CA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,aAAuB,EAAE,YAA4B;IAClF,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,GAAqB,EAAE,IAAY,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACrI,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA8C;IAC/E,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,YAAY,EAAE;QACjD,MAAM,EAAC,aAAa,EAAE,YAAY,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;QAEtD,OAAO;YACL,GAAG,GAAG;YACN,QAAQ,EAAE,cAAc,CAAC,aAAa,EAAE,YAAY,CAAC;SACtD,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAqB;IAC/C,MAAM,CAAC,YAAY,EAAE,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC;IAEpD,OAAO;QACL,YAAY;QACZ,cAAc,EAAE,GAAG;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\n\nexport type GenericValue = Type<any> | JsonSchema | any;\n\n/**\n * @ignore\n */\nexport type GenericsMap = Map<string, GenericValue>;\n\n/**\n * @ignore\n */\nexport interface GenericTypes {\n genericTypes: Type<any>[];\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nexport interface GenericLabels {\n genericLabels: string[];\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nexport interface NestedGenerics {\n nestedGenerics: GenericValue[][];\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nexport interface GenericsContext extends GenericTypes, GenericLabels, NestedGenerics {\n generics: GenericsMap;\n}\n\n/**\n * @ignore\n * @param genericLabels\n * @param genericTypes\n */\nexport function getGenericsMap(genericLabels: string[], genericTypes: GenericValue[]): GenericsMap {\n return genericLabels.reduce((map: Map<string, any>, item: string, index: number) => map.set(item, genericTypes[index]), new Map());\n}\n\n/**\n * @ignore\n * @param options\n */\nexport function mapGenericsOptions(options: Partial<GenericTypes & GenericLabels>) {\n if (options.genericLabels && options.genericTypes) {\n const {genericLabels, genericTypes, ...ops} = options;\n\n return {\n ...ops,\n generics: getGenericsMap(genericLabels, genericTypes)\n };\n }\n\n return options;\n}\n\n/**\n * @ignore\n * @param value\n */\nexport function popGenerics(value: NestedGenerics): NestedGenerics & GenericTypes {\n const [genericTypes, ...out] = value.nestedGenerics;\n\n return {\n genericTypes,\n nestedGenerics: out\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ancestorsOf } from "@tsed/core";
2
- import { getJsonEntityStore } from "./getJsonEntityStore";
2
+ import { getJsonEntityStore } from "./getJsonEntityStore.js";
3
3
  /**
4
4
  * Return store and his inherited stores
5
5
  * @param target
@@ -1,9 +1,9 @@
1
1
  import { DecoratorTypes } from "@tsed/core";
2
- import { JsonEntitiesContainer, JsonEntityStore } from "../domain/JsonEntityStore";
3
- import { JsonClassStore } from "../domain/JsonClassStore";
4
- import { JsonPropertyStore } from "../domain/JsonPropertyStore";
5
- import { JsonParameterStore } from "../domain/JsonParameterStore";
6
- import { JsonMethodStore } from "../domain/JsonMethodStore";
2
+ import { JsonEntitiesContainer, JsonEntityStore } from "../domain/JsonEntityStore.js";
3
+ import { JsonClassStore } from "../domain/JsonClassStore.js";
4
+ import { JsonPropertyStore } from "../domain/JsonPropertyStore.js";
5
+ import { JsonParameterStore } from "../domain/JsonParameterStore.js";
6
+ import { JsonMethodStore } from "../domain/JsonMethodStore.js";
7
7
  JsonEntitiesContainer.set(DecoratorTypes.CLASS, JsonClassStore);
8
8
  JsonEntitiesContainer.set(DecoratorTypes.PROP, JsonPropertyStore);
9
9
  JsonEntitiesContainer.set(DecoratorTypes.PARAM, JsonParameterStore);
@@ -1,7 +1,17 @@
1
- import "../components";
2
- import { SpecTypes } from "../domain/SpecTypes";
3
- import { execMapper } from "../registries/JsonSchemaMapperContainer";
4
- import { getJsonEntityStore } from "./getJsonEntityStore";
1
+ import { SpecTypes } from "../domain/SpecTypes.js";
2
+ import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
3
+ import { getJsonEntityStore } from "./getJsonEntityStore.js";
4
+ import "../components/anyMapper.js";
5
+ import "../components/classMapper.js";
6
+ import "../components/genericsMapper.js";
7
+ import "../components/inheritedClassMapper.js";
8
+ import "../components/itemMapper.js";
9
+ import "../components/lazyRefMapper.js";
10
+ import "../components/mapMapper.js";
11
+ import "../components/objectMapper.js";
12
+ import "../components/ofMapper.js";
13
+ import "../components/propertiesMapper.js";
14
+ import "../components/schemaMapper.js";
5
15
  /**
6
16
  * @ignore
7
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getJsonSchema.js","source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R,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE;QACV,GAAG,OAAO;QACV,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI;QAC5C,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,IAAI,MAAM,CAAC,aAAa,KAAK,WAAW,EAAE;QACxC,OAAO,GAAG;YACR,GAAG,OAAO;YACV,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;YACtC,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,MAAM,EAAE,MAAA,MAAM,CAAC,SAAS,0CAAE,MAAM;SACjC,CAAC;KACH;IAED,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport \"../components\";\nimport type {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\n\n/**\n * @ignore\n */\nconst CACHE_KEY = \"$cache:schemes\";\n\n/**\n * @ignore\n */\nfunction getKey(options: any) {\n return JSON.stringify(options);\n}\n\n/**\n * @ignore\n */\nfunction get(entity: JsonEntityStore, options: any) {\n const cache: Map<string, any> = entity.store.get(CACHE_KEY) || new Map();\n const key = getKey(options);\n\n if (!cache.has(key)) {\n const schema = execMapper(\"schema\", entity.schema, options);\n\n if (Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n cache.set(key, schema);\n }\n\n entity.store.set(CACHE_KEY, cache);\n\n return cache.get(key);\n}\n\nexport function getJsonSchema(model: Type<any> | any, options: JsonSchemaOptions = {}) {\n const entity = getJsonEntityStore(model);\n\n options = {\n endpoint: true,\n groups: [],\n ...options,\n specType: options.specType || SpecTypes.JSON,\n schemas: {}\n };\n\n if (entity.decoratorType === \"parameter\") {\n options = {\n ...options,\n genericTypes: entity.nestedGenerics[0],\n nestedGenerics: entity.nestedGenerics,\n groups: entity.parameter?.groups\n };\n }\n\n return get(entity, options);\n}\n"]}
1
+ {"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/utils/getJsonSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,yBAAyB,CAAC;AACjC,OAAO,2BAA2B,CAAC;AACnC,OAAO,8BAA8B,CAAC;AACtC,OAAO,oCAAoC,CAAC;AAC5C,OAAO,0BAA0B,CAAC;AAClC,OAAO,6BAA6B,CAAC;AACrC,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,wBAAwB,CAAC;AAChC,OAAO,gCAAgC,CAAC;AACxC,OAAO,4BAA4B,CAAC;AAEpC;;GAEG;AACH,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC;;GAEG;AACH,SAAS,MAAM,CAAC,OAAY;IAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAS,GAAG,CAAC,MAAuB,EAAE,OAAY;IAChD,MAAM,KAAK,GAAqB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;IACzE,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAE5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACnB,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE5D,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;YACvC,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;SACtC;QAED,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;KACxB;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAEnC,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAsB,EAAE,UAA6B,EAAE;;IACnF,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAEzC,OAAO,GAAG;QACR,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE;QACV,GAAG,OAAO;QACV,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI;QAC5C,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,IAAI,MAAM,CAAC,aAAa,KAAK,WAAW,EAAE;QACxC,OAAO,GAAG;YACR,GAAG,OAAO;YACV,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;YACtC,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,MAAM,EAAE,MAAA,MAAM,CAAC,SAAS,0CAAE,MAAM;SACjC,CAAC;KACH;IAED,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport \"../components/anyMapper\";\nimport \"../components/classMapper\";\nimport \"../components/genericsMapper\";\nimport \"../components/inheritedClassMapper\";\nimport \"../components/itemMapper\";\nimport \"../components/lazyRefMapper\";\nimport \"../components/mapMapper\";\nimport \"../components/objectMapper\";\nimport \"../components/ofMapper\";\nimport \"../components/propertiesMapper\";\nimport \"../components/schemaMapper\";\n\n/**\n * @ignore\n */\nconst CACHE_KEY = \"$cache:schemes\";\n\n/**\n * @ignore\n */\nfunction getKey(options: any) {\n return JSON.stringify(options);\n}\n\n/**\n * @ignore\n */\nfunction get(entity: JsonEntityStore, options: any) {\n const cache: Map<string, any> = entity.store.get(CACHE_KEY) || new Map();\n const key = getKey(options);\n\n if (!cache.has(key)) {\n const schema = execMapper(\"schema\", entity.schema, options);\n\n if (Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n cache.set(key, schema);\n }\n\n entity.store.set(CACHE_KEY, cache);\n\n return cache.get(key);\n}\n\nexport function getJsonSchema(model: Type<any> | any, options: JsonSchemaOptions = {}) {\n const entity = getJsonEntityStore(model);\n\n options = {\n endpoint: true,\n groups: [],\n ...options,\n specType: options.specType || SpecTypes.JSON,\n schemas: {}\n };\n\n if (entity.decoratorType === \"parameter\") {\n options = {\n ...options,\n genericTypes: entity.nestedGenerics[0],\n nestedGenerics: entity.nestedGenerics,\n groups: entity.parameter?.groups\n };\n }\n\n return get(entity, options);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { isArray, isDate, isPrimitiveOrPrimitiveClass, primitiveOf } from "@tsed/core";
1
+ import { isArray, isBuffer, isDate, isPrimitiveOrPrimitiveClass, primitiveOf } from "@tsed/core";
2
2
  /**
3
3
  * @ignore
4
4
  */
@@ -28,7 +28,7 @@ export function getJsonType(value) {
28
28
  if (value === Set) {
29
29
  return "array";
30
30
  }
31
- if (isDate(value)) {
31
+ if (isDate(value) || isBuffer(value)) {
32
32
  return "string";
33
33
  }
34
34
  return "object";
@@ -1 +1 @@
1
- {"version":3,"file":"getJsonType.js","sourceRoot":"","sources":["../../../src/utils/getJsonType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,2BAA2B,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AAErF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAEvG,MAAM,UAAU,WAAW,CAAC,KAAU;IACpC,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,MAAM,CAAC;KACf;IAED,IAAI,2BAA2B,CAAC,KAAK,CAAC,EAAE;QACtC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAe,CAAC,GAAG,CAAC,CAAC,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,KAAK,KAAK,MAAM,EAAE;gBACpB,OAAO,MAAM,CAAC;aACf;YAED,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;KAC3B;IAED,IAAI,KAAK,KAAK,KAAK,EAAE;QACnB,OAAO,OAAO,CAAC;KAChB;IAED,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,CAAQ,CAAC;KACtC;IAED,IAAI,KAAK,KAAK,GAAG,EAAE;QACjB,OAAO,OAAO,CAAC;KAChB;IAED,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QACjB,OAAO,QAAQ,CAAC;KACjB;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {isArray, isDate, isPrimitiveOrPrimitiveClass, primitiveOf} from \"@tsed/core\";\n\n/**\n * @ignore\n */\nexport const JSON_TYPES = [\"string\", \"number\", \"integer\", \"boolean\", \"object\", \"array\", \"null\", \"any\"];\n\nexport function getJsonType(value: any): string {\n if (value === null) {\n return \"null\";\n }\n\n if (isPrimitiveOrPrimitiveClass(value)) {\n if (JSON_TYPES.indexOf(value as string) > -1) {\n return value;\n }\n\n if (typeof value === \"string\") {\n if (value === \"file\") {\n return \"file\";\n }\n\n return \"generic\";\n }\n\n return primitiveOf(value);\n }\n\n if (value === Array) {\n return \"array\";\n }\n\n if (isArray(value)) {\n return value.map(getJsonType) as any;\n }\n\n if (value === Set) {\n return \"array\";\n }\n\n if (isDate(value)) {\n return \"string\";\n }\n\n return \"object\";\n}\n"]}
1
+ {"version":3,"file":"getJsonType.js","sourceRoot":"","sources":["../../../src/utils/getJsonType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,2BAA2B,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AAE/F;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAEvG,MAAM,UAAU,WAAW,CAAC,KAAU;IACpC,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,MAAM,CAAC;KACf;IAED,IAAI,2BAA2B,CAAC,KAAK,CAAC,EAAE;QACtC,IAAI,UAAU,CAAC,OAAO,CAAC,KAAe,CAAC,GAAG,CAAC,CAAC,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,KAAK,KAAK,MAAM,EAAE;gBACpB,OAAO,MAAM,CAAC;aACf;YAED,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;KAC3B;IAED,IAAI,KAAK,KAAK,KAAK,EAAE;QACnB,OAAO,OAAO,CAAC;KAChB;IAED,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,GAAG,CAAC,WAAW,CAAQ,CAAC;KACtC;IAED,IAAI,KAAK,KAAK,GAAG,EAAE;QACjB,OAAO,OAAO,CAAC;KAChB;IAED,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QACpC,OAAO,QAAQ,CAAC;KACjB;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {isArray, isBuffer, isDate, isPrimitiveOrPrimitiveClass, primitiveOf} from \"@tsed/core\";\n\n/**\n * @ignore\n */\nexport const JSON_TYPES = [\"string\", \"number\", \"integer\", \"boolean\", \"object\", \"array\", \"null\", \"any\"];\n\nexport function getJsonType(value: any): string {\n if (value === null) {\n return \"null\";\n }\n\n if (isPrimitiveOrPrimitiveClass(value)) {\n if (JSON_TYPES.indexOf(value as string) > -1) {\n return value;\n }\n\n if (typeof value === \"string\") {\n if (value === \"file\") {\n return \"file\";\n }\n\n return \"generic\";\n }\n\n return primitiveOf(value);\n }\n\n if (value === Array) {\n return \"array\";\n }\n\n if (isArray(value)) {\n return value.map(getJsonType) as any;\n }\n\n if (value === Set) {\n return \"array\";\n }\n\n if (isDate(value) || isBuffer(value)) {\n return \"string\";\n }\n\n return \"object\";\n}\n"]}
@@ -1,9 +1,10 @@
1
- import { getOperationsStores } from "./getOperationsStores";
2
- import { JsonOperationRoute } from "../domain/JsonOperationRoute";
3
- import { getJsonEntityStore } from "./getJsonEntityStore";
1
+ import { getOperationsStores } from "./getOperationsStores.js";
2
+ import { JsonOperationRoute } from "../domain/JsonOperationRoute.js";
3
+ import { getJsonEntityStore } from "./getJsonEntityStore.js";
4
+ import { concatPath } from "./concatPath.js";
4
5
  export function getOperationsRoutes(token, options = {}) {
5
6
  const store = token.isStore ? token : getJsonEntityStore(token);
6
- const basePath = ((options.basePath || "") + (store.path || "")).replace(/\/\//gi, "/");
7
+ const basePath = concatPath(options.basePath, store.path);
7
8
  let operationsRoutes = [];
8
9
  if (options.withChildren) {
9
10
  const children = store.get("childrenControllers", []);
@@ -1 +1 @@
1
- {"version":3,"file":"getOperationsRoutes.js","sourceRoot":"","sources":["../../../src/utils/getOperationsR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AAC,IAAI,CACT,IAAI,kBAAkB,CAAS;oBAC7B,QAAQ;oBACR,KAAK;oBACL,QAAQ;oBACR,aAAa;iBACd,CAAC,CACH,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,gBAAgB,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {getOperationsStores} from \"./getOperationsStores\";\nimport {JsonOperationRoute} from \"../domain/JsonOperationRoute\";\nimport {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\n\nexport interface GetOperationsRoutesOptions {\n withChildren?: boolean;\n basePath?: string;\n}\n\nexport function getOperationsRoutes<Entity extends JsonEntityStore = JsonEntityStore>(\n token: Type<any> | any,\n options: GetOperationsRoutesOptions = {}\n): JsonOperationRoute<Entity>[] {\n const store: JsonEntityStore = token.isStore ? token : getJsonEntityStore(token);\n const basePath = ((options.basePath || \"\") + (store.path || \"\")).replace(/\\/\\//gi, \"/\");\n let operationsRoutes: JsonOperationRoute<Entity>[] = [];\n\n if (options.withChildren) {\n const children = store.get<Type[]>(\"childrenControllers\", []);\n\n operationsRoutes = children.reduce((operationsRoutes, token) => {\n return operationsRoutes.concat(\n getOperationsRoutes(token, {\n ...options,\n basePath\n })\n );\n }, operationsRoutes);\n }\n\n return [...getOperationsStores(token).values()].reduce((routes, endpoint) => {\n const {operation} = endpoint;\n\n if (operation) {\n operation.operationPaths.forEach((operationPath) => {\n routes.push(\n new JsonOperationRoute<Entity>({\n basePath,\n token,\n endpoint,\n operationPath\n })\n );\n });\n }\n\n return routes;\n }, operationsRoutes);\n}\n"]}
1
+ {"version":3,"file":"getOperationsRoutes.js","sourceRoot":"","sources":["../../../src/utils/getOperationsRoutes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,kBAAkB,EAAC,MAAM,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O,MAAM,CAAC;IAChB,CAAC,EAAE,gBAAgB,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonMethodStore} from \"../domain/JsonMethodStore\";\nimport {getOperationsStores} from \"./getOperationsStores\";\nimport {JsonOperationRoute} from \"../domain/JsonOperationRoute\";\nimport {JsonEntityStore} from \"../domain/JsonEntityStore\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport {concatPath} from \"./concatPath\";\n\nexport interface GetOperationsRoutesOptions {\n withChildren?: boolean;\n basePath?: string;\n}\n\nexport function getOperationsRoutes<Entity extends JsonMethodStore = JsonMethodStore>(\n token: Type<any> | any,\n options: GetOperationsRoutesOptions = {}\n): JsonOperationRoute<Entity>[] {\n const store: JsonEntityStore = token.isStore ? token : getJsonEntityStore(token);\n const basePath = concatPath(options.basePath, store.path);\n let operationsRoutes: JsonOperationRoute<Entity>[] = [];\n\n if (options.withChildren) {\n const children = store.get<Type[]>(\"childrenControllers\", []);\n\n operationsRoutes = children.reduce((operationsRoutes, token) => {\n return operationsRoutes.concat(\n getOperationsRoutes(token, {\n ...options,\n basePath\n })\n );\n }, operationsRoutes);\n }\n\n return [...getOperationsStores(token).values()].reduce((routes, endpoint) => {\n const {operation} = endpoint;\n\n if (operation) {\n operation.operationPaths.forEach((operationPath) => {\n routes.push(\n new JsonOperationRoute<Entity>({\n basePath,\n token,\n endpoint,\n operationPath\n })\n );\n });\n }\n\n return routes;\n }, operationsRoutes);\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { JsonMethodStore } from "../domain/JsonMethodStore";
2
- import { JsonOperationPathsMap } from "../domain/JsonOperationPathsMap";
3
- import { getInheritedStores } from "./getInheritedStores";
4
- import { getJsonEntityStore } from "./getJsonEntityStore";
1
+ import { JsonMethodStore } from "../domain/JsonMethodStore.js";
2
+ import { JsonOperationPathsMap } from "../domain/JsonOperationPathsMap.js";
3
+ import { getInheritedStores } from "./getInheritedStores.js";
4
+ import { getJsonEntityStore } from "./getJsonEntityStore.js";
5
5
  /**
6
6
  * @ignore
7
7
  */
@@ -1,6 +1,6 @@
1
- import { alterIgnore } from "../hooks/alterIgnore";
2
- import { getInheritedStores } from "./getInheritedStores";
3
- import { getJsonEntityStore } from "./getJsonEntityStore";
1
+ import { alterIgnore } from "../hooks/alterIgnore.js";
2
+ import { getInheritedStores } from "./getInheritedStores.js";
3
+ import { getJsonEntityStore } from "./getJsonEntityStore.js";
4
4
  /**
5
5
  * Return the list of properties including properties from inherited classes
6
6
  * @param target
@@ -1,5 +1,5 @@
1
1
  import { uniq } from "@tsed/core";
2
- import { alterRequiredGroups } from "../hooks/alterRequiredGroups";
2
+ import { alterRequiredGroups } from "../hooks/alterRequiredGroups.js";
3
3
  function applyStringRule(obj, propSchema) {
4
4
  if (!(propSchema === null || propSchema === void 0 ? void 0 : propSchema.$allow.includes(""))) {
5
5
  if ([].concat(propSchema === null || propSchema === void 0 ? void 0 : propSchema.get("type")).includes("string")) {
@@ -1,10 +1,11 @@
1
- import { cleanObject, uniqBy } from "@tsed/core";
2
- import { SpecTypes } from "../domain/SpecTypes";
3
- import { buildPath } from "./buildPath";
4
- import { getJsonEntityStore } from "./getJsonEntityStore";
5
- import { getOperationsStores } from "./getOperationsStores";
6
- import { mergeOperation } from "./mergeOperation";
7
- import { operationIdFormatter } from "./operationIdFormatter";
1
+ import { cleanObject, isArray, uniqBy } from "@tsed/core";
2
+ import { SpecTypes } from "../domain/SpecTypes.js";
3
+ import { buildPath } from "./buildPath.js";
4
+ import { getJsonEntityStore } from "./getJsonEntityStore.js";
5
+ import { getOperationsStores } from "./getOperationsStores.js";
6
+ import { mergeOperation } from "./mergeOperation.js";
7
+ import { operationIdFormatter } from "./operationIdFormatter.js";
8
+ import { mergeSpec } from "./mergeSpec.js";
8
9
  /**
9
10
  * @ignore
10
11
  */
@@ -23,61 +24,75 @@ function get(model, options, cb) {
23
24
  }
24
25
  return cache.get(key);
25
26
  }
27
+ function generate(model, options) {
28
+ const store = getJsonEntityStore(model);
29
+ const { schemas = {}, paths = {}, rootPath = "/", tags = [] } = options;
30
+ const specType = SpecTypes.OPENAPI;
31
+ const ctrlPath = store.path;
32
+ const defaultTags = cleanObject({
33
+ name: store.schema.getName(),
34
+ description: store.schema.get("description")
35
+ });
36
+ const specJson = { paths };
37
+ getOperationsStores(model).forEach((operationStore) => {
38
+ if (operationStore.store.get("hidden")) {
39
+ return;
40
+ }
41
+ const operation = operationStore.operation.toJSON({ ...options, specType, schemas });
42
+ operationStore.operation.operationPaths.forEach(({ path, method }) => {
43
+ if (method) {
44
+ mergeOperation(specJson, operation, {
45
+ rootPath: buildPath(rootPath + ctrlPath),
46
+ path,
47
+ method,
48
+ defaultTags,
49
+ tags,
50
+ specType,
51
+ operationId: (path) => options.operationIdFormatter(operationStore.parent.schema.get("name") || operationStore.parent.targetName, operationStore.propertyName, path)
52
+ });
53
+ }
54
+ });
55
+ });
56
+ specJson.tags = uniqBy(tags, "name");
57
+ if (Object.keys(schemas).length) {
58
+ specJson.components = {
59
+ schemas
60
+ };
61
+ }
62
+ return specJson;
63
+ }
26
64
  /**
27
65
  * Return the swagger or open spec for the given class.
28
66
  * @param model
29
67
  * @param options
30
68
  */
31
69
  export function getSpec(model, options = {}) {
32
- if (!options.specType) {
33
- options.specType = SpecTypes.OPENAPI;
34
- }
35
70
  options = {
36
71
  ...options,
37
72
  operationIdFormatter: options.operationIdFormatter || operationIdFormatter(options.operationIdPattern),
38
- root: false,
39
- specType: options.specType
73
+ root: false
40
74
  };
41
- return get(model, options, () => {
42
- const store = getJsonEntityStore(model);
43
- const { specType = SpecTypes.OPENAPI, schemas = {}, paths = {}, rootPath = "/", tags = [] } = options;
44
- const ctrlPath = store.path;
45
- const defaultTags = cleanObject({
46
- name: store.schema.getName(),
47
- description: store.schema.get("description")
48
- });
49
- const specJson = { paths };
50
- getOperationsStores(model).forEach((operationStore) => {
51
- if (operationStore.store.get("hidden")) {
52
- return;
75
+ if (isArray(model)) {
76
+ let finalSpec = {};
77
+ options = {
78
+ ...options,
79
+ specType: SpecTypes.OPENAPI,
80
+ paths: {},
81
+ tags: [],
82
+ schemas: {},
83
+ append(spec) {
84
+ finalSpec = mergeSpec(finalSpec, spec);
53
85
  }
54
- const operation = operationStore.operation.toJSON({ ...options, specType, schemas });
55
- operationStore.operation.operationPaths.forEach(({ path, method }) => {
56
- if (method) {
57
- mergeOperation(specJson, operation, {
58
- rootPath: buildPath(rootPath + ctrlPath),
59
- path,
60
- method,
61
- defaultTags,
62
- tags,
63
- specType,
64
- operationId: (path) => options.operationIdFormatter(operationStore.parent.schema.get("name") || operationStore.parent.targetName, operationStore.propertyName, path)
65
- });
66
- }
86
+ };
87
+ model.forEach(({ token, ...opts }) => {
88
+ const spec = getSpec(token, {
89
+ ...options,
90
+ ...opts
67
91
  });
92
+ options.append(spec);
68
93
  });
69
- specJson.tags = uniqBy(tags, "name");
70
- if (Object.keys(schemas).length) {
71
- if (specType === SpecTypes.OPENAPI) {
72
- specJson.components = {
73
- schemas
74
- };
75
- }
76
- else {
77
- specJson.definitions = schemas;
78
- }
79
- }
80
- return specJson;
81
- });
94
+ return finalSpec;
95
+ }
96
+ return get(model, options, () => generate(model, options));
82
97
  }
83
98
  //# sourceMappingURL=getSpec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSpec.js","sourceRoot":"","sources":["../../../src/utils/getSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAQ,MAAM,EAAC,MAAM,YAAY,CAAC;AAErD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAw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,EAAE,MAAM,CAAC,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;YAC/B,IAAI,QAAQ,KAAK,SAAS,CAAC,OAAO,EAAE;gBAClC,QAAQ,CAAC,UAAU,GAAG;oBACpB,OAAO;iBACR,CAAC;aACH;iBAAM;gBACL,QAAQ,CAAC,WAAW,GAAG,OAAO,CAAC;aAChC;SACF;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {cleanObject, Type, uniqBy} from \"@tsed/core\";\nimport {OpenSpec3} from \"@tsed/openspec\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {buildPath} from \"./buildPath\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport {getOperationsStores} from \"./getOperationsStores\";\nimport {mergeOperation} from \"./mergeOperation\";\nimport {operationIdFormatter} from \"./operationIdFormatter\";\n\nexport interface SpecSerializerOptions extends JsonSchemaOptions {\n specType?: SpecTypes.OPENAPI;\n /**\n * Paths\n */\n paths?: any;\n /**\n * Root path. This paths will be added to all generated paths Object.\n */\n rootPath?: string;\n /**\n * A function to generate the operationId.\n */\n operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;\n /**\n * A pattern to generate the operationId.\n */\n operationIdPattern?: string;\n}\n\n/**\n * @ignore\n */\nconst caches: Map<Type<any>, Map<string, any>> = new Map();\n\n/**\n * @ignore\n */\nfunction get(model: Type<any>, options: any, cb: any) {\n if (!caches.has(model)) {\n caches.set(model, new Map());\n }\n\n const cache = caches.get(model)!;\n const key = JSON.stringify(options);\n\n if (!cache.has(key)) {\n cache.set(key, cb());\n }\n\n return cache.get(key);\n}\n\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any>, options: SpecSerializerOptions = {}): Partial<OpenSpec3> {\n if (!options.specType) {\n options.specType = SpecTypes.OPENAPI;\n }\n\n options = {\n ...options,\n operationIdFormatter: options.operationIdFormatter || operationIdFormatter(options.operationIdPattern),\n root: false,\n specType: options.specType\n };\n\n return get(model, options, () => {\n const store = getJsonEntityStore(model);\n const {specType = SpecTypes.OPENAPI, schemas = {}, paths = {}, rootPath = \"/\", tags = []} = options;\n const ctrlPath = store.path;\n const defaultTags = cleanObject({\n name: store.schema.getName(),\n description: store.schema.get(\"description\")\n });\n\n const specJson: any = {paths};\n\n getOperationsStores(model).forEach((operationStore) => {\n if (operationStore.store.get(\"hidden\")) {\n return;\n }\n\n const operation = operationStore.operation!.toJSON({...options, specType, schemas});\n\n operationStore.operation!.operationPaths.forEach(({path, method}: {path: string; method: string}) => {\n if (method) {\n mergeOperation(specJson, operation, {\n rootPath: buildPath(rootPath + ctrlPath),\n path,\n method,\n defaultTags,\n tags,\n specType,\n operationId: (path: string) =>\n options.operationIdFormatter!(\n operationStore.parent.schema.get(\"name\") || operationStore.parent.targetName,\n operationStore.propertyName,\n path\n )\n });\n }\n });\n });\n\n specJson.tags = uniqBy(tags, \"name\");\n\n if (Object.keys(schemas).length) {\n if (specType === SpecTypes.OPENAPI) {\n specJson.components = {\n schemas\n };\n } else {\n specJson.definitions = schemas;\n }\n }\n\n return specJson;\n });\n}\n"]}
1
+ {"version":3,"file":"getSpec.js","sourceRoot":"","sources":["../../../src/utils/getSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAQ,MAAM,EAAC,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAA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AC,oBAAoB,IAAI,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACtG,IAAI,EAAE,KAAK;KACZ,CAAC;IAEF,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAClB,IAAI,SAAS,GAAQ,EAAE,CAAC;QAExB,OAAO,GAAG;YACR,GAAG,OAAO;YACV,QAAQ,EAAE,SAAS,CAAC,OAAO;YAC3B,KAAK,EAAE,EAAE;YACT,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,EAAE;YACX,MAAM,CAAC,IAAS;gBACd,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC;SACF,CAAC;QAEF,KAAK,CAAC,OAAO,CAAC,CAAC,EAAC,KAAK,EAAE,GAAG,IAAI,EAAC,EAAE,EAAE;YACjC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE;gBAC1B,GAAG,OAAO;gBACV,GAAG,IAAI;aACR,CAAC,CAAC;YAEH,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import {cleanObject, isArray, Type, uniqBy} from \"@tsed/core\";\nimport {OpenSpec3} from \"@tsed/openspec\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {buildPath} from \"./buildPath\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport {getOperationsStores} from \"./getOperationsStores\";\nimport {mergeOperation} from \"./mergeOperation\";\nimport {operationIdFormatter} from \"./operationIdFormatter\";\nimport {mergeSpec} from \"./mergeSpec\";\n\nexport type JsonTokenOptions = ({token: Type<any>} & Partial<SpecSerializerOptions>)[];\n\nexport interface SpecSerializerOptions extends JsonSchemaOptions {\n /**\n * Paths\n */\n paths?: any;\n /**\n * Root path. This paths will be added to all generated paths Object.\n */\n rootPath?: string;\n /**\n * A function to generate the operationId.\n */\n operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;\n /**\n * A pattern to generate the operationId.\n */\n operationIdPattern?: string;\n}\n\n/**\n * @ignore\n */\nconst caches: Map<Type<any>, Map<string, any>> = new Map();\n\n/**\n * @ignore\n */\nfunction get(model: Type<any>, options: any, cb: any) {\n if (!caches.has(model)) {\n caches.set(model, new Map());\n }\n\n const cache = caches.get(model)!;\n const key = JSON.stringify(options);\n\n if (!cache.has(key)) {\n cache.set(key, cb());\n }\n\n return cache.get(key);\n}\n\nfunction generate(model: Type<any>, options: SpecSerializerOptions) {\n const store = getJsonEntityStore(model);\n const {schemas = {}, paths = {}, rootPath = \"/\", tags = []} = options;\n const specType = SpecTypes.OPENAPI;\n const ctrlPath = store.path;\n const defaultTags = cleanObject({\n name: store.schema.getName(),\n description: store.schema.get(\"description\")\n });\n\n const specJson: any = {paths};\n\n getOperationsStores(model).forEach((operationStore) => {\n if (operationStore.store.get(\"hidden\")) {\n return;\n }\n\n const operation = operationStore.operation!.toJSON({...options, specType, schemas});\n\n operationStore.operation!.operationPaths.forEach(({path, method}: {path: string; method: string}) => {\n if (method) {\n mergeOperation(specJson, operation, {\n rootPath: buildPath(rootPath + ctrlPath),\n path,\n method,\n defaultTags,\n tags,\n specType,\n operationId: (path: string) =>\n options.operationIdFormatter!(\n operationStore.parent.schema.get(\"name\") || operationStore.parent.targetName,\n operationStore.propertyName,\n path\n )\n });\n }\n });\n });\n\n specJson.tags = uniqBy(tags, \"name\");\n\n if (Object.keys(schemas).length) {\n specJson.components = {\n schemas\n };\n }\n\n return specJson;\n}\n\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any> | JsonTokenOptions, options: SpecSerializerOptions = {}): Partial<OpenSpec3> {\n options = {\n ...options,\n operationIdFormatter: options.operationIdFormatter || operationIdFormatter(options.operationIdPattern),\n root: false\n };\n\n if (isArray(model)) {\n let finalSpec: any = {};\n\n options = {\n ...options,\n specType: SpecTypes.OPENAPI,\n paths: {},\n tags: [],\n schemas: {},\n append(spec: any) {\n finalSpec = mergeSpec(finalSpec, spec);\n }\n };\n\n model.forEach(({token, ...opts}) => {\n const spec = getSpec(token, {\n ...options,\n ...opts\n });\n\n options.append(spec);\n });\n\n return finalSpec;\n }\n\n return get(model, options, () => generate(model, options));\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { SpecTypes } from "../domain/SpecTypes.js";
2
+ /**
3
+ * @ignore
4
+ * @param version
5
+ */
6
+ export function getSpecType(version) {
7
+ return version.startsWith("3.") ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;
8
+ }
9
+ /**
10
+ * @ignore
11
+ * @param spec
12
+ */
13
+ export function getSpecTypeFromSpec(spec) {
14
+ return "openapi" in spec ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;
15
+ }
16
+ //# sourceMappingURL=getSpecType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSpecType.js","sourceRoot":"","sources":["../../../src/utils/getSpecType.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAoC;IACtE,OAAO,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;AACnE,CAAC","sourcesContent":["import {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\n\n/**\n * @ignore\n * @param version\n */\nexport function getSpecType(version: string) {\n return version.startsWith(\"3.\") ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;\n}\n\n/**\n * @ignore\n * @param spec\n */\nexport function getSpecTypeFromSpec(spec: Partial<OpenSpec2 | OpenSpec3>) {\n return \"openapi\" in spec ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import { uniq } from "@tsed/core";
2
- import { SpecTypes } from "../domain/SpecTypes";
2
+ import { SpecTypes } from "../domain/SpecTypes.js";
3
3
  function hasNullable(obj) {
4
4
  return obj.oneOf.find((o) => o.type === "null");
5
5
  }
6
6
  export function mapNullableType(obj, schema, options) {
7
- if (!schema.isNullable) {
7
+ if (!(schema === null || schema === void 0 ? void 0 : schema.isNullable)) {
8
8
  return obj;
9
9
  }
10
10
  let types = [].concat(obj.type).filter(Boolean);
@@ -1 +1 @@
1
- {"version":3,"file":"mapNullableType.js","sourceRoot":"","sources":["../../../src/utils/mapNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAG9C,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAQ,EAAE,MAAkB,EAAE,OAA0B;IACtF,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;QACtB,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,KAAK,GAAa,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1D,QAAQ,OAAO,CAAC,QAAQ,EAAE;QACxB,QAAQ;QACR,KAAK,SAAS,CAAC,IAAI;YACjB,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;oBACrB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;wBAChB,IAAI,EAAE,MAAM;qBACb,CAAC,CAAC;iBACJ;aACF;iBAAM;gBACL,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;aACrC;YACD,MAAM;QAER,KAAK,SAAS,CAAC,OAAO;YACpB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;YAEpB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBACd,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBACpB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC;oBAC1C,OAAO,GAAG,CAAC,IAAI,CAAC;iBACjB;qBAAM;oBACL,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;iBACrB;aACF;YACD,MAAM;KACT;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction hasNullable(obj: any) {\n return obj.oneOf.find((o: any) => o.type === \"null\");\n}\n\nexport function mapNullableType(obj: any, schema: JsonSchema, options: JsonSchemaOptions) {\n if (!schema.isNullable) {\n return obj;\n }\n let types: string[] = [].concat(obj.type).filter(Boolean);\n\n switch (options.specType) {\n default:\n case SpecTypes.JSON:\n if (obj.oneOf) {\n if (!hasNullable(obj)) {\n obj.oneOf.unshift({\n type: \"null\"\n });\n }\n } else {\n obj.type = uniq([\"null\", ...types]);\n }\n break;\n\n case SpecTypes.OPENAPI:\n obj.nullable = true;\n\n if (!obj.oneOf) {\n if (types.length > 1) {\n obj.oneOf = types.map((type) => ({type}));\n delete obj.type;\n } else {\n obj.type = types[0];\n }\n }\n break;\n }\n\n return obj;\n}\n"]}
1
+ {"version":3,"file":"mapNullableType.js","sourceRoot":"","sources":["../../../src/utils/mapNullableType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAG9C,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAQ,EAAE,MAAyB,EAAE,OAA0B;IAC7F,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,EAAE;QACvB,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,KAAK,GAAa,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1D,QAAQ,OAAO,CAAC,QAAQ,EAAE;QACxB,QAAQ;QACR,KAAK,SAAS,CAAC,IAAI;YACjB,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;oBACrB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;wBAChB,IAAI,EAAE,MAAM;qBACb,CAAC,CAAC;iBACJ;aACF;iBAAM;gBACL,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;aACrC;YACD,MAAM;QAER,KAAK,SAAS,CAAC,OAAO;YACpB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;YAEpB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBACd,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBACpB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC;oBAC1C,OAAO,GAAG,CAAC,IAAI,CAAC;iBACjB;qBAAM;oBACL,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;iBACrB;aACF;YACD,MAAM;KACT;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction hasNullable(obj: any) {\n return obj.oneOf.find((o: any) => o.type === \"null\");\n}\n\nexport function mapNullableType(obj: any, schema: JsonSchema | null, options: JsonSchemaOptions) {\n if (!schema?.isNullable) {\n return obj;\n }\n let types: string[] = [].concat(obj.type).filter(Boolean);\n\n switch (options.specType) {\n default:\n case SpecTypes.JSON:\n if (obj.oneOf) {\n if (!hasNullable(obj)) {\n obj.oneOf.unshift({\n type: \"null\"\n });\n }\n } else {\n obj.type = uniq([\"null\", ...types]);\n }\n break;\n\n case SpecTypes.OPENAPI:\n obj.nullable = true;\n\n if (!obj.oneOf) {\n if (types.length > 1) {\n obj.oneOf = types.map((type) => ({type}));\n delete obj.type;\n } else {\n obj.type = types[0];\n }\n }\n break;\n }\n\n return obj;\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { getValue, setValue } from "@tsed/core";
2
+ import { getSpecType } from "./getSpecType.js";
3
+ import { mapOpenSpec2 } from "./mapOpenSpec2.js";
4
+ import { SpecTypes } from "../domain/SpecTypes.js";
5
+ import { mapOpenSpec3 } from "./mapOpenSpec3.js";
6
+ import { mergeSpec } from "./mergeSpec.js";
7
+ /**
8
+ * @ignore
9
+ * @param spec
10
+ * @param fileSpec
11
+ * @param version
12
+ * @param acceptMimes
13
+ * @param specVersion
14
+ */
15
+ export function mapOpenSpec(spec, { fileSpec, acceptMimes, specVersion, version }) {
16
+ specVersion = specVersion || getValue(spec, "openapi", getValue(spec, "swagger", "2.0"));
17
+ const options = {
18
+ specVersion,
19
+ acceptMimes
20
+ };
21
+ switch (getSpecType(specVersion)) {
22
+ case SpecTypes.OPENAPI:
23
+ spec = mapOpenSpec3(spec, options);
24
+ fileSpec = fileSpec ? mapOpenSpec3(fileSpec, options) : fileSpec;
25
+ break;
26
+ default:
27
+ case SpecTypes.SWAGGER:
28
+ spec = mapOpenSpec2(spec, options);
29
+ fileSpec = fileSpec ? mapOpenSpec2(fileSpec, options) : fileSpec;
30
+ break;
31
+ }
32
+ spec = mergeSpec(spec, fileSpec);
33
+ setValue(spec, "info.title", getValue(spec, "info.title", "Api documentation"));
34
+ setValue(spec, "info.version", getValue(spec, "info.version", version));
35
+ return spec;
36
+ }
37
+ //# sourceMappingURL=mapOpenSpec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapOpenSpec.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,IAAS,EAAE,EAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAM;IACvF,WAAW,GAAG,WAAW,IAAI,QAAQ,CAAmB,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAE3G,MAAM,OAAO,GAAG;QACd,WAAW;QACX,WAAW;KACZ,CAAC;IAEF,QAAQ,WAAW,CAAC,WAAW,CAAC,EAAE;QAChC,KAAK,SAAS,CAAC,OAAO;YACpB,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACnC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YACjE,MAAM;QACR,QAAQ;QACR,KAAK,SAAS,CAAC,OAAO;YACpB,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACnC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YACjE,MAAM;KACT;IAED,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEjC,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAChF,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;IAExE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {getValue, setValue} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3, OpenSpecVersions} from \"@tsed/openspec\";\nimport {getSpecType} from \"./getSpecType\";\nimport {mapOpenSpec2} from \"./mapOpenSpec2\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {mapOpenSpec3} from \"./mapOpenSpec3\";\nimport {mergeSpec} from \"./mergeSpec\";\n\n/**\n * @ignore\n * @param spec\n * @param fileSpec\n * @param version\n * @param acceptMimes\n * @param specVersion\n */\nexport function mapOpenSpec(spec: any, {fileSpec, acceptMimes, specVersion, version}: any): Partial<OpenSpec2 | OpenSpec3> {\n specVersion = specVersion || getValue<OpenSpecVersions>(spec, \"openapi\", getValue(spec, \"swagger\", \"2.0\"));\n\n const options = {\n specVersion,\n acceptMimes\n };\n\n switch (getSpecType(specVersion)) {\n case SpecTypes.OPENAPI:\n spec = mapOpenSpec3(spec, options);\n fileSpec = fileSpec ? mapOpenSpec3(fileSpec, options) : fileSpec;\n break;\n default:\n case SpecTypes.SWAGGER:\n spec = mapOpenSpec2(spec, options);\n fileSpec = fileSpec ? mapOpenSpec2(fileSpec, options) : fileSpec;\n break;\n }\n\n spec = mergeSpec(spec, fileSpec);\n\n setValue(spec, \"info.title\", getValue(spec, \"info.title\", \"Api documentation\"));\n setValue(spec, \"info.version\", getValue(spec, \"info.version\", version));\n\n return spec;\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import { getValue, uniq } from "@tsed/core";
2
+ import { mapOpenSpecInfo } from "./mapOpenSpecInfo.js";
3
+ /**
4
+ * @ignore
5
+ * @param spec
6
+ * @param version
7
+ * @param specVersion
8
+ * @param acceptMimes
9
+ */
10
+ export function mapOpenSpec2(spec, { version, specVersion, acceptMimes = ["application/json"] }) {
11
+ const { paths, security, tags, host, basePath, schemes, consumes = [], produces = ["application/json"], definitions, parameters, responses, securityDefinitions, externalDocs } = spec;
12
+ return {
13
+ swagger: specVersion,
14
+ consumes: uniq([...acceptMimes, ...consumes]),
15
+ produces: uniq([...produces]),
16
+ info: mapOpenSpecInfo(getValue(spec, "info", {})),
17
+ paths,
18
+ host,
19
+ basePath,
20
+ schemes,
21
+ definitions,
22
+ parameters,
23
+ responses,
24
+ security,
25
+ securityDefinitions,
26
+ tags,
27
+ externalDocs
28
+ };
29
+ }
30
+ //# sourceMappingURL=mapOpenSpec2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapOpenSpec2.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpec2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAwB,EACxB,EAAC,OAAO,EAAE,WAAW,EAAE,WAAW,GAAG,CAAC,kBAAkB,CAAC,EAAM;IAE/D,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,CAAC,kBAAkB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,YAAY,EACb,GAAG,IAAI,CAAC;IAET,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,QAAQ,EAAE,IAAI,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,QAAQ,CAAC,CAAC;QAC7C,QAAQ,EAAE,IAAI,CAAS,CAAC,GAAG,QAAQ,CAAC,CAAC;QACrC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACjD,KAAK;QACL,IAAI;QACJ,QAAQ;QACR,OAAO;QACP,WAAW;QACX,UAAU;QACV,SAAS;QACT,QAAQ;QACR,mBAAmB;QACnB,IAAI;QACJ,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import {getValue, uniq} from \"@tsed/core\";\nimport {OpenSpec2} from \"@tsed/openspec\";\nimport {mapOpenSpecInfo} from \"./mapOpenSpecInfo\";\n\n/**\n * @ignore\n * @param spec\n * @param version\n * @param specVersion\n * @param acceptMimes\n */\nexport function mapOpenSpec2(\n spec: Partial<OpenSpec2>,\n {version, specVersion, acceptMimes = [\"application/json\"]}: any\n): Partial<OpenSpec2> {\n const {\n paths,\n security,\n tags,\n host,\n basePath,\n schemes,\n consumes = [],\n produces = [\"application/json\"],\n definitions,\n parameters,\n responses,\n securityDefinitions,\n externalDocs\n } = spec;\n\n return {\n swagger: specVersion,\n consumes: uniq([...acceptMimes, ...consumes]),\n produces: uniq<string>([...produces]),\n info: mapOpenSpecInfo(getValue(spec, \"info\", {})),\n paths,\n host,\n basePath,\n schemes,\n definitions,\n parameters,\n responses,\n security,\n securityDefinitions,\n tags,\n externalDocs\n };\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { getValue } from "@tsed/core";
2
+ import { mapOpenSpecInfo } from "./mapOpenSpecInfo.js";
3
+ /**
4
+ * @ignore
5
+ * @param spec
6
+ * @param version
7
+ * @param specVersion
8
+ */
9
+ export function mapOpenSpec3(spec, { specVersion }) {
10
+ const { servers, paths, components, security, tags, externalDocs } = spec;
11
+ return {
12
+ openapi: specVersion,
13
+ info: mapOpenSpecInfo(getValue(spec, "info", {})),
14
+ servers,
15
+ paths,
16
+ components,
17
+ security,
18
+ tags,
19
+ externalDocs
20
+ };
21
+ }
22
+ //# sourceMappingURL=mapOpenSpec3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapOpenSpec3.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpec3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAS,EAAE,EAAC,WAAW,EAAM;IACxD,MAAM,EAAC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAC,GAAG,IAAI,CAAC;IAExE,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACjD,OAAO;QACP,KAAK;QACL,UAAU;QACV,QAAQ;QACR,IAAI;QACJ,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {OpenSpec3} from \"@tsed/openspec\";\nimport {mapOpenSpecInfo} from \"./mapOpenSpecInfo\";\n\n/**\n * @ignore\n * @param spec\n * @param version\n * @param specVersion\n */\nexport function mapOpenSpec3(spec: any, {specVersion}: any): Partial<OpenSpec3> {\n const {servers, paths, components, security, tags, externalDocs} = spec;\n\n return {\n openapi: specVersion,\n info: mapOpenSpecInfo(getValue(spec, \"info\", {})),\n servers,\n paths,\n components,\n security,\n tags,\n externalDocs\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { cleanObject } from "@tsed/core";
2
+ /**
3
+ * @ignore
4
+ * @param info
5
+ */
6
+ export function mapOpenSpecInfo(info) {
7
+ const { title, description, version, termsOfService, contact, license } = info;
8
+ return cleanObject({
9
+ version,
10
+ title,
11
+ description,
12
+ termsOfService,
13
+ contact,
14
+ license
15
+ });
16
+ }
17
+ //# sourceMappingURL=mapOpenSpecInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapOpenSpecInfo.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpecInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAGvC;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAA2B;IACzD,MAAM,EAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAC,GAAG,IAAI,CAAC;IAE7E,OAAO,WAAW,CAAC;QACjB,OAAO;QACP,KAAK;QACL,WAAW;QACX,cAAc;QACd,OAAO;QACP,OAAO;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport {OpenSpecInfo} from \"@tsed/openspec\";\n\n/**\n * @ignore\n * @param info\n */\nexport function mapOpenSpecInfo(info: Partial<OpenSpecInfo>): OpenSpecInfo {\n const {title, description, version, termsOfService, contact, license} = info;\n\n return cleanObject({\n version,\n title,\n description,\n termsOfService,\n contact,\n license\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { HTTP_METHODS } from "../constants/httpMethods";
1
+ import { HTTP_METHODS } from "../constants/httpMethods.js";
2
2
  export function mapRouteOptions(args) {
3
3
  let method = undefined;
4
4
  let path = undefined;
@@ -1,12 +1,13 @@
1
- import { SpecTypes } from "../domain/SpecTypes";
2
- import { concatParameters } from "./concatParameters";
3
- import { getJsonPathParameters } from "./getJsonPathParameters";
1
+ import { SpecTypes } from "../domain/SpecTypes.js";
2
+ import { concatParameters } from "./concatParameters.js";
3
+ import { getJsonPathParameters } from "./getJsonPathParameters.js";
4
4
  /**
5
5
  * @ignore
6
6
  */
7
7
  export function mergeOperation(obj, operation, { rootPath, specType, operationId, defaultTags, tags, path, method }) {
8
8
  const pathParameters = getJsonPathParameters(rootPath, path).map(({ path, parameters }) => {
9
9
  path = path ? path : "/";
10
+ // FIXME not on the right place
10
11
  if (specType === SpecTypes.OPENAPI) {
11
12
  parameters = parameters.map(({ type, ...param }) => {
12
13
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"mergeOperation.js","sourceRoot":"","sources":["../../../src/utils/mergeOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAe9D;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAQ,EACR,SAAc,EACd,EAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAwB;IAEzF,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,EAAE,IAAI,C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AI,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QAE5B,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC","sourcesContent":["import {SpecTypes} from \"../domain/SpecTypes\";\nimport {concatParameters} from \"./concatParameters\";\nimport {getJsonPathParameters} from \"./getJsonPathParameters\";\n\n/**\n * @ignore\n */\nexport interface MergeOperationOptions {\n rootPath: string;\n specType: SpecTypes;\n operationId: (path: string) => string | undefined;\n defaultTags: string[];\n tags: string[];\n path: string;\n method: string;\n}\n\n/**\n * @ignore\n */\nexport function mergeOperation(\n obj: any,\n operation: any,\n {rootPath, specType, operationId, defaultTags, tags, path, method}: MergeOperationOptions\n) {\n const pathParameters = getJsonPathParameters(rootPath, path).map(({path, parameters}) => {\n path = path ? path : \"/\";\n\n if (specType === SpecTypes.OPENAPI) {\n parameters = parameters.map(({type, ...param}) => {\n return {\n ...param,\n schema: {\n type\n }\n };\n });\n }\n\n return {path, parameters};\n });\n\n return pathParameters.reduce((obj, {path, parameters}) => {\n parameters = concatParameters(parameters, operation);\n path = path ? path : \"/\";\n\n const operationTags = operation.tags?.length ? operation.tags : [defaultTags];\n\n obj.paths[path] = {\n ...obj.paths[path],\n [method.toLowerCase()]: {\n operationId: operation.operationId || operationId(path),\n ...operation,\n tags: operationTags.map(({name}: any) => name),\n parameters\n }\n };\n\n tags.push(...operationTags);\n\n return obj;\n }, obj);\n}\n"]}
1
+ {"version":3,"file":"mergeOperation.js","sourceRoot":"","sources":["../../../src/utils/mergeOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAe9D;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAQ,EACR,SAAc,EACd,EAAC,QAAQ,EAAE,QAAQ,EAA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AS;gBACZ,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAM,EAAE,EAAE,CAAC,IAAI,CAAC;gBAC9C,UAAU;aACX;SACF,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QAE5B,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC","sourcesContent":["import {SpecTypes} from \"../domain/SpecTypes\";\nimport {concatParameters} from \"./concatParameters\";\nimport {getJsonPathParameters} from \"./getJsonPathParameters\";\n\n/**\n * @ignore\n */\nexport interface MergeOperationOptions {\n rootPath: string;\n specType: SpecTypes;\n operationId: (path: string) => string | undefined;\n defaultTags: string[];\n tags: string[];\n path: string;\n method: string;\n}\n\n/**\n * @ignore\n */\nexport function mergeOperation(\n obj: any,\n operation: any,\n {rootPath, specType, operationId, defaultTags, tags, path, method}: MergeOperationOptions\n) {\n const pathParameters = getJsonPathParameters(rootPath, path).map(({path, parameters}) => {\n path = path ? path : \"/\";\n\n // FIXME not on the right place\n if (specType === SpecTypes.OPENAPI) {\n parameters = parameters.map(({type, ...param}) => {\n return {\n ...param,\n schema: {\n type\n }\n };\n });\n }\n\n return {path, parameters};\n });\n\n return pathParameters.reduce((obj, {path, parameters}) => {\n parameters = concatParameters(parameters, operation);\n path = path ? path : \"/\";\n\n const operationTags = operation.tags?.length ? operation.tags : [defaultTags];\n\n obj.paths[path] = {\n ...obj.paths[path],\n [method.toLowerCase()]: {\n operationId: operation.operationId || operationId(path),\n ...operation,\n tags: operationTags.map(({name}: any) => name),\n parameters\n }\n };\n\n tags.push(...operationTags);\n\n return obj;\n }, obj);\n}\n"]}