@scalar/openapi-parser 0.10.16 → 0.10.17

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 (329) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/configuration/index.js +19 -22
  3. package/dist/configuration/index.js.map +7 -0
  4. package/dist/declarations.d.js +1 -0
  5. package/dist/declarations.d.js.map +7 -0
  6. package/dist/index.d.ts +4 -4
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +5 -29
  9. package/dist/index.js.map +7 -0
  10. package/dist/lib/Validator/Validator.d.ts +2 -2
  11. package/dist/lib/Validator/Validator.d.ts.map +1 -1
  12. package/dist/lib/Validator/Validator.js +99 -119
  13. package/dist/lib/Validator/Validator.js.map +7 -0
  14. package/dist/lib/Validator/Validator.test.js +8 -0
  15. package/dist/lib/Validator/Validator.test.js.map +7 -0
  16. package/dist/lib/Validator/index.d.ts +2 -2
  17. package/dist/lib/Validator/index.d.ts.map +1 -1
  18. package/dist/lib/Validator/index.js +3 -0
  19. package/dist/lib/Validator/index.js.map +7 -0
  20. package/dist/plugins/fetch-urls/fetchUrls.d.ts +1 -1
  21. package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +1 -1
  22. package/dist/plugins/fetch-urls/fetchUrls.js +36 -39
  23. package/dist/plugins/fetch-urls/fetchUrls.js.map +7 -0
  24. package/dist/plugins/fetch-urls/fetchUrls.test.js +50 -0
  25. package/dist/plugins/fetch-urls/fetchUrls.test.js.map +7 -0
  26. package/dist/plugins/fetch-urls/index.d.ts +1 -1
  27. package/dist/plugins/fetch-urls/index.d.ts.map +1 -1
  28. package/dist/plugins/fetch-urls/index.js +2 -1
  29. package/dist/plugins/fetch-urls/index.js.map +7 -0
  30. package/dist/plugins/read-files/index.d.ts +1 -1
  31. package/dist/plugins/read-files/index.d.ts.map +1 -1
  32. package/dist/plugins/read-files/index.js +2 -1
  33. package/dist/plugins/read-files/index.js.map +7 -0
  34. package/dist/plugins/read-files/readFiles.d.ts +1 -1
  35. package/dist/plugins/read-files/readFiles.d.ts.map +1 -1
  36. package/dist/plugins/read-files/readFiles.js +50 -55
  37. package/dist/plugins/read-files/readFiles.js.map +7 -0
  38. package/dist/plugins/read-files/readFiles.test.js +20 -0
  39. package/dist/plugins/read-files/readFiles.test.js.map +7 -0
  40. package/dist/polyfills/index.d.ts +1 -1
  41. package/dist/polyfills/index.d.ts.map +1 -1
  42. package/dist/polyfills/index.js +5 -0
  43. package/dist/polyfills/index.js.map +7 -0
  44. package/dist/polyfills/path.js +155 -98
  45. package/dist/polyfills/path.js.map +7 -0
  46. package/dist/schemas/v2.0/schema.d.ts +1405 -0
  47. package/dist/schemas/v2.0/schema.d.ts.map +1 -0
  48. package/dist/schemas/v2.0/schema.js +1463 -0
  49. package/dist/schemas/v2.0/schema.js.map +7 -0
  50. package/dist/schemas/v3.0/schema.d.ts +1264 -0
  51. package/dist/schemas/v3.0/schema.d.ts.map +1 -0
  52. package/dist/schemas/v3.0/schema.js +1493 -0
  53. package/dist/schemas/v3.0/schema.js.map +7 -0
  54. package/dist/schemas/v3.1/schema.d.ts +1225 -0
  55. package/dist/schemas/v3.1/schema.d.ts.map +1 -0
  56. package/dist/schemas/v3.1/schema.js +1296 -0
  57. package/dist/schemas/v3.1/schema.js.map +7 -0
  58. package/dist/types/index.d.ts +1 -1
  59. package/dist/types/index.d.ts.map +1 -1
  60. package/dist/types/index.js +1 -0
  61. package/dist/types/index.js.map +7 -0
  62. package/dist/utils/betterAjvErrors/helpers.js +88 -93
  63. package/dist/utils/betterAjvErrors/helpers.js.map +7 -0
  64. package/dist/utils/betterAjvErrors/index.js +14 -13
  65. package/dist/utils/betterAjvErrors/index.js.map +7 -0
  66. package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts +2 -0
  67. package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts.map +1 -0
  68. package/dist/utils/betterAjvErrors/json/get-meta-from-path.js +27 -0
  69. package/dist/utils/betterAjvErrors/json/get-meta-from-path.js.map +7 -0
  70. package/dist/utils/betterAjvErrors/json/index.d.ts +2 -0
  71. package/dist/utils/betterAjvErrors/json/index.d.ts.map +1 -0
  72. package/dist/utils/betterAjvErrors/json/index.js +5 -0
  73. package/dist/utils/betterAjvErrors/json/index.js.map +7 -0
  74. package/dist/utils/betterAjvErrors/json/utils.d.ts +2 -0
  75. package/dist/utils/betterAjvErrors/json/utils.d.ts.map +1 -0
  76. package/dist/utils/betterAjvErrors/json/utils.js +11 -0
  77. package/dist/utils/betterAjvErrors/json/utils.js.map +7 -0
  78. package/dist/utils/betterAjvErrors/utils.js +21 -14
  79. package/dist/utils/betterAjvErrors/utils.js.map +7 -0
  80. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts +10 -0
  81. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts.map +1 -0
  82. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js +8 -9
  83. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js.map +7 -0
  84. package/dist/utils/betterAjvErrors/validation-errors/base.d.ts +23 -0
  85. package/dist/utils/betterAjvErrors/validation-errors/base.d.ts.map +1 -0
  86. package/dist/utils/betterAjvErrors/validation-errors/base.js +6 -10
  87. package/dist/utils/betterAjvErrors/validation-errors/base.js.map +7 -0
  88. package/dist/utils/betterAjvErrors/validation-errors/default.d.ts +10 -0
  89. package/dist/utils/betterAjvErrors/validation-errors/default.d.ts.map +1 -0
  90. package/dist/utils/betterAjvErrors/validation-errors/default.js +8 -9
  91. package/dist/utils/betterAjvErrors/validation-errors/default.js.map +7 -0
  92. package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts +11 -0
  93. package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts.map +1 -0
  94. package/dist/utils/betterAjvErrors/validation-errors/enum.js +19 -29
  95. package/dist/utils/betterAjvErrors/validation-errors/enum.js.map +7 -0
  96. package/dist/utils/betterAjvErrors/validation-errors/index.d.ts +7 -0
  97. package/dist/utils/betterAjvErrors/validation-errors/index.d.ts.map +1 -0
  98. package/dist/utils/betterAjvErrors/validation-errors/index.js +15 -0
  99. package/dist/utils/betterAjvErrors/validation-errors/index.js.map +7 -0
  100. package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts +10 -0
  101. package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts.map +1 -0
  102. package/dist/utils/betterAjvErrors/validation-errors/pattern.js +8 -9
  103. package/dist/utils/betterAjvErrors/validation-errors/pattern.js.map +7 -0
  104. package/dist/utils/betterAjvErrors/validation-errors/required.d.ts +10 -0
  105. package/dist/utils/betterAjvErrors/validation-errors/required.d.ts.map +1 -0
  106. package/dist/utils/betterAjvErrors/validation-errors/required.js +8 -9
  107. package/dist/utils/betterAjvErrors/validation-errors/required.js.map +7 -0
  108. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts +10 -0
  109. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts.map +1 -0
  110. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +8 -9
  111. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js.map +7 -0
  112. package/dist/utils/dereference.d.ts +2 -2
  113. package/dist/utils/dereference.d.ts.map +1 -1
  114. package/dist/utils/dereference.js +17 -19
  115. package/dist/utils/dereference.js.map +7 -0
  116. package/dist/utils/dereference.test.js +300 -0
  117. package/dist/utils/dereference.test.js.map +7 -0
  118. package/dist/utils/details.d.ts +1 -1
  119. package/dist/utils/details.d.ts.map +1 -1
  120. package/dist/utils/details.js +26 -28
  121. package/dist/utils/details.js.map +7 -0
  122. package/dist/utils/errors.test.js +48 -0
  123. package/dist/utils/errors.test.js.map +7 -0
  124. package/dist/utils/escapeJsonPointer.js +5 -8
  125. package/dist/utils/escapeJsonPointer.js.map +7 -0
  126. package/dist/utils/escapeJsonPointer.test.js +11 -0
  127. package/dist/utils/escapeJsonPointer.test.js.map +7 -0
  128. package/dist/utils/filter.d.ts +1 -1
  129. package/dist/utils/filter.d.ts.map +1 -1
  130. package/dist/utils/filter.js +13 -15
  131. package/dist/utils/filter.js.map +7 -0
  132. package/dist/utils/getEntrypoint.d.ts +1 -1
  133. package/dist/utils/getEntrypoint.d.ts.map +1 -1
  134. package/dist/utils/getEntrypoint.js +5 -6
  135. package/dist/utils/getEntrypoint.js.map +7 -0
  136. package/dist/utils/getEntrypoint.test.js +18 -0
  137. package/dist/utils/getEntrypoint.test.js.map +7 -0
  138. package/dist/utils/getListOfReferences.d.ts +1 -1
  139. package/dist/utils/getListOfReferences.d.ts.map +1 -1
  140. package/dist/utils/getListOfReferences.js +15 -22
  141. package/dist/utils/getListOfReferences.js.map +7 -0
  142. package/dist/utils/getSegmentsFromPath.js +8 -15
  143. package/dist/utils/getSegmentsFromPath.js.map +7 -0
  144. package/dist/utils/getSegmentsFromPath.test.js +13 -0
  145. package/dist/utils/getSegmentsFromPath.test.js.map +7 -0
  146. package/dist/utils/index.d.ts +26 -26
  147. package/dist/utils/index.d.ts.map +1 -1
  148. package/dist/utils/index.js +27 -0
  149. package/dist/utils/index.js.map +7 -0
  150. package/dist/utils/isFilesystem.js +5 -9
  151. package/dist/utils/isFilesystem.js.map +7 -0
  152. package/dist/utils/isJson.js +10 -9
  153. package/dist/utils/isJson.js.map +7 -0
  154. package/dist/utils/isObject.js +5 -6
  155. package/dist/utils/isObject.js.map +7 -0
  156. package/dist/utils/isObject.test.js +23 -0
  157. package/dist/utils/isObject.test.js.map +7 -0
  158. package/dist/utils/isYaml.js +16 -17
  159. package/dist/utils/isYaml.js.map +7 -0
  160. package/dist/utils/load/index.d.ts +1 -1
  161. package/dist/utils/load/index.d.ts.map +1 -1
  162. package/dist/utils/load/index.js +2 -0
  163. package/dist/utils/load/index.js.map +7 -0
  164. package/dist/utils/load/load.d.ts +1 -1
  165. package/dist/utils/load/load.d.ts.map +1 -1
  166. package/dist/utils/load/load.js +89 -110
  167. package/dist/utils/load/load.js.map +7 -0
  168. package/dist/utils/load/load.test.js +361 -0
  169. package/dist/utils/load/load.test.js.map +7 -0
  170. package/dist/utils/makeFilesystem.d.ts +1 -1
  171. package/dist/utils/makeFilesystem.d.ts.map +1 -1
  172. package/dist/utils/makeFilesystem.js +20 -22
  173. package/dist/utils/makeFilesystem.js.map +7 -0
  174. package/dist/utils/makeFilesystem.test.js +15 -0
  175. package/dist/utils/makeFilesystem.test.js.map +7 -0
  176. package/dist/utils/normalize.d.ts +1 -1
  177. package/dist/utils/normalize.d.ts.map +1 -1
  178. package/dist/utils/normalize.js +22 -27
  179. package/dist/utils/normalize.js.map +7 -0
  180. package/dist/utils/normalize.test.js +88 -0
  181. package/dist/utils/normalize.test.js.map +7 -0
  182. package/dist/utils/openapi/actions/details.d.ts +2 -2
  183. package/dist/utils/openapi/actions/details.d.ts.map +1 -1
  184. package/dist/utils/openapi/actions/details.js +9 -11
  185. package/dist/utils/openapi/actions/details.js.map +7 -0
  186. package/dist/utils/openapi/actions/files.d.ts +1 -1
  187. package/dist/utils/openapi/actions/files.d.ts.map +1 -1
  188. package/dist/utils/openapi/actions/files.js +7 -9
  189. package/dist/utils/openapi/actions/files.js.map +7 -0
  190. package/dist/utils/openapi/actions/get.d.ts +1 -1
  191. package/dist/utils/openapi/actions/get.d.ts.map +1 -1
  192. package/dist/utils/openapi/actions/get.js +9 -11
  193. package/dist/utils/openapi/actions/get.js.map +7 -0
  194. package/dist/utils/openapi/actions/toJson.d.ts +1 -1
  195. package/dist/utils/openapi/actions/toJson.d.ts.map +1 -1
  196. package/dist/utils/openapi/actions/toJson.js +9 -11
  197. package/dist/utils/openapi/actions/toJson.js.map +7 -0
  198. package/dist/utils/openapi/actions/toYaml.d.ts +1 -1
  199. package/dist/utils/openapi/actions/toYaml.d.ts.map +1 -1
  200. package/dist/utils/openapi/actions/toYaml.js +9 -11
  201. package/dist/utils/openapi/actions/toYaml.js.map +7 -0
  202. package/dist/utils/openapi/commands/dereferenceCommand.d.ts +5 -5
  203. package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +1 -1
  204. package/dist/utils/openapi/commands/dereferenceCommand.js +25 -27
  205. package/dist/utils/openapi/commands/dereferenceCommand.js.map +7 -0
  206. package/dist/utils/openapi/commands/filterCommand.d.ts +9 -9
  207. package/dist/utils/openapi/commands/filterCommand.d.ts.map +1 -1
  208. package/dist/utils/openapi/commands/filterCommand.js +24 -26
  209. package/dist/utils/openapi/commands/filterCommand.js.map +7 -0
  210. package/dist/utils/openapi/commands/loadCommand.d.ts +994 -994
  211. package/dist/utils/openapi/commands/loadCommand.d.ts.map +1 -1
  212. package/dist/utils/openapi/commands/loadCommand.js +40 -42
  213. package/dist/utils/openapi/commands/loadCommand.js.map +7 -0
  214. package/dist/utils/openapi/commands/upgradeCommand.d.ts +311 -311
  215. package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +1 -1
  216. package/dist/utils/openapi/commands/upgradeCommand.js +27 -29
  217. package/dist/utils/openapi/commands/upgradeCommand.js.map +7 -0
  218. package/dist/utils/openapi/commands/validateCommand.d.ts +311 -311
  219. package/dist/utils/openapi/commands/validateCommand.d.ts.map +1 -1
  220. package/dist/utils/openapi/commands/validateCommand.js +31 -33
  221. package/dist/utils/openapi/commands/validateCommand.js.map +7 -0
  222. package/dist/utils/openapi/index.d.ts +1 -1
  223. package/dist/utils/openapi/index.d.ts.map +1 -1
  224. package/dist/utils/openapi/index.js +2 -0
  225. package/dist/utils/openapi/index.js.map +7 -0
  226. package/dist/utils/openapi/openapi.d.ts +700 -700
  227. package/dist/utils/openapi/openapi.d.ts.map +1 -1
  228. package/dist/utils/openapi/openapi.js +13 -16
  229. package/dist/utils/openapi/openapi.js.map +7 -0
  230. package/dist/utils/openapi/openapi.test-d.js +14 -0
  231. package/dist/utils/openapi/openapi.test-d.js.map +7 -0
  232. package/dist/utils/openapi/openapi.test.js +309 -0
  233. package/dist/utils/openapi/openapi.test.js.map +7 -0
  234. package/dist/utils/openapi/utils/queueTask.d.ts +1 -1
  235. package/dist/utils/openapi/utils/queueTask.d.ts.map +1 -1
  236. package/dist/utils/openapi/utils/queueTask.js +8 -9
  237. package/dist/utils/openapi/utils/queueTask.js.map +7 -0
  238. package/dist/utils/openapi/utils/workThroughQueue.d.ts +1 -1
  239. package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +1 -1
  240. package/dist/utils/openapi/utils/workThroughQueue.js +49 -64
  241. package/dist/utils/openapi/utils/workThroughQueue.js.map +7 -0
  242. package/dist/utils/openapi/utils/workThroughQueue.test.js +244 -0
  243. package/dist/utils/openapi/utils/workThroughQueue.test.js.map +7 -0
  244. package/dist/utils/resolveReferences.d.ts +1 -1
  245. package/dist/utils/resolveReferences.d.ts.map +1 -1
  246. package/dist/utils/resolveReferences.js +91 -139
  247. package/dist/utils/resolveReferences.js.map +7 -0
  248. package/dist/utils/resolveReferences.test.js +567 -0
  249. package/dist/utils/resolveReferences.test.js.map +7 -0
  250. package/dist/utils/toJson.d.ts +1 -1
  251. package/dist/utils/toJson.d.ts.map +1 -1
  252. package/dist/utils/toJson.js +4 -2
  253. package/dist/utils/toJson.js.map +7 -0
  254. package/dist/utils/toYaml.d.ts +1 -1
  255. package/dist/utils/toYaml.d.ts.map +1 -1
  256. package/dist/utils/toYaml.js +5 -4
  257. package/dist/utils/toYaml.js.map +7 -0
  258. package/dist/utils/transform/index.d.ts +1 -1
  259. package/dist/utils/transform/index.d.ts.map +1 -1
  260. package/dist/utils/transform/index.js +2 -0
  261. package/dist/utils/transform/index.js.map +7 -0
  262. package/dist/utils/transform/sanitize.d.ts +3 -3
  263. package/dist/utils/transform/sanitize.d.ts.map +1 -1
  264. package/dist/utils/transform/sanitize.js +22 -21
  265. package/dist/utils/transform/sanitize.js.map +7 -0
  266. package/dist/utils/transform/sanitize.test.js +148 -0
  267. package/dist/utils/transform/sanitize.test.js.map +7 -0
  268. package/dist/utils/transform/utils/addInfoObject.d.ts +1 -1
  269. package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
  270. package/dist/utils/transform/utils/addInfoObject.js +14 -10
  271. package/dist/utils/transform/utils/addInfoObject.js.map +7 -0
  272. package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts +1 -1
  273. package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts.map +1 -1
  274. package/dist/utils/transform/utils/addLatestOpenApiVersion.js +8 -5
  275. package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +7 -0
  276. package/dist/utils/transform/utils/addMissingTags.d.ts +1 -1
  277. package/dist/utils/transform/utils/addMissingTags.d.ts.map +1 -1
  278. package/dist/utils/transform/utils/addMissingTags.js +26 -27
  279. package/dist/utils/transform/utils/addMissingTags.js.map +7 -0
  280. package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts +1 -1
  281. package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts.map +1 -1
  282. package/dist/utils/transform/utils/normalizeSecuritySchemes.js +36 -40
  283. package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +7 -0
  284. package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts +1 -1
  285. package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts.map +1 -1
  286. package/dist/utils/transform/utils/rejectSwaggerDocuments.js +8 -6
  287. package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +7 -0
  288. package/dist/utils/transformErrors.d.ts +1 -1
  289. package/dist/utils/transformErrors.d.ts.map +1 -1
  290. package/dist/utils/transformErrors.js +18 -21
  291. package/dist/utils/transformErrors.js.map +7 -0
  292. package/dist/utils/transformErrors.test.js +17 -0
  293. package/dist/utils/transformErrors.test.js.map +7 -0
  294. package/dist/utils/traverse.d.ts +1 -1
  295. package/dist/utils/traverse.d.ts.map +1 -1
  296. package/dist/utils/traverse.js +19 -22
  297. package/dist/utils/traverse.js.map +7 -0
  298. package/dist/utils/traverse.test.js +68 -0
  299. package/dist/utils/traverse.test.js.map +7 -0
  300. package/dist/utils/unescapeJsonPointer.js +5 -9
  301. package/dist/utils/unescapeJsonPointer.js.map +7 -0
  302. package/dist/utils/unescapeJsonPointer.test.js +19 -0
  303. package/dist/utils/unescapeJsonPointer.test.js.map +7 -0
  304. package/dist/utils/upgrade.d.ts +1 -1
  305. package/dist/utils/upgrade.d.ts.map +1 -1
  306. package/dist/utils/upgrade.js +22 -22
  307. package/dist/utils/upgrade.js.map +7 -0
  308. package/dist/utils/upgrade.test-d.js +16 -0
  309. package/dist/utils/upgrade.test-d.js.map +7 -0
  310. package/dist/utils/upgrade.test.js +57 -0
  311. package/dist/utils/upgrade.test.js.map +7 -0
  312. package/dist/utils/upgradeFromThreeToThreeOne.js +114 -140
  313. package/dist/utils/upgradeFromThreeToThreeOne.js.map +7 -0
  314. package/dist/utils/upgradeFromThreeToThreeOne.test.js +462 -0
  315. package/dist/utils/upgradeFromThreeToThreeOne.test.js.map +7 -0
  316. package/dist/utils/upgradeFromTwoToThree.js +212 -219
  317. package/dist/utils/upgradeFromTwoToThree.js.map +7 -0
  318. package/dist/utils/upgradeFromTwoToThree.test.js +589 -0
  319. package/dist/utils/upgradeFromTwoToThree.test.js.map +7 -0
  320. package/dist/utils/validate.d.ts +1 -1
  321. package/dist/utils/validate.d.ts.map +1 -1
  322. package/dist/utils/validate.js +14 -16
  323. package/dist/utils/validate.js.map +7 -0
  324. package/dist/utils/validate.test.js +64 -0
  325. package/dist/utils/validate.test.js.map +7 -0
  326. package/package.json +6 -7
  327. package/dist/schemas/v2.0/schema.json.js +0 -1623
  328. package/dist/schemas/v3.0/schema.json.js +0 -1673
  329. package/dist/schemas/v3.1/schema.json.js +0 -1451
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/openapi-parser
2
2
 
3
+ ## 0.10.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 8c7bad8: chore: move build tooling to esbuild
8
+
3
9
  ## 0.10.16
4
10
 
5
11
  ### Patch Changes
@@ -1,27 +1,24 @@
1
- import Swagger20 from '../schemas/v2.0/schema.json.js';
2
- import OpenApi30 from '../schemas/v3.0/schema.json.js';
3
- import OpenApi31 from '../schemas/v3.1/schema.json.js';
4
-
5
- /**
6
- * A list of the supported OpenAPI specifications
7
- */
1
+ import Swagger20 from "../schemas/v2.0/schema.js";
2
+ import OpenApi30 from "../schemas/v3.0/schema.js";
3
+ import OpenApi31 from "../schemas/v3.1/schema.js";
8
4
  const OpenApiSpecifications = {
9
- '2.0': Swagger20,
10
- '3.0': OpenApi30,
11
- '3.1': OpenApi31,
5
+ "2.0": Swagger20,
6
+ "3.0": OpenApi30,
7
+ "3.1": OpenApi31
12
8
  };
13
9
  const OpenApiVersions = Object.keys(OpenApiSpecifications);
14
- /**
15
- * List of error messages used in the Validator
16
- */
17
10
  const ERRORS = {
18
- EMPTY_OR_INVALID: 'Can’t find JSON, YAML or filename in data',
19
- // URI_MUST_BE_STRING: 'uri parameter or $id attribute must be a string',
20
- OPENAPI_VERSION_NOT_SUPPORTED: 'Can’t find supported Swagger/OpenAPI version in specification, version must be a string.',
21
- INVALID_REFERENCE: 'Can’t resolve reference: %s',
22
- EXTERNAL_REFERENCE_NOT_FOUND: 'Can’t resolve external reference: %s',
23
- FILE_DOES_NOT_EXIST: 'File does not exist: %s',
24
- NO_CONTENT: 'No content found',
11
+ EMPTY_OR_INVALID: "Can\u2019t find JSON, YAML or filename in data",
12
+ // URI_MUST_BE_STRING: 'uri parameter or $id attribute must be a string',
13
+ OPENAPI_VERSION_NOT_SUPPORTED: "Can\u2019t find supported Swagger/OpenAPI version in specification, version must be a string.",
14
+ INVALID_REFERENCE: "Can\u2019t resolve reference: %s",
15
+ EXTERNAL_REFERENCE_NOT_FOUND: "Can\u2019t resolve external reference: %s",
16
+ FILE_DOES_NOT_EXIST: "File does not exist: %s",
17
+ NO_CONTENT: "No content found"
25
18
  };
26
-
27
- export { ERRORS, OpenApiSpecifications, OpenApiVersions };
19
+ export {
20
+ ERRORS,
21
+ OpenApiSpecifications,
22
+ OpenApiVersions
23
+ };
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/configuration/index.ts"],
4
+ "sourcesContent": ["import Swagger20 from '../schemas/v2.0/schema'\nimport OpenApi30 from '../schemas/v3.0/schema'\nimport OpenApi31 from '../schemas/v3.1/schema'\n\n/**\n * A list of the supported OpenAPI specifications\n */\nexport const OpenApiSpecifications = {\n '2.0': Swagger20,\n '3.0': OpenApi30,\n '3.1': OpenApi31,\n}\n\nexport type OpenApiVersion = keyof typeof OpenApiSpecifications\n\nexport const OpenApiVersions = Object.keys(OpenApiSpecifications) as OpenApiVersion[]\n\n/**\n * List of error messages used in the Validator\n */\nexport const ERRORS = {\n EMPTY_OR_INVALID: 'Can\u2019t find JSON, YAML or filename in data',\n // URI_MUST_BE_STRING: 'uri parameter or $id attribute must be a string',\n OPENAPI_VERSION_NOT_SUPPORTED:\n 'Can\u2019t find supported Swagger/OpenAPI version in specification, version must be a string.',\n INVALID_REFERENCE: 'Can\u2019t resolve reference: %s',\n EXTERNAL_REFERENCE_NOT_FOUND: 'Can\u2019t resolve external reference: %s',\n FILE_DOES_NOT_EXIST: 'File does not exist: %s',\n NO_CONTENT: 'No content found',\n} as const\n\nexport type ValidationError = keyof typeof ERRORS\n"],
5
+ "mappings": "AAAA,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,eAAe;AAKf,MAAM,wBAAwB;AAAA,EACnC,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;AAIO,MAAM,kBAAkB,OAAO,KAAK,qBAAqB;AAKzD,MAAM,SAAS;AAAA,EACpB,kBAAkB;AAAA;AAAA,EAElB,+BACE;AAAA,EACF,mBAAmB;AAAA,EACnB,8BAA8B;AAAA,EAC9B,qBAAqB;AAAA,EACrB,YAAY;AACd;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=declarations.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './configuration/index.ts';
2
- export * from './lib/Validator/index.ts';
3
- export * from './types/index.ts';
4
- export * from './utils/index.ts';
1
+ export * from './configuration/index.js';
2
+ export * from './lib/Validator/index.js';
3
+ export * from './types/index.js';
4
+ export * from './utils/index.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
package/dist/index.js CHANGED
@@ -1,29 +1,5 @@
1
- export { ERRORS, OpenApiSpecifications, OpenApiVersions } from './configuration/index.js';
2
- export { Validator, jsonSchemaVersions } from './lib/Validator/Validator.js';
3
- export { resolveReferences } from './utils/resolveReferences.js';
4
- export { dereference } from './utils/dereference.js';
5
- export { details } from './utils/details.js';
6
- export { escapeJsonPointer } from './utils/escapeJsonPointer.js';
7
- export { filter } from './utils/filter.js';
8
- export { getEntrypoint } from './utils/getEntrypoint.js';
9
- export { getListOfReferences } from './utils/getListOfReferences.js';
10
- export { getSegmentsFromPath } from './utils/getSegmentsFromPath.js';
11
- export { isFilesystem } from './utils/isFilesystem.js';
12
- export { isJson } from './utils/isJson.js';
13
- export { isObject } from './utils/isObject.js';
14
- export { isYaml } from './utils/isYaml.js';
15
- export { load } from './utils/load/load.js';
16
- export { normalize } from './utils/normalize.js';
17
- export { openapi } from './utils/openapi/openapi.js';
18
- export { toJson } from './utils/toJson.js';
19
- export { toYaml } from './utils/toYaml.js';
20
- export { transformErrors } from './utils/transformErrors.js';
21
- export { traverse } from './utils/traverse.js';
22
- export { unescapeJsonPointer } from './utils/unescapeJsonPointer.js';
23
- export { upgrade } from './utils/upgrade.js';
24
- export { isSchemaPath, upgradeFromThreeToThreeOne } from './utils/upgradeFromThreeToThreeOne.js';
25
- export { upgradeFromTwoToThree } from './utils/upgradeFromTwoToThree.js';
26
- export { validate } from './utils/validate.js';
27
- export { DEFAULT_OPENAPI_VERSION } from './utils/transform/utils/addLatestOpenApiVersion.js';
28
- export { DEFAULT_TITLE, DEFAULT_VERSION } from './utils/transform/utils/addInfoObject.js';
29
- export { sanitize } from './utils/transform/sanitize.js';
1
+ export * from "./configuration/index.js";
2
+ export * from "./lib/Validator/index.js";
3
+ export * from "./types/index.js";
4
+ export * from "./utils/index.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export * from './configuration/index'\nexport * from './lib/Validator/index'\nexport * from './types/index'\nexport * from './utils/index'\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  import Ajv04 from 'ajv-draft-04';
2
2
  import Ajv2020 from 'ajv/dist/2020.js';
3
- import { type OpenApiVersion } from '../../configuration/index.ts';
4
- import type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '../../types/index.ts';
3
+ import { type OpenApiVersion } from '../../configuration/index.js';
4
+ import type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '../../types/index.js';
5
5
  /**
6
6
  * Configure available JSON Schema versions
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/Validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,OAAO,MAAM,kBAAkB,CAAA;AAEtC,OAAO,EAAiC,KAAK,cAAc,EAAmB,MAAM,8BAA8B,CAAA;AAClH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAKrG;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;CAG9B,CAAA;AAED,qBAAa,SAAS;IACb,OAAO,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;IAErC,OAAc,iBAAiB,4BAAkB;IAGjD,SAAS,CAAC,aAAa,EAAE,MAAM,CAC7B,MAAM,EACN,CAAC,CAAC,aAAa,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG;QACxC,MAAM,EAAE,MAAM,CAAA;KACf,CACF,CAAK;IAEN,SAAS,CAAC,MAAM,EAAE,MAAM,CAAA;IAExB,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAA;IAEtC,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAE5B,aAAa,EAAE,SAAS,CAAA;IAE/B;;OAEG;IACG,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAoF7F;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc;CA+B9C"}
1
+ {"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/Validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,OAAO,MAAM,kBAAkB,CAAA;AAEtC,OAAO,EAAiC,KAAK,cAAc,EAAmB,MAAM,2BAA2B,CAAA;AAC/G,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAKlG;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;CAG9B,CAAA;AAED,qBAAa,SAAS;IACb,OAAO,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;IAErC,OAAc,iBAAiB,4BAAkB;IAGjD,SAAS,CAAC,aAAa,EAAE,MAAM,CAC7B,MAAM,EACN,CAAC,CAAC,aAAa,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG;QACxC,MAAM,EAAE,MAAM,CAAA;KACf,CACF,CAAK;IAEN,SAAS,CAAC,MAAM,EAAE,MAAM,CAAA;IAExB,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAA;IAEtC,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAE5B,aAAa,EAAE,SAAS,CAAA;IAE/B;;OAEG;IACG,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAoF7F;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc;CA8B9C"}
@@ -1,128 +1,108 @@
1
- import Ajv04 from 'ajv-draft-04';
2
- import addFormats from 'ajv-formats';
3
- import Ajv2020 from 'ajv/dist/2020.js';
4
- import { OpenApiVersions, ERRORS, OpenApiSpecifications } from '../../configuration/index.js';
5
- import { details } from '../../utils/details.js';
6
- import { resolveReferences } from '../../utils/resolveReferences.js';
7
- import { transformErrors } from '../../utils/transformErrors.js';
8
-
9
- /**
10
- * Configure available JSON Schema versions
11
- */
1
+ import Ajv04 from "ajv-draft-04";
2
+ import addFormats from "ajv-formats";
3
+ import Ajv2020 from "ajv/dist/2020.js";
4
+ import { ERRORS, OpenApiSpecifications, OpenApiVersions } from "../../configuration/index.js";
5
+ import { details as getOpenApiVersion } from "../../utils/details.js";
6
+ import { resolveReferences } from "../../utils/resolveReferences.js";
7
+ import { transformErrors } from "../../utils/transformErrors.js";
12
8
  const jsonSchemaVersions = {
13
- 'http://json-schema.org/draft-04/schema#': Ajv04,
14
- 'https://json-schema.org/draft/2020-12/schema': Ajv2020,
9
+ "http://json-schema.org/draft-04/schema#": Ajv04,
10
+ "https://json-schema.org/draft/2020-12/schema": Ajv2020
15
11
  };
16
12
  class Validator {
17
- version;
18
- static supportedVersions = OpenApiVersions;
19
- // Object with function *or* object { errors: string }
20
- ajvValidators = {};
21
- errors;
22
- specificationVersion;
23
- specificationType;
24
- specification;
25
- /**
26
- * Checks whether a specification is valid and all references can be resolved.
27
- */
28
- async validate(filesystem, options) {
29
- const entrypoint = filesystem.find((file) => file.isEntrypoint);
30
- const specification = entrypoint?.specification;
31
- // TODO: How does this work with a filesystem?
32
- this.specification = specification;
33
- // TODO: defaulting info.version to keep parser compatible with the previous one
34
- // we should bubble this error up and not throw on it
35
- if (this.specification?.info && !this.specification.info.version) {
36
- this.specification.info.version = '0.0.1';
13
+ version;
14
+ static supportedVersions = OpenApiVersions;
15
+ // Object with function *or* object { errors: string }
16
+ ajvValidators = {};
17
+ errors;
18
+ specificationVersion;
19
+ specificationType;
20
+ specification;
21
+ /**
22
+ * Checks whether a specification is valid and all references can be resolved.
23
+ */
24
+ async validate(filesystem, options) {
25
+ const entrypoint = filesystem.find((file) => file.isEntrypoint);
26
+ const specification = entrypoint?.specification;
27
+ this.specification = specification;
28
+ if (this.specification?.info && !this.specification.info.version) {
29
+ this.specification.info.version = "0.0.1";
30
+ }
31
+ try {
32
+ if (specification === void 0 || specification === null) {
33
+ if (options?.throwOnError) {
34
+ throw new Error(ERRORS.EMPTY_OR_INVALID);
37
35
  }
38
- try {
39
- // AnyObject is empty or invalid
40
- if (specification === undefined || specification === null) {
41
- if (options?.throwOnError) {
42
- throw new Error(ERRORS.EMPTY_OR_INVALID);
43
- }
44
- return {
45
- valid: false,
46
- errors: transformErrors(entrypoint, ERRORS.EMPTY_OR_INVALID),
47
- };
48
- }
49
- // Meta data about the specification
50
- const { version, specificationType, specificationVersion } = details(specification);
51
- this.version = version;
52
- this.specificationVersion = specificationVersion;
53
- this.specificationType = specificationType;
54
- // AnyObject is not supported
55
- if (!version) {
56
- if (options?.throwOnError) {
57
- throw new Error(ERRORS.OPENAPI_VERSION_NOT_SUPPORTED);
58
- }
59
- return {
60
- valid: false,
61
- errors: transformErrors(entrypoint, ERRORS.OPENAPI_VERSION_NOT_SUPPORTED),
62
- };
63
- }
64
- // Get the correct OpenAPI validator
65
- const validateSchema = await this.getAjvValidator(version);
66
- const schemaResult = validateSchema(specification);
67
- // Error handling
68
- if (validateSchema.errors) {
69
- if (validateSchema.errors.length > 0) {
70
- if (options?.throwOnError) {
71
- throw new Error(validateSchema.errors[0]);
72
- }
73
- return {
74
- valid: false,
75
- errors: transformErrors(entrypoint, validateSchema.errors),
76
- };
77
- }
78
- }
79
- // Check if the references are valid
80
- const resolvedReferences = resolveReferences(filesystem, options);
81
- return {
82
- valid: schemaResult && resolvedReferences.valid,
83
- errors: [...(schemaResult.errors ?? []), ...resolvedReferences.errors],
84
- schema: resolvedReferences.schema,
85
- };
36
+ return {
37
+ valid: false,
38
+ errors: transformErrors(entrypoint, ERRORS.EMPTY_OR_INVALID)
39
+ };
40
+ }
41
+ const { version, specificationType, specificationVersion } = getOpenApiVersion(specification);
42
+ this.version = version;
43
+ this.specificationVersion = specificationVersion;
44
+ this.specificationType = specificationType;
45
+ if (!version) {
46
+ if (options?.throwOnError) {
47
+ throw new Error(ERRORS.OPENAPI_VERSION_NOT_SUPPORTED);
86
48
  }
87
- catch (error) {
88
- // Something went horribly wrong!
89
- if (options?.throwOnError) {
90
- throw error;
91
- }
92
- return {
93
- valid: false,
94
- errors: transformErrors(entrypoint, error.message ?? error),
95
- };
49
+ return {
50
+ valid: false,
51
+ errors: transformErrors(entrypoint, ERRORS.OPENAPI_VERSION_NOT_SUPPORTED)
52
+ };
53
+ }
54
+ const validateSchema = await this.getAjvValidator(version);
55
+ const schemaResult = validateSchema(specification);
56
+ if (validateSchema.errors) {
57
+ if (validateSchema.errors.length > 0) {
58
+ if (options?.throwOnError) {
59
+ throw new Error(validateSchema.errors[0]);
60
+ }
61
+ return {
62
+ valid: false,
63
+ errors: transformErrors(entrypoint, validateSchema.errors)
64
+ };
96
65
  }
66
+ }
67
+ const resolvedReferences = resolveReferences(filesystem, options);
68
+ return {
69
+ valid: schemaResult && resolvedReferences.valid,
70
+ errors: [...schemaResult.errors ?? [], ...resolvedReferences.errors],
71
+ schema: resolvedReferences.schema
72
+ };
73
+ } catch (error) {
74
+ if (options?.throwOnError) {
75
+ throw error;
76
+ }
77
+ return {
78
+ valid: false,
79
+ errors: transformErrors(entrypoint, error.message ?? error)
80
+ };
97
81
  }
98
- /**
99
- * Ajv JSON schema validator
100
- */
101
- async getAjvValidator(version) {
102
- // Schema loaded already
103
- if (this.ajvValidators[version]) {
104
- return this.ajvValidators[version];
105
- }
106
- // Load OpenAPI Schema
107
- const schema = OpenApiSpecifications[version];
108
- // Load JSON Schema
109
- const AjvClass = jsonSchemaVersions[schema.$schema];
110
- // Get the correct Ajv validator
111
- const ajv = new AjvClass({
112
- // Ajv is a bit too strict in its strict validation of OpenAPI schemas.
113
- // Switch strict mode off.
114
- strict: false,
115
- });
116
- // Register formats
117
- // https://ajv.js.org/packages/ajv-formats.html#formats
118
- // @ts-expect-error ajv-formats is not well typed
119
- addFormats(ajv);
120
- // OpenAPI 3.1 uses media-range format
121
- if (version === '3.1') {
122
- ajv.addFormat('media-range', true);
123
- }
124
- return (this.ajvValidators[version] = ajv.compile(schema));
82
+ }
83
+ /**
84
+ * Ajv JSON schema validator
85
+ */
86
+ async getAjvValidator(version) {
87
+ if (this.ajvValidators[version]) {
88
+ return this.ajvValidators[version];
125
89
  }
90
+ const schema = OpenApiSpecifications[version];
91
+ const AjvClass = jsonSchemaVersions[schema.$schema];
92
+ const ajv = new AjvClass({
93
+ // Ajv is a bit too strict in its strict validation of OpenAPI schemas.
94
+ // Switch strict mode off.
95
+ strict: false
96
+ });
97
+ addFormats(ajv);
98
+ if (version === "3.1") {
99
+ ajv.addFormat("media-range", true);
100
+ }
101
+ return this.ajvValidators[version] = ajv.compile(schema);
102
+ }
126
103
  }
127
-
128
- export { Validator, jsonSchemaVersions };
104
+ export {
105
+ Validator,
106
+ jsonSchemaVersions
107
+ };
108
+ //# sourceMappingURL=Validator.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/Validator/Validator.ts"],
4
+ "sourcesContent": ["import Ajv04 from 'ajv-draft-04'\nimport addFormats from 'ajv-formats'\nimport Ajv2020 from 'ajv/dist/2020.js'\n\nimport { ERRORS, OpenApiSpecifications, type OpenApiVersion, OpenApiVersions } from '../../configuration/index'\nimport type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '../../types/index'\nimport { details as getOpenApiVersion } from '../../utils/details'\nimport { resolveReferences } from '../../utils/resolveReferences'\nimport { transformErrors } from '../../utils/transformErrors'\n\n/**\n * Configure available JSON Schema versions\n */\nexport const jsonSchemaVersions = {\n 'http://json-schema.org/draft-04/schema#': Ajv04,\n 'https://json-schema.org/draft/2020-12/schema': Ajv2020,\n}\n\nexport class Validator {\n public version: '2.0' | '3.0' | '3.1'\n\n public static supportedVersions = OpenApiVersions\n\n // Object with function *or* object { errors: string }\n protected ajvValidators: Record<\n string,\n ((specification: AnyObject) => boolean) & {\n errors: string\n }\n > = {}\n\n protected errors: string\n\n protected specificationVersion: string\n\n protected specificationType: string\n\n public specification: AnyObject\n\n /**\n * Checks whether a specification is valid and all references can be resolved.\n */\n async validate(filesystem: Filesystem, options?: ThrowOnErrorOption): Promise<ValidateResult> {\n const entrypoint = filesystem.find((file) => file.isEntrypoint)\n const specification = entrypoint?.specification\n\n // TODO: How does this work with a filesystem?\n this.specification = specification\n\n // TODO: defaulting info.version to keep parser compatible with the previous one\n // we should bubble this error up and not throw on it\n if (this.specification?.info && !this.specification.info.version) {\n this.specification.info.version = '0.0.1'\n }\n\n try {\n // AnyObject is empty or invalid\n if (specification === undefined || specification === null) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.EMPTY_OR_INVALID)\n }\n\n return {\n valid: false,\n errors: transformErrors(entrypoint, ERRORS.EMPTY_OR_INVALID),\n }\n }\n\n // Meta data about the specification\n const { version, specificationType, specificationVersion } = getOpenApiVersion(specification)\n\n this.version = version\n this.specificationVersion = specificationVersion\n this.specificationType = specificationType\n\n // AnyObject is not supported\n if (!version) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.OPENAPI_VERSION_NOT_SUPPORTED)\n }\n\n return {\n valid: false,\n errors: transformErrors(entrypoint, ERRORS.OPENAPI_VERSION_NOT_SUPPORTED),\n }\n }\n\n // Get the correct OpenAPI validator\n const validateSchema = await this.getAjvValidator(version)\n const schemaResult = validateSchema(specification)\n\n // Error handling\n if (validateSchema.errors) {\n if (validateSchema.errors.length > 0) {\n if (options?.throwOnError) {\n throw new Error(validateSchema.errors[0])\n }\n\n return {\n valid: false,\n errors: transformErrors(entrypoint, validateSchema.errors),\n }\n }\n }\n\n // Check if the references are valid\n const resolvedReferences = resolveReferences(filesystem, options)\n\n return {\n valid: schemaResult && resolvedReferences.valid,\n errors: [...(schemaResult.errors ?? []), ...resolvedReferences.errors],\n schema: resolvedReferences.schema,\n }\n } catch (error) {\n // Something went horribly wrong!\n if (options?.throwOnError) {\n throw error\n }\n\n return {\n valid: false,\n errors: transformErrors(entrypoint, error.message ?? error),\n }\n }\n }\n\n /**\n * Ajv JSON schema validator\n */\n async getAjvValidator(version: OpenApiVersion) {\n // Schema loaded already\n if (this.ajvValidators[version]) {\n return this.ajvValidators[version]\n }\n\n // Load OpenAPI Schema\n const schema = OpenApiSpecifications[version]\n\n // Load JSON Schema\n const AjvClass = jsonSchemaVersions[schema.$schema]\n\n // Get the correct Ajv validator\n const ajv = new AjvClass({\n // Ajv is a bit too strict in its strict validation of OpenAPI schemas.\n // Switch strict mode off.\n strict: false,\n })\n\n // Register formats\n // https://ajv.js.org/packages/ajv-formats.html#formats\n addFormats(ajv)\n\n // OpenAPI 3.1 uses media-range format\n if (version === '3.1') {\n ajv.addFormat('media-range', true)\n }\n\n return (this.ajvValidators[version] = ajv.compile(schema))\n }\n}\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,gBAAgB;AACvB,OAAO,aAAa;AAEpB,SAAS,QAAQ,uBAA4C,uBAAuB;AAEpF,SAAS,WAAW,yBAAyB;AAC7C,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAKzB,MAAM,qBAAqB;AAAA,EAChC,2CAA2C;AAAA,EAC3C,gDAAgD;AAClD;AAEO,MAAM,UAAU;AAAA,EACd;AAAA,EAEP,OAAc,oBAAoB;AAAA;AAAA,EAGxB,gBAKN,CAAC;AAAA,EAEK;AAAA,EAEA;AAAA,EAEA;AAAA,EAEH;AAAA;AAAA;AAAA;AAAA,EAKP,MAAM,SAAS,YAAwB,SAAuD;AAC5F,UAAM,aAAa,WAAW,KAAK,CAAC,SAAS,KAAK,YAAY;AAC9D,UAAM,gBAAgB,YAAY;AAGlC,SAAK,gBAAgB;AAIrB,QAAI,KAAK,eAAe,QAAQ,CAAC,KAAK,cAAc,KAAK,SAAS;AAChE,WAAK,cAAc,KAAK,UAAU;AAAA,IACpC;AAEA,QAAI;AAEF,UAAI,kBAAkB,UAAa,kBAAkB,MAAM;AACzD,YAAI,SAAS,cAAc;AACzB,gBAAM,IAAI,MAAM,OAAO,gBAAgB;AAAA,QACzC;AAEA,eAAO;AAAA,UACL,OAAO;AAAA,UACP,QAAQ,gBAAgB,YAAY,OAAO,gBAAgB;AAAA,QAC7D;AAAA,MACF;AAGA,YAAM,EAAE,SAAS,mBAAmB,qBAAqB,IAAI,kBAAkB,aAAa;AAE5F,WAAK,UAAU;AACf,WAAK,uBAAuB;AAC5B,WAAK,oBAAoB;AAGzB,UAAI,CAAC,SAAS;AACZ,YAAI,SAAS,cAAc;AACzB,gBAAM,IAAI,MAAM,OAAO,6BAA6B;AAAA,QACtD;AAEA,eAAO;AAAA,UACL,OAAO;AAAA,UACP,QAAQ,gBAAgB,YAAY,OAAO,6BAA6B;AAAA,QAC1E;AAAA,MACF;AAGA,YAAM,iBAAiB,MAAM,KAAK,gBAAgB,OAAO;AACzD,YAAM,eAAe,eAAe,aAAa;AAGjD,UAAI,eAAe,QAAQ;AACzB,YAAI,eAAe,OAAO,SAAS,GAAG;AACpC,cAAI,SAAS,cAAc;AACzB,kBAAM,IAAI,MAAM,eAAe,OAAO,CAAC,CAAC;AAAA,UAC1C;AAEA,iBAAO;AAAA,YACL,OAAO;AAAA,YACP,QAAQ,gBAAgB,YAAY,eAAe,MAAM;AAAA,UAC3D;AAAA,QACF;AAAA,MACF;AAGA,YAAM,qBAAqB,kBAAkB,YAAY,OAAO;AAEhE,aAAO;AAAA,QACL,OAAO,gBAAgB,mBAAmB;AAAA,QAC1C,QAAQ,CAAC,GAAI,aAAa,UAAU,CAAC,GAAI,GAAG,mBAAmB,MAAM;AAAA,QACrE,QAAQ,mBAAmB;AAAA,MAC7B;AAAA,IACF,SAAS,OAAO;AAEd,UAAI,SAAS,cAAc;AACzB,cAAM;AAAA,MACR;AAEA,aAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ,gBAAgB,YAAY,MAAM,WAAW,KAAK;AAAA,MAC5D;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,gBAAgB,SAAyB;AAE7C,QAAI,KAAK,cAAc,OAAO,GAAG;AAC/B,aAAO,KAAK,cAAc,OAAO;AAAA,IACnC;AAGA,UAAM,SAAS,sBAAsB,OAAO;AAG5C,UAAM,WAAW,mBAAmB,OAAO,OAAO;AAGlD,UAAM,MAAM,IAAI,SAAS;AAAA;AAAA;AAAA,MAGvB,QAAQ;AAAA,IACV,CAAC;AAID,eAAW,GAAG;AAGd,QAAI,YAAY,OAAO;AACrB,UAAI,UAAU,eAAe,IAAI;AAAA,IACnC;AAEA,WAAQ,KAAK,cAAc,OAAO,IAAI,IAAI,QAAQ,MAAM;AAAA,EAC1D;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { Validator } from "./Validator.js";
3
+ describe("Validator", () => {
4
+ it("returns all supported versions", () => {
5
+ expect(Validator.supportedVersions).toMatchObject(["2.0", "3.0", "3.1"]);
6
+ });
7
+ });
8
+ //# sourceMappingURL=Validator.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/Validator/Validator.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { Validator } from './Validator'\n\ndescribe('Validator', () => {\n it('returns all supported versions', () => {\n expect(Validator.supportedVersions).toMatchObject(['2.0', '3.0', '3.1'])\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,iBAAiB;AAE1B,SAAS,aAAa,MAAM;AAC1B,KAAG,kCAAkC,MAAM;AACzC,WAAO,UAAU,iBAAiB,EAAE,cAAc,CAAC,OAAO,OAAO,KAAK,CAAC;AAAA,EACzE,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -1,3 +1,3 @@
1
- export * from './Validator.ts';
2
- export * from '../../utils/resolveReferences.ts';
1
+ export * from './Validator.js';
2
+ export * from '../../utils/resolveReferences.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kCAAkC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,+BAA+B,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from "./Validator.js";
2
+ export * from "../../utils/resolveReferences.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/Validator/index.ts"],
4
+ "sourcesContent": ["export * from './Validator'\nexport * from '../../utils/resolveReferences'\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- import type { LoadPlugin } from '../../utils/load/load.ts';
1
+ import type { LoadPlugin } from '../../utils/load/load.js';
2
2
  export declare const fetchUrlsDefaultConfiguration: {
3
3
  limit: number;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"fetchUrls.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch-urls/fetchUrls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAO,MAAM,6BAA6B;;CAEzC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,CAAC,mBAAmB,CAAC,EAAE;IAC7C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC3C,KAAK,UA2CL,CAAA"}
1
+ {"version":3,"file":"fetchUrls.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch-urls/fetchUrls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,6BAA6B;;CAEzC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,CAAC,mBAAmB,CAAC,EAAE;IAC7C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC3C,KAAK,UA2CL,CAAA"}
@@ -1,43 +1,40 @@
1
1
  const fetchUrlsDefaultConfiguration = {
2
- limit: 20,
2
+ limit: 20
3
3
  };
4
4
  const fetchUrls = (customConfiguration) => {
5
- // State
6
- let numberOfRequests = 0;
7
- // Configuration
8
- const configuration = {
9
- ...fetchUrlsDefaultConfiguration,
10
- ...customConfiguration,
11
- };
12
- return {
13
- check(value) {
14
- // Not a string
15
- if (typeof value !== 'string') {
16
- return false;
17
- }
18
- // Not http/https
19
- if (!value.startsWith('http://') && !value.startsWith('https://')) {
20
- return false;
21
- }
22
- return true;
23
- },
24
- async get(value) {
25
- // Limit ht enumber of requests
26
- if (configuration?.limit !== false && numberOfRequests >= configuration?.limit) {
27
- console.warn(`[fetchUrls] Maximum number of requests reeached (${configuration?.limit}), skipping request`);
28
- return undefined;
29
- }
30
- try {
31
- numberOfRequests++;
32
- const response = await (configuration?.fetch ? configuration.fetch(value) : fetch(value));
33
- return await response.text();
34
- }
35
- catch (error) {
36
- console.error('[fetchUrls]', error.message, `(${value})`);
37
- return undefined;
38
- }
39
- },
40
- };
5
+ let numberOfRequests = 0;
6
+ const configuration = {
7
+ ...fetchUrlsDefaultConfiguration,
8
+ ...customConfiguration
9
+ };
10
+ return {
11
+ check(value) {
12
+ if (typeof value !== "string") {
13
+ return false;
14
+ }
15
+ if (!value.startsWith("http://") && !value.startsWith("https://")) {
16
+ return false;
17
+ }
18
+ return true;
19
+ },
20
+ async get(value) {
21
+ if (configuration?.limit !== false && numberOfRequests >= configuration?.limit) {
22
+ console.warn(`[fetchUrls] Maximum number of requests reeached (${configuration?.limit}), skipping request`);
23
+ return void 0;
24
+ }
25
+ try {
26
+ numberOfRequests++;
27
+ const response = await (configuration?.fetch ? configuration.fetch(value) : fetch(value));
28
+ return await response.text();
29
+ } catch (error) {
30
+ console.error("[fetchUrls]", error.message, `(${value})`);
31
+ return void 0;
32
+ }
33
+ }
34
+ };
41
35
  };
42
-
43
- export { fetchUrls, fetchUrlsDefaultConfiguration };
36
+ export {
37
+ fetchUrls,
38
+ fetchUrlsDefaultConfiguration
39
+ };
40
+ //# sourceMappingURL=fetchUrls.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/fetch-urls/fetchUrls.ts"],
4
+ "sourcesContent": ["import type { LoadPlugin } from '../../utils/load/load'\n\nexport const fetchUrlsDefaultConfiguration = {\n limit: 20,\n}\n\nexport const fetchUrls: (customConfiguration?: {\n /**\n * Limit the number of requests. Set to `false` to disable the limit.\n */\n limit?: number | false\n /**\n * Fetch function to use instead of the global fetch. Use this to intercept requests.\n */\n fetch?: (url: string) => Promise<Response>\n}) => LoadPlugin = (customConfiguration) => {\n // State\n let numberOfRequests = 0\n\n // Configuration\n const configuration = {\n ...fetchUrlsDefaultConfiguration,\n ...customConfiguration,\n }\n\n return {\n check(value?: any) {\n // Not a string\n if (typeof value !== 'string') {\n return false\n }\n\n // Not http/https\n if (!value.startsWith('http://') && !value.startsWith('https://')) {\n return false\n }\n\n return true\n },\n async get(value?: any) {\n // Limit ht enumber of requests\n if (configuration?.limit !== false && numberOfRequests >= configuration?.limit) {\n console.warn(`[fetchUrls] Maximum number of requests reeached (${configuration?.limit}), skipping request`)\n return undefined\n }\n\n try {\n numberOfRequests++\n\n const response = await (configuration?.fetch ? configuration.fetch(value) : fetch(value))\n\n return await response.text()\n } catch (error) {\n console.error('[fetchUrls]', error.message, `(${value})`)\n return undefined\n }\n },\n }\n}\n"],
5
+ "mappings": "AAEO,MAAM,gCAAgC;AAAA,EAC3C,OAAO;AACT;AAEO,MAAM,YASM,CAAC,wBAAwB;AAE1C,MAAI,mBAAmB;AAGvB,QAAM,gBAAgB;AAAA,IACpB,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,SAAO;AAAA,IACL,MAAM,OAAa;AAEjB,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAGA,UAAI,CAAC,MAAM,WAAW,SAAS,KAAK,CAAC,MAAM,WAAW,UAAU,GAAG;AACjE,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,IAAI,OAAa;AAErB,UAAI,eAAe,UAAU,SAAS,oBAAoB,eAAe,OAAO;AAC9E,gBAAQ,KAAK,oDAAoD,eAAe,KAAK,qBAAqB;AAC1G,eAAO;AAAA,MACT;AAEA,UAAI;AACF;AAEA,cAAM,WAAW,OAAO,eAAe,QAAQ,cAAc,MAAM,KAAK,IAAI,MAAM,KAAK;AAEvF,eAAO,MAAM,SAAS,KAAK;AAAA,MAC7B,SAAS,OAAO;AACd,gBAAQ,MAAM,eAAe,MAAM,SAAS,IAAI,KAAK,GAAG;AACxD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { fetchUrls } from "./fetchUrls.js";
3
+ global.fetch = vi.fn();
4
+ describe("fetchUrls", async () => {
5
+ beforeEach(() => {
6
+ global.fetch.mockReset();
7
+ });
8
+ it("returns true for an url", async () => {
9
+ expect(fetchUrls().check("http://example.com/specification/openapi.yaml")).toBe(true);
10
+ });
11
+ it("returns false for a filename", async () => {
12
+ expect(fetchUrls().check("openapi.yaml")).toBe(false);
13
+ });
14
+ it("returns false for a path", async () => {
15
+ expect(fetchUrls().check("specification/openapi.yaml")).toBe(false);
16
+ });
17
+ it("returns false for an object", async () => {
18
+ expect(fetchUrls().check({})).toBe(false);
19
+ });
20
+ it("returns false for undefinded", async () => {
21
+ expect(fetchUrls().check()).toBe(false);
22
+ });
23
+ it("fetches the URL", async () => {
24
+ fetch.mockImplementation(async (url) => ({
25
+ text: async () => {
26
+ if (url === "http://example.com/specification/openapi.yaml") {
27
+ return "OK";
28
+ }
29
+ throw new Error("Not found");
30
+ }
31
+ }));
32
+ expect(await fetchUrls().get("http://example.com/specification/openapi.yaml")).toBe("OK");
33
+ });
34
+ it("rewrites the URL", async () => {
35
+ fetch.mockImplementation(async (url) => ({
36
+ text: async () => {
37
+ if (url === "http://foobar.com/specification/openapi.yaml") {
38
+ return "OK";
39
+ }
40
+ throw new Error("Not found");
41
+ }
42
+ }));
43
+ expect(
44
+ await fetchUrls({
45
+ fetch: (url) => fetch(url.replace("example", "foobar"))
46
+ }).get("http://foobar.com/specification/openapi.yaml")
47
+ ).toBe("OK");
48
+ });
49
+ });
50
+ //# sourceMappingURL=fetchUrls.test.js.map