@scalar/openapi-parser 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/configuration/index.d.ts +2 -2
  3. package/dist/configuration/index.js +2 -2
  4. package/dist/configuration/index.js.map +1 -1
  5. package/dist/index.d.ts +17 -4
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +34 -4
  8. package/dist/index.js.map +2 -2
  9. package/dist/lib/Validator/Validator.d.ts.map +1 -1
  10. package/dist/lib/Validator/Validator.js +2 -2
  11. package/dist/lib/Validator/Validator.js.map +1 -1
  12. package/dist/lib/Validator/index.d.ts +1 -2
  13. package/dist/lib/Validator/index.d.ts.map +1 -1
  14. package/dist/lib/Validator/index.js +4 -2
  15. package/dist/lib/Validator/index.js.map +2 -2
  16. package/dist/plugins/fetch-urls/{fetchUrls.d.ts → fetch-urls.d.ts} +1 -1
  17. package/dist/plugins/fetch-urls/fetch-urls.d.ts.map +1 -0
  18. package/dist/plugins/fetch-urls/{fetchUrls.js → fetch-urls.js} +1 -1
  19. package/dist/plugins/fetch-urls/fetch-urls.js.map +7 -0
  20. package/dist/plugins/fetch-urls/index.d.ts +1 -1
  21. package/dist/plugins/fetch-urls/index.d.ts.map +1 -1
  22. package/dist/plugins/fetch-urls/index.js +5 -1
  23. package/dist/plugins/fetch-urls/index.js.map +2 -2
  24. package/dist/plugins/read-files/index.d.ts +1 -1
  25. package/dist/plugins/read-files/index.d.ts.map +1 -1
  26. package/dist/plugins/read-files/index.js +4 -1
  27. package/dist/plugins/read-files/index.js.map +2 -2
  28. package/dist/plugins/read-files/{readFiles.d.ts → read-files.d.ts} +1 -1
  29. package/dist/plugins/read-files/read-files.d.ts.map +1 -0
  30. package/dist/plugins/read-files/{readFiles.js → read-files.js} +3 -3
  31. package/dist/plugins/read-files/read-files.js.map +7 -0
  32. package/dist/polyfills/index.d.ts +1 -1
  33. package/dist/polyfills/index.d.ts.map +1 -1
  34. package/dist/polyfills/index.js +22 -2
  35. package/dist/polyfills/index.js.map +2 -2
  36. package/dist/types/index.d.ts.map +1 -1
  37. package/dist/utils/betterAjvErrors/validation-errors/base.js.map +1 -1
  38. package/dist/utils/dereference.d.ts +1 -1
  39. package/dist/utils/dereference.d.ts.map +1 -1
  40. package/dist/utils/dereference.js +3 -3
  41. package/dist/utils/dereference.js.map +1 -1
  42. package/dist/utils/details.d.ts +1 -2
  43. package/dist/utils/details.d.ts.map +1 -1
  44. package/dist/utils/details.js +12 -9
  45. package/dist/utils/details.js.map +2 -2
  46. package/dist/utils/{escapeJsonPointer.d.ts → escape-json-pointer.d.ts} +1 -1
  47. package/dist/utils/escape-json-pointer.d.ts.map +1 -0
  48. package/dist/utils/{escapeJsonPointer.js → escape-json-pointer.js} +1 -1
  49. package/dist/utils/{escapeJsonPointer.js.map → escape-json-pointer.js.map} +1 -1
  50. package/dist/utils/filter.d.ts.map +1 -1
  51. package/dist/utils/filter.js +2 -2
  52. package/dist/utils/filter.js.map +1 -1
  53. package/dist/utils/{getEntrypoint.d.ts → get-entrypoint.d.ts} +1 -1
  54. package/dist/utils/get-entrypoint.d.ts.map +1 -0
  55. package/dist/utils/{getEntrypoint.js → get-entrypoint.js} +1 -1
  56. package/dist/utils/get-entrypoint.js.map +7 -0
  57. package/dist/utils/{getListOfReferences.d.ts → get-list-of-references.d.ts} +1 -1
  58. package/dist/utils/get-list-of-references.d.ts.map +1 -0
  59. package/dist/utils/{getListOfReferences.js → get-list-of-references.js} +1 -1
  60. package/dist/utils/get-list-of-references.js.map +7 -0
  61. package/dist/utils/{getSegmentsFromPath.d.ts → get-segments-from-path.d.ts} +1 -1
  62. package/dist/utils/get-segments-from-path.d.ts.map +1 -0
  63. package/dist/utils/{getSegmentsFromPath.js → get-segments-from-path.js} +2 -2
  64. package/dist/utils/get-segments-from-path.js.map +7 -0
  65. package/dist/utils/{isFilesystem.d.ts → is-filesystem.d.ts} +1 -1
  66. package/dist/utils/is-filesystem.d.ts.map +1 -0
  67. package/dist/utils/{isFilesystem.js → is-filesystem.js} +1 -1
  68. package/dist/utils/is-filesystem.js.map +7 -0
  69. package/dist/utils/{isJson.d.ts → is-json.d.ts} +1 -1
  70. package/dist/utils/is-json.d.ts.map +1 -0
  71. package/dist/utils/{isJson.js → is-json.js} +1 -1
  72. package/dist/utils/{isJson.js.map → is-json.js.map} +1 -1
  73. package/dist/utils/{isObject.d.ts → is-object.d.ts} +1 -1
  74. package/dist/utils/is-object.d.ts.map +1 -0
  75. package/dist/utils/{isObject.js → is-object.js} +1 -1
  76. package/dist/utils/{isObject.js.map → is-object.js.map} +1 -1
  77. package/dist/utils/{isYaml.d.ts → is-yaml.d.ts} +1 -1
  78. package/dist/utils/is-yaml.d.ts.map +1 -0
  79. package/dist/utils/{isYaml.js → is-yaml.js} +1 -1
  80. package/dist/utils/{isYaml.js.map → is-yaml.js.map} +1 -1
  81. package/dist/utils/load/index.d.ts +1 -1
  82. package/dist/utils/load/index.d.ts.map +1 -1
  83. package/dist/utils/load/index.js +4 -1
  84. package/dist/utils/load/index.js.map +2 -2
  85. package/dist/utils/load/load.d.ts.map +1 -1
  86. package/dist/utils/load/load.js +4 -4
  87. package/dist/utils/load/load.js.map +1 -1
  88. package/dist/utils/{makeFilesystem.d.ts → make-filesystem.d.ts} +1 -1
  89. package/dist/utils/make-filesystem.d.ts.map +1 -0
  90. package/dist/utils/{makeFilesystem.js → make-filesystem.js} +3 -3
  91. package/dist/utils/make-filesystem.js.map +7 -0
  92. package/dist/utils/normalize.d.ts +1 -1
  93. package/dist/utils/normalize.d.ts.map +1 -1
  94. package/dist/utils/normalize.js +17 -12
  95. package/dist/utils/normalize.js.map +2 -2
  96. package/dist/utils/{resolveReferences.d.ts → resolve-references.d.ts} +1 -1
  97. package/dist/utils/resolve-references.d.ts.map +1 -0
  98. package/dist/utils/{resolveReferences.js → resolve-references.js} +15 -4
  99. package/dist/utils/resolve-references.js.map +7 -0
  100. package/dist/utils/{toJson.d.ts → to-json.d.ts} +1 -1
  101. package/dist/utils/to-json.d.ts.map +1 -0
  102. package/dist/utils/{toJson.js → to-json.js} +1 -1
  103. package/dist/utils/to-json.js.map +7 -0
  104. package/dist/utils/{toYaml.d.ts → to-yaml.d.ts} +1 -1
  105. package/dist/utils/to-yaml.d.ts.map +1 -0
  106. package/dist/utils/{toYaml.js → to-yaml.js} +1 -1
  107. package/dist/utils/{toYaml.js.map → to-yaml.js.map} +2 -2
  108. package/dist/utils/transform/sanitize.d.ts +2 -0
  109. package/dist/utils/transform/sanitize.d.ts.map +1 -1
  110. package/dist/utils/transform/sanitize.js.map +2 -2
  111. package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
  112. package/dist/utils/transform/utils/addInfoObject.js.map +1 -1
  113. package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts.map +1 -1
  114. package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +1 -1
  115. package/dist/utils/transform/utils/addMissingTags.d.ts.map +1 -1
  116. package/dist/utils/transform/utils/addMissingTags.js.map +1 -1
  117. package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts.map +1 -1
  118. package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +1 -1
  119. package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts.map +1 -1
  120. package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +1 -1
  121. package/dist/utils/{transformErrors.d.ts → transform-errors.d.ts} +1 -1
  122. package/dist/utils/transform-errors.d.ts.map +1 -0
  123. package/dist/utils/{transformErrors.js → transform-errors.js} +1 -1
  124. package/dist/utils/transform-errors.js.map +7 -0
  125. package/dist/utils/traverse.d.ts.map +1 -1
  126. package/dist/utils/traverse.js.map +1 -1
  127. package/dist/utils/{unescapeJsonPointer.d.ts → unescape-json-pointer.d.ts} +1 -1
  128. package/dist/utils/unescape-json-pointer.d.ts.map +1 -0
  129. package/dist/utils/{unescapeJsonPointer.js → unescape-json-pointer.js} +1 -1
  130. package/dist/utils/{unescapeJsonPointer.js.map → unescape-json-pointer.js.map} +1 -1
  131. package/dist/utils/{upgradeFromThreeToThreeOne.d.ts → upgrade-from-three-to-three-one.d.ts} +1 -1
  132. package/dist/utils/upgrade-from-three-to-three-one.d.ts.map +1 -0
  133. package/dist/utils/{upgradeFromThreeToThreeOne.js → upgrade-from-three-to-three-one.js} +1 -2
  134. package/dist/utils/upgrade-from-three-to-three-one.js.map +7 -0
  135. package/dist/utils/{upgradeFromTwoToThree.d.ts → upgrade-from-two-to-three.d.ts} +1 -1
  136. package/dist/utils/upgrade-from-two-to-three.d.ts.map +1 -0
  137. package/dist/utils/{upgradeFromTwoToThree.js → upgrade-from-two-to-three.js} +1 -1
  138. package/dist/utils/{upgradeFromTwoToThree.js.map → upgrade-from-two-to-three.js.map} +1 -1
  139. package/dist/utils/upgrade.bench.js +1 -1
  140. package/dist/utils/upgrade.bench.js.map +1 -1
  141. package/dist/utils/upgrade.d.ts.map +1 -1
  142. package/dist/utils/upgrade.js +4 -4
  143. package/dist/utils/upgrade.js.map +1 -1
  144. package/dist/utils/validate.d.ts.map +1 -1
  145. package/dist/utils/validate.js +1 -1
  146. package/dist/utils/validate.js.map +1 -1
  147. package/package.json +3 -3
  148. package/dist/lib/Validator/Validator.test.js +0 -8
  149. package/dist/lib/Validator/Validator.test.js.map +0 -7
  150. package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +0 -1
  151. package/dist/plugins/fetch-urls/fetchUrls.js.map +0 -7
  152. package/dist/plugins/fetch-urls/fetchUrls.test.js +0 -50
  153. package/dist/plugins/fetch-urls/fetchUrls.test.js.map +0 -7
  154. package/dist/plugins/read-files/readFiles.d.ts.map +0 -1
  155. package/dist/plugins/read-files/readFiles.js.map +0 -7
  156. package/dist/plugins/read-files/readFiles.test.js +0 -20
  157. package/dist/plugins/read-files/readFiles.test.js.map +0 -7
  158. package/dist/utils/dereference.test.js +0 -300
  159. package/dist/utils/dereference.test.js.map +0 -7
  160. package/dist/utils/errors.test.js +0 -48
  161. package/dist/utils/errors.test.js.map +0 -7
  162. package/dist/utils/escapeJsonPointer.d.ts.map +0 -1
  163. package/dist/utils/escapeJsonPointer.test.js +0 -11
  164. package/dist/utils/escapeJsonPointer.test.js.map +0 -7
  165. package/dist/utils/getEntrypoint.d.ts.map +0 -1
  166. package/dist/utils/getEntrypoint.js.map +0 -7
  167. package/dist/utils/getEntrypoint.test.js +0 -18
  168. package/dist/utils/getEntrypoint.test.js.map +0 -7
  169. package/dist/utils/getListOfReferences.d.ts.map +0 -1
  170. package/dist/utils/getListOfReferences.js.map +0 -7
  171. package/dist/utils/getSegmentsFromPath.d.ts.map +0 -1
  172. package/dist/utils/getSegmentsFromPath.js.map +0 -7
  173. package/dist/utils/getSegmentsFromPath.test.js +0 -13
  174. package/dist/utils/getSegmentsFromPath.test.js.map +0 -7
  175. package/dist/utils/index.d.ts +0 -27
  176. package/dist/utils/index.d.ts.map +0 -1
  177. package/dist/utils/index.js +0 -27
  178. package/dist/utils/index.js.map +0 -7
  179. package/dist/utils/isFilesystem.d.ts.map +0 -1
  180. package/dist/utils/isFilesystem.js.map +0 -7
  181. package/dist/utils/isJson.d.ts.map +0 -1
  182. package/dist/utils/isObject.d.ts.map +0 -1
  183. package/dist/utils/isObject.test.js +0 -23
  184. package/dist/utils/isObject.test.js.map +0 -7
  185. package/dist/utils/isYaml.d.ts.map +0 -1
  186. package/dist/utils/load/load.test.js +0 -361
  187. package/dist/utils/load/load.test.js.map +0 -7
  188. package/dist/utils/makeFilesystem.d.ts.map +0 -1
  189. package/dist/utils/makeFilesystem.js.map +0 -7
  190. package/dist/utils/makeFilesystem.test.js +0 -15
  191. package/dist/utils/makeFilesystem.test.js.map +0 -7
  192. package/dist/utils/normalize.test.js +0 -88
  193. package/dist/utils/normalize.test.js.map +0 -7
  194. package/dist/utils/openapi/actions/details.d.ts +0 -7
  195. package/dist/utils/openapi/actions/details.d.ts.map +0 -1
  196. package/dist/utils/openapi/actions/details.js +0 -11
  197. package/dist/utils/openapi/actions/details.js.map +0 -7
  198. package/dist/utils/openapi/actions/files.d.ts +0 -6
  199. package/dist/utils/openapi/actions/files.d.ts.map +0 -1
  200. package/dist/utils/openapi/actions/files.js +0 -9
  201. package/dist/utils/openapi/actions/files.js.map +0 -7
  202. package/dist/utils/openapi/actions/get.d.ts +0 -6
  203. package/dist/utils/openapi/actions/get.d.ts.map +0 -1
  204. package/dist/utils/openapi/actions/get.js +0 -11
  205. package/dist/utils/openapi/actions/get.js.map +0 -7
  206. package/dist/utils/openapi/actions/toJson.d.ts +0 -6
  207. package/dist/utils/openapi/actions/toJson.d.ts.map +0 -1
  208. package/dist/utils/openapi/actions/toJson.js +0 -11
  209. package/dist/utils/openapi/actions/toJson.js.map +0 -7
  210. package/dist/utils/openapi/actions/toYaml.d.ts +0 -6
  211. package/dist/utils/openapi/actions/toYaml.d.ts.map +0 -1
  212. package/dist/utils/openapi/actions/toYaml.js +0 -11
  213. package/dist/utils/openapi/actions/toYaml.js.map +0 -7
  214. package/dist/utils/openapi/commands/dereferenceCommand.d.ts +0 -27
  215. package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +0 -1
  216. package/dist/utils/openapi/commands/dereferenceCommand.js +0 -27
  217. package/dist/utils/openapi/commands/dereferenceCommand.js.map +0 -7
  218. package/dist/utils/openapi/commands/filterCommand.d.ts +0 -41
  219. package/dist/utils/openapi/commands/filterCommand.d.ts.map +0 -1
  220. package/dist/utils/openapi/commands/filterCommand.js +0 -26
  221. package/dist/utils/openapi/commands/filterCommand.js.map +0 -7
  222. package/dist/utils/openapi/commands/loadCommand.d.ts +0 -8321
  223. package/dist/utils/openapi/commands/loadCommand.d.ts.map +0 -1
  224. package/dist/utils/openapi/commands/loadCommand.js +0 -42
  225. package/dist/utils/openapi/commands/loadCommand.js.map +0 -7
  226. package/dist/utils/openapi/commands/upgradeCommand.d.ts +0 -3406
  227. package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +0 -1
  228. package/dist/utils/openapi/commands/upgradeCommand.js +0 -29
  229. package/dist/utils/openapi/commands/upgradeCommand.js.map +0 -7
  230. package/dist/utils/openapi/commands/validateCommand.d.ts +0 -3451
  231. package/dist/utils/openapi/commands/validateCommand.d.ts.map +0 -1
  232. package/dist/utils/openapi/commands/validateCommand.js +0 -33
  233. package/dist/utils/openapi/commands/validateCommand.js.map +0 -7
  234. package/dist/utils/openapi/index.d.ts +0 -2
  235. package/dist/utils/openapi/index.d.ts.map +0 -1
  236. package/dist/utils/openapi/index.js +0 -2
  237. package/dist/utils/openapi/index.js.map +0 -7
  238. package/dist/utils/openapi/openapi.d.ts +0 -1272
  239. package/dist/utils/openapi/openapi.d.ts.map +0 -1
  240. package/dist/utils/openapi/openapi.js +0 -15
  241. package/dist/utils/openapi/openapi.js.map +0 -7
  242. package/dist/utils/openapi/openapi.test-d.d.ts +0 -2
  243. package/dist/utils/openapi/openapi.test-d.d.ts.map +0 -1
  244. package/dist/utils/openapi/openapi.test-d.js +0 -14
  245. package/dist/utils/openapi/openapi.test-d.js.map +0 -7
  246. package/dist/utils/openapi/openapi.test.js +0 -309
  247. package/dist/utils/openapi/openapi.test.js.map +0 -7
  248. package/dist/utils/openapi/utils/queueTask.d.ts +0 -6
  249. package/dist/utils/openapi/utils/queueTask.d.ts.map +0 -1
  250. package/dist/utils/openapi/utils/queueTask.js +0 -10
  251. package/dist/utils/openapi/utils/queueTask.js.map +0 -7
  252. package/dist/utils/openapi/utils/workThroughQueue.d.ts +0 -6
  253. package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +0 -1
  254. package/dist/utils/openapi/utils/workThroughQueue.js +0 -52
  255. package/dist/utils/openapi/utils/workThroughQueue.js.map +0 -7
  256. package/dist/utils/openapi/utils/workThroughQueue.test.js +0 -244
  257. package/dist/utils/openapi/utils/workThroughQueue.test.js.map +0 -7
  258. package/dist/utils/resolveReferences.d.ts.map +0 -1
  259. package/dist/utils/resolveReferences.js.map +0 -7
  260. package/dist/utils/resolveReferences.test.js +0 -567
  261. package/dist/utils/resolveReferences.test.js.map +0 -7
  262. package/dist/utils/toJson.d.ts.map +0 -1
  263. package/dist/utils/toJson.js.map +0 -7
  264. package/dist/utils/toYaml.d.ts.map +0 -1
  265. package/dist/utils/transform/index.d.ts +0 -2
  266. package/dist/utils/transform/index.d.ts.map +0 -1
  267. package/dist/utils/transform/index.js +0 -2
  268. package/dist/utils/transform/index.js.map +0 -7
  269. package/dist/utils/transform/sanitize.test.js +0 -148
  270. package/dist/utils/transform/sanitize.test.js.map +0 -7
  271. package/dist/utils/transformErrors.d.ts.map +0 -1
  272. package/dist/utils/transformErrors.js.map +0 -7
  273. package/dist/utils/transformErrors.test.js +0 -17
  274. package/dist/utils/transformErrors.test.js.map +0 -7
  275. package/dist/utils/traverse.test.js +0 -68
  276. package/dist/utils/traverse.test.js.map +0 -7
  277. package/dist/utils/unescapeJsonPointer.d.ts.map +0 -1
  278. package/dist/utils/unescapeJsonPointer.test.js +0 -19
  279. package/dist/utils/unescapeJsonPointer.test.js.map +0 -7
  280. package/dist/utils/upgrade.test.js +0 -57
  281. package/dist/utils/upgrade.test.js.map +0 -7
  282. package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +0 -1
  283. package/dist/utils/upgradeFromThreeToThreeOne.js.map +0 -7
  284. package/dist/utils/upgradeFromThreeToThreeOne.test.js +0 -462
  285. package/dist/utils/upgradeFromThreeToThreeOne.test.js.map +0 -7
  286. package/dist/utils/upgradeFromTwoToThree.d.ts.map +0 -1
  287. package/dist/utils/upgradeFromTwoToThree.test.js +0 -589
  288. package/dist/utils/upgradeFromTwoToThree.test.js.map +0 -7
  289. package/dist/utils/validate.test.js +0 -64
  290. package/dist/utils/validate.test.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/transform/utils/addInfoObject.ts"],
4
- "sourcesContent": ["import type { AnyObject } from '../../../types/index'\n\nexport const DEFAULT_TITLE = 'API'\nexport const DEFAULT_VERSION = '1.0'\n\nexport const addInfoObject = (definition: AnyObject) => ({\n ...definition,\n info: {\n ...definition.info,\n title: definition.info?.title ?? DEFAULT_TITLE,\n version: definition.info?.version ?? DEFAULT_VERSION,\n },\n})\n"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const DEFAULT_TITLE = 'API'\nexport const DEFAULT_VERSION = '1.0'\n\nexport const addInfoObject = (definition: AnyObject) => ({\n ...definition,\n info: {\n ...definition.info,\n title: definition.info?.title ?? DEFAULT_TITLE,\n version: definition.info?.version ?? DEFAULT_VERSION,\n },\n})\n"],
5
5
  "mappings": "AAEO,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAExB,MAAM,gBAAgB,CAAC,gBAA2B;AAAA,EACvD,GAAG;AAAA,EACH,MAAM;AAAA,IACJ,GAAG,WAAW;AAAA,IACd,OAAO,WAAW,MAAM,SAAS;AAAA,IACjC,SAAS,WAAW,MAAM,WAAW;AAAA,EACvC;AACF;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"addLatestOpenApiVersion.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/addLatestOpenApiVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAErD,eAAO,MAAM,uBAAuB,UAAU,CAAA;AAE9C,eAAO,MAAM,uBAAuB,eAAgB,SAAS;;CAG3D,CAAA"}
1
+ {"version":3,"file":"addLatestOpenApiVersion.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/addLatestOpenApiVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,uBAAuB,UAAU,CAAA;AAE9C,eAAO,MAAM,uBAAuB,eAAgB,SAAS;;CAG3D,CAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/transform/utils/addLatestOpenApiVersion.ts"],
4
- "sourcesContent": ["import type { AnyObject } from '../../../types/index'\n\nexport const DEFAULT_OPENAPI_VERSION = '3.1.1'\n\nexport const addLatestOpenApiVersion = (definition: AnyObject) => ({\n openapi: definition.openapi ?? DEFAULT_OPENAPI_VERSION,\n ...definition,\n})\n"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const DEFAULT_OPENAPI_VERSION = '3.1.1'\n\nexport const addLatestOpenApiVersion = (definition: AnyObject) => ({\n openapi: definition.openapi ?? DEFAULT_OPENAPI_VERSION,\n ...definition,\n})\n"],
5
5
  "mappings": "AAEO,MAAM,0BAA0B;AAEhC,MAAM,0BAA0B,CAAC,gBAA2B;AAAA,EACjE,SAAS,WAAW,WAAW;AAAA,EAC/B,GAAG;AACL;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"addMissingTags.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/addMissingTags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAErD,eAAO,MAAM,cAAc,eAAgB,SAAS,cAmCnD,CAAA"}
1
+ {"version":3,"file":"addMissingTags.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/addMissingTags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,cAAc,eAAgB,SAAS,cAmCnD,CAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/transform/utils/addMissingTags.ts"],
4
- "sourcesContent": ["import type { AnyObject } from '../../../types/index'\n\nexport const addMissingTags = (definition: AnyObject) => {\n if (!definition.paths) {\n return definition\n }\n\n // Collect all unique tags used in operations\n const usedTags = new Set<string>()\n for (const path of Object.values(definition.paths)) {\n if (typeof path === 'object' && path !== null) {\n for (const operation of Object.values(path)) {\n if (typeof operation === 'object' && operation !== null && 'tags' in operation) {\n const tags = operation.tags\n\n if (Array.isArray(tags)) {\n tags.forEach((tag) => usedTags.add(String(tag)))\n }\n }\n }\n }\n }\n\n // Convert tags to array of tag objects if not already present\n const existingTags = new Set(\n (Array.isArray(definition.tags) ? definition.tags : [])\n .map((tag) => (typeof tag === 'object' && tag !== null ? String(tag.name) : null))\n .filter(Boolean),\n )\n\n // Add missing tags\n const missingTags = [...usedTags].filter((tag) => !existingTags.has(tag)).map((name) => ({ name }))\n\n return {\n ...definition,\n tags: [...(Array.isArray(definition.tags) ? definition.tags : []), ...missingTags],\n }\n}\n"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const addMissingTags = (definition: AnyObject) => {\n if (!definition.paths) {\n return definition\n }\n\n // Collect all unique tags used in operations\n const usedTags = new Set<string>()\n for (const path of Object.values(definition.paths)) {\n if (typeof path === 'object' && path !== null) {\n for (const operation of Object.values(path)) {\n if (typeof operation === 'object' && operation !== null && 'tags' in operation) {\n const tags = operation.tags\n\n if (Array.isArray(tags)) {\n tags.forEach((tag) => usedTags.add(String(tag)))\n }\n }\n }\n }\n }\n\n // Convert tags to array of tag objects if not already present\n const existingTags = new Set(\n (Array.isArray(definition.tags) ? definition.tags : [])\n .map((tag) => (typeof tag === 'object' && tag !== null ? String(tag.name) : null))\n .filter(Boolean),\n )\n\n // Add missing tags\n const missingTags = [...usedTags].filter((tag) => !existingTags.has(tag)).map((name) => ({ name }))\n\n return {\n ...definition,\n tags: [...(Array.isArray(definition.tags) ? definition.tags : []), ...missingTags],\n }\n}\n"],
5
5
  "mappings": "AAEO,MAAM,iBAAiB,CAAC,eAA0B;AACvD,MAAI,CAAC,WAAW,OAAO;AACrB,WAAO;AAAA,EACT;AAGA,QAAM,WAAW,oBAAI,IAAY;AACjC,aAAW,QAAQ,OAAO,OAAO,WAAW,KAAK,GAAG;AAClD,QAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAC7C,iBAAW,aAAa,OAAO,OAAO,IAAI,GAAG;AAC3C,YAAI,OAAO,cAAc,YAAY,cAAc,QAAQ,UAAU,WAAW;AAC9E,gBAAM,OAAO,UAAU;AAEvB,cAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,iBAAK,QAAQ,CAAC,QAAQ,SAAS,IAAI,OAAO,GAAG,CAAC,CAAC;AAAA,UACjD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,QAAM,eAAe,IAAI;AAAA,KACtB,MAAM,QAAQ,WAAW,IAAI,IAAI,WAAW,OAAO,CAAC,GAClD,IAAI,CAAC,QAAS,OAAO,QAAQ,YAAY,QAAQ,OAAO,OAAO,IAAI,IAAI,IAAI,IAAK,EAChF,OAAO,OAAO;AAAA,EACnB;AAGA,QAAM,cAAc,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,aAAa,IAAI,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE;AAElG,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,CAAC,GAAI,MAAM,QAAQ,WAAW,IAAI,IAAI,WAAW,OAAO,CAAC,GAAI,GAAG,WAAW;AAAA,EACnF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeSecuritySchemes.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/normalizeSecuritySchemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAErD,eAAO,MAAM,wBAAwB,eAAgB,SAAS,cAiD7D,CAAA"}
1
+ {"version":3,"file":"normalizeSecuritySchemes.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/normalizeSecuritySchemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,wBAAwB,eAAgB,SAAS,cAiD7D,CAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/transform/utils/normalizeSecuritySchemes.ts"],
4
- "sourcesContent": ["import type { AnyObject } from '../../../types/index'\n\nexport const normalizeSecuritySchemes = (definition: AnyObject) => {\n if (!definition.components?.securitySchemes) {\n return definition\n }\n\n const securitySchemes = { ...definition.components.securitySchemes }\n\n for (const scheme of Object.values(securitySchemes)) {\n if (typeof scheme === 'object' && scheme !== null && 'type' in scheme) {\n const type = String(scheme.type).toLowerCase()\n scheme.type =\n {\n apikey: 'apiKey',\n oauth2: 'oauth2',\n http: 'http',\n mutualtls: 'mutualTLS',\n openidconnect: 'openIdConnect',\n }[type] ?? type\n }\n }\n\n // Convert array scopes to objects\n for (const scheme of Object.values(securitySchemes)) {\n if (\n typeof scheme === 'object' &&\n scheme !== null &&\n 'type' in scheme &&\n scheme.type === 'oauth2' &&\n 'flows' in scheme\n ) {\n const flows = scheme.flows as AnyObject\n for (const flow of Object.values(flows)) {\n if (typeof flow === 'object' && flow !== null && 'scopes' in flow && Array.isArray(flow.scopes)) {\n flow.scopes = flow.scopes.reduce((acc: AnyObject, scope: string) => {\n acc[scope] = ''\n return acc\n }, {})\n }\n }\n }\n }\n\n return {\n ...definition,\n components: {\n ...definition.components,\n securitySchemes,\n },\n }\n}\n"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const normalizeSecuritySchemes = (definition: AnyObject) => {\n if (!definition.components?.securitySchemes) {\n return definition\n }\n\n const securitySchemes = { ...definition.components.securitySchemes }\n\n for (const scheme of Object.values(securitySchemes)) {\n if (typeof scheme === 'object' && scheme !== null && 'type' in scheme) {\n const type = String(scheme.type).toLowerCase()\n scheme.type =\n {\n apikey: 'apiKey',\n oauth2: 'oauth2',\n http: 'http',\n mutualtls: 'mutualTLS',\n openidconnect: 'openIdConnect',\n }[type] ?? type\n }\n }\n\n // Convert array scopes to objects\n for (const scheme of Object.values(securitySchemes)) {\n if (\n typeof scheme === 'object' &&\n scheme !== null &&\n 'type' in scheme &&\n scheme.type === 'oauth2' &&\n 'flows' in scheme\n ) {\n const flows = scheme.flows as AnyObject\n for (const flow of Object.values(flows)) {\n if (typeof flow === 'object' && flow !== null && 'scopes' in flow && Array.isArray(flow.scopes)) {\n flow.scopes = flow.scopes.reduce((acc: AnyObject, scope: string) => {\n acc[scope] = ''\n return acc\n }, {})\n }\n }\n }\n }\n\n return {\n ...definition,\n components: {\n ...definition.components,\n securitySchemes,\n },\n }\n}\n"],
5
5
  "mappings": "AAEO,MAAM,2BAA2B,CAAC,eAA0B;AACjE,MAAI,CAAC,WAAW,YAAY,iBAAiB;AAC3C,WAAO;AAAA,EACT;AAEA,QAAM,kBAAkB,EAAE,GAAG,WAAW,WAAW,gBAAgB;AAEnE,aAAW,UAAU,OAAO,OAAO,eAAe,GAAG;AACnD,QAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,UAAU,QAAQ;AACrE,YAAM,OAAO,OAAO,OAAO,IAAI,EAAE,YAAY;AAC7C,aAAO,OACL;AAAA,QACE,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,WAAW;AAAA,QACX,eAAe;AAAA,MACjB,EAAE,IAAI,KAAK;AAAA,IACf;AAAA,EACF;AAGA,aAAW,UAAU,OAAO,OAAO,eAAe,GAAG;AACnD,QACE,OAAO,WAAW,YAClB,WAAW,QACX,UAAU,UACV,OAAO,SAAS,YAChB,WAAW,QACX;AACA,YAAM,QAAQ,OAAO;AACrB,iBAAW,QAAQ,OAAO,OAAO,KAAK,GAAG;AACvC,YAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,YAAY,QAAQ,MAAM,QAAQ,KAAK,MAAM,GAAG;AAC/F,eAAK,SAAS,KAAK,OAAO,OAAO,CAAC,KAAgB,UAAkB;AAClE,gBAAI,KAAK,IAAI;AACb,mBAAO;AAAA,UACT,GAAG,CAAC,CAAC;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY;AAAA,MACV,GAAG,WAAW;AAAA,MACd;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rejectSwaggerDocuments.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/rejectSwaggerDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAErD,eAAO,MAAM,sBAAsB,cAAe,SAAS,cAM1D,CAAA"}
1
+ {"version":3,"file":"rejectSwaggerDocuments.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/rejectSwaggerDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,sBAAsB,cAAe,SAAS,cAM1D,CAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/transform/utils/rejectSwaggerDocuments.ts"],
4
- "sourcesContent": ["import type { AnyObject } from '../../../types/index'\n\nexport const rejectSwaggerDocuments = (defintion: AnyObject) => {\n if ('swagger' in defintion) {\n throw new Error('Swagger 2.0 documents are not supported. Please upgrade to OpenAPI 3.x.')\n }\n\n return defintion\n}\n"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const rejectSwaggerDocuments = (defintion: AnyObject) => {\n if ('swagger' in defintion) {\n throw new Error('Swagger 2.0 documents are not supported. Please upgrade to OpenAPI 3.x.')\n }\n\n return defintion\n}\n"],
5
5
  "mappings": "AAEO,MAAM,yBAAyB,CAAC,cAAyB;AAC9D,MAAI,aAAa,WAAW;AAC1B,UAAM,IAAI,MAAM,yEAAyE;AAAA,EAC3F;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -3,4 +3,4 @@ import type { AnyObject } from '../types/index.js';
3
3
  * Transforms ajv errors, finds the positions in the schema and returns an enriched format.
4
4
  */
5
5
  export declare function transformErrors(specification: AnyObject, errors: any): any;
6
- //# sourceMappingURL=transformErrors.d.ts.map
6
+ //# sourceMappingURL=transform-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-errors.d.ts","sourceRoot":"","sources":["../../src/utils/transform-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C;;GAEG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAkBpE"}
@@ -17,4 +17,4 @@ function transformErrors(specification, errors) {
17
17
  export {
18
18
  transformErrors
19
19
  };
20
- //# sourceMappingURL=transformErrors.js.map
20
+ //# sourceMappingURL=transform-errors.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/transform-errors.ts"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\nimport { betterAjvErrors } from './betterAjvErrors/index'\n\n/**\n * Transforms ajv errors, finds the positions in the schema and returns an enriched format.\n */\nexport function transformErrors(specification: AnyObject, errors: any) {\n // TODO: This should work with multiple files\n\n if (typeof errors === 'string') {\n return [\n {\n message: errors,\n },\n ]\n }\n\n return betterAjvErrors(specification, null, errors, {\n indent: 2,\n }).map((error) => {\n error.message = error.message.trim()\n\n return error\n })\n}\n"],
5
+ "mappings": "AACA,SAAS,uBAAuB;AAKzB,SAAS,gBAAgB,eAA0B,QAAa;AAGrE,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,MACL;AAAA,QACE,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAEA,SAAO,gBAAgB,eAAe,MAAM,QAAQ;AAAA,IAClD,QAAQ;AAAA,EACV,CAAC,EAAE,IAAI,CAAC,UAAU;AAChB,UAAM,UAAU,MAAM,QAAQ,KAAK;AAEnC,WAAO;AAAA,EACT,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../src/utils/traverse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD;;GAEG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,aAAa,EACrE,IAAI,GAAE,MAAM,EAAO,iBA6BpB"}
1
+ {"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../src/utils/traverse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD;;GAEG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,aAAa,EACrE,IAAI,GAAE,MAAM,EAAO,iBA6BpB"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/traverse.ts"],
4
- "sourcesContent": ["import type { UnknownObject } from '@scalar/types/utils'\nimport type { AnyObject } from '../types/index'\n\n/**\n * Recursively traverses the content and applies the transform function to each node.\n */\nexport function traverse(\n content: UnknownObject,\n transform: (content: UnknownObject, path?: string[]) => UnknownObject,\n path: string[] = [],\n) {\n const result: AnyObject = {}\n\n for (const [key, value] of Object.entries(content)) {\n const currentPath = [...path, key]\n\n if (Array.isArray(value)) {\n result[key] = value.map((item, index) => {\n if (typeof item === 'object' && !Array.isArray(item) && item !== null) {\n return traverse(item, transform, [...currentPath, index.toString()])\n }\n\n return item\n })\n\n continue\n }\n\n if (typeof value === 'object' && value !== null) {\n result[key] = traverse(value as UnknownObject, transform, currentPath)\n\n continue\n }\n\n result[key] = value\n }\n\n return transform(result, path)\n}\n"],
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\nimport type { UnknownObject } from '@scalar/types/utils'\n\n/**\n * Recursively traverses the content and applies the transform function to each node.\n */\nexport function traverse(\n content: UnknownObject,\n transform: (content: UnknownObject, path?: string[]) => UnknownObject,\n path: string[] = [],\n) {\n const result: AnyObject = {}\n\n for (const [key, value] of Object.entries(content)) {\n const currentPath = [...path, key]\n\n if (Array.isArray(value)) {\n result[key] = value.map((item, index) => {\n if (typeof item === 'object' && !Array.isArray(item) && item !== null) {\n return traverse(item, transform, [...currentPath, index.toString()])\n }\n\n return item\n })\n\n continue\n }\n\n if (typeof value === 'object' && value !== null) {\n result[key] = traverse(value as UnknownObject, transform, currentPath)\n\n continue\n }\n\n result[key] = value\n }\n\n return transform(result, path)\n}\n"],
5
5
  "mappings": "AAMO,SAAS,SACd,SACA,WACA,OAAiB,CAAC,GAClB;AACA,QAAM,SAAoB,CAAC;AAE3B,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,UAAM,cAAc,CAAC,GAAG,MAAM,GAAG;AAEjC,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,aAAO,GAAG,IAAI,MAAM,IAAI,CAAC,MAAM,UAAU;AACvC,YAAI,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,KAAK,SAAS,MAAM;AACrE,iBAAO,SAAS,MAAM,WAAW,CAAC,GAAG,aAAa,MAAM,SAAS,CAAC,CAAC;AAAA,QACrE;AAEA,eAAO;AAAA,MACT,CAAC;AAED;AAAA,IACF;AAEA,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,aAAO,GAAG,IAAI,SAAS,OAAwB,WAAW,WAAW;AAErE;AAAA,IACF;AAEA,WAAO,GAAG,IAAI;AAAA,EAChB;AAEA,SAAO,UAAU,QAAQ,IAAI;AAC/B;",
6
6
  "names": []
7
7
  }
@@ -5,4 +5,4 @@
5
5
  * /foo~1bar~0baz -> /foo/bar~baz
6
6
  */
7
7
  export declare function unescapeJsonPointer(uri: string): string;
8
- //# sourceMappingURL=unescapeJsonPointer.d.ts.map
8
+ //# sourceMappingURL=unescape-json-pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unescape-json-pointer.d.ts","sourceRoot":"","sources":["../../src/utils/unescape-json-pointer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,UAE9C"}
@@ -4,4 +4,4 @@ function unescapeJsonPointer(uri) {
4
4
  export {
5
5
  unescapeJsonPointer
6
6
  };
7
- //# sourceMappingURL=unescapeJsonPointer.js.map
7
+ //# sourceMappingURL=unescape-json-pointer.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/unescapeJsonPointer.ts"],
3
+ "sources": ["../../src/utils/unescape-json-pointer.ts"],
4
4
  "sourcesContent": ["/**\n * Unescape JSON pointer\n *\n * Examples:\n * /foo~1bar~0baz -> /foo/bar~baz\n */\nexport function unescapeJsonPointer(uri: string) {\n return decodeURI(uri.replace(/~1/g, '/').replace(/~0/g, '~'))\n}\n"],
5
5
  "mappings": "AAMO,SAAS,oBAAoB,KAAa;AAC/C,SAAO,UAAU,IAAI,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,CAAC;AAC9D;",
6
6
  "names": []
@@ -28,4 +28,4 @@ export declare function upgradeFromThreeToThreeOne(originalContent: UnknownObjec
28
28
  [customExtension: `x-${string}`]: any;
29
29
  [key: string]: any;
30
30
  }) | UnknownObject;
31
- //# sourceMappingURL=upgradeFromThreeToThreeOne.d.ts.map
31
+ //# sourceMappingURL=upgrade-from-three-to-three-one.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-from-three-to-three-one.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade-from-three-to-three-one.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAgBxD,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAiBpD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;mBAcxE"}
@@ -9,7 +9,6 @@ const SCHEMA_SEGMENTS = /* @__PURE__ */ new Set([
9
9
  "additionalProperties",
10
10
  "schema"
11
11
  ]);
12
- const SCHEMA_PATHS = /* @__PURE__ */ new Set(["components/schemas"]);
13
12
  function isSchemaPath(path) {
14
13
  if (path.some((segment) => SCHEMA_SEGMENTS.has(segment))) {
15
14
  return true;
@@ -107,4 +106,4 @@ export {
107
106
  isSchemaPath,
108
107
  upgradeFromThreeToThreeOne
109
108
  };
110
- //# sourceMappingURL=upgradeFromThreeToThreeOne.js.map
109
+ //# sourceMappingURL=upgrade-from-three-to-three-one.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/upgrade-from-three-to-three-one.ts"],
4
+ "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport { traverse } from './traverse'\n\n// Create Sets for faster schema path lookups\nconst SCHEMA_SEGMENTS = new Set([\n 'properties',\n 'items',\n 'allOf',\n 'anyOf',\n 'oneOf',\n 'not',\n 'additionalProperties',\n 'schema',\n])\n\n/** Determine if the current path is within a schema - optimized version */\nexport function isSchemaPath(path: string[]): boolean {\n // Check for schema segments first (most common case)\n if (path.some((segment) => SCHEMA_SEGMENTS.has(segment))) {\n return true\n }\n\n // Check for schema suffix\n if (path.some((segment) => segment.endsWith('Schema'))) {\n return true\n }\n\n // Check for components/schemas path\n if (path.length >= 2 && path[0] === 'components' && path[1] === 'schemas') {\n return true\n }\n\n return false\n}\n\n/**\n * Upgrade from OpenAPI 3.0.x to 3.1.1\n *\n * https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n */\nexport function upgradeFromThreeToThreeOne(originalContent: UnknownObject) {\n let content = originalContent\n\n // Version check - early return if not 3.0.x\n if (content === null || typeof content.openapi !== 'string' || !content.openapi.startsWith('3.0')) {\n return content\n }\n\n content.openapi = '3.1.1'\n\n // Single traversal that handles all transformations\n content = traverse(content, applyChangesToDocument)\n\n return content as OpenAPIV3_1.Document\n}\n\nconst applyChangesToDocument = (schema: UnknownObject, path: string[]) => {\n // 1. Handle nullable types\n if (schema.type !== 'undefined' && schema.nullable === true) {\n schema.type = [schema.type, 'null']\n delete schema.nullable\n }\n\n // 2. Handle exclusiveMinimum and exclusiveMaximum\n if (schema.exclusiveMinimum === true) {\n schema.exclusiveMinimum = schema.minimum\n delete schema.minimum\n } else if (schema.exclusiveMinimum === false) {\n delete schema.exclusiveMinimum\n }\n\n if (schema.exclusiveMaximum === true) {\n schema.exclusiveMaximum = schema.maximum\n delete schema.maximum\n } else if (schema.exclusiveMaximum === false) {\n delete schema.exclusiveMaximum\n }\n\n // 3. Handle examples\n if (schema.example !== undefined) {\n if (isSchemaPath(path)) {\n schema.examples = [schema.example]\n } else {\n schema.examples = {\n default: {\n value: schema.example,\n },\n }\n }\n delete schema.example\n }\n\n // 4. Handle multipart file uploads\n if (schema.type === 'object' && schema.properties !== undefined) {\n const parentPath = path.slice(0, -1)\n const isMultipart = parentPath.some((segment, index) => {\n return segment === 'content' && path[index + 1] === 'multipart/form-data'\n })\n\n if (isMultipart) {\n for (const value of Object.values(schema.properties)) {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n 'format' in value &&\n value.type === 'string' &&\n value.format === 'binary'\n ) {\n ;(value as any).contentMediaType = 'application/octet-stream'\n delete (value as any).format\n }\n }\n }\n }\n\n // 5. Handle binary file uploads\n if (path.includes('content') && path.includes('application/octet-stream')) {\n return {}\n }\n\n if (schema.type === 'string') {\n if (schema.format === 'binary') {\n return {\n type: 'string',\n contentMediaType: 'application/octet-stream',\n }\n }\n\n if (schema.format === 'base64') {\n return {\n type: 'string',\n contentEncoding: 'base64',\n }\n }\n\n if (schema.format === 'byte') {\n const parentPath = path.slice(0, -1)\n const contentMediaType = parentPath.find((_, index) => path[index - 1] === 'content')\n return {\n type: 'string',\n contentEncoding: 'base64',\n contentMediaType,\n }\n }\n }\n\n return schema\n}\n"],
5
+ "mappings": "AAGA,SAAS,gBAAgB;AAGzB,MAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,SAAS,aAAa,MAAyB;AAEpD,MAAI,KAAK,KAAK,CAAC,YAAY,gBAAgB,IAAI,OAAO,CAAC,GAAG;AACxD,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,KAAK,CAAC,YAAY,QAAQ,SAAS,QAAQ,CAAC,GAAG;AACtD,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,UAAU,KAAK,KAAK,CAAC,MAAM,gBAAgB,KAAK,CAAC,MAAM,WAAW;AACzE,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAOO,SAAS,2BAA2B,iBAAgC;AACzE,MAAI,UAAU;AAGd,MAAI,YAAY,QAAQ,OAAO,QAAQ,YAAY,YAAY,CAAC,QAAQ,QAAQ,WAAW,KAAK,GAAG;AACjG,WAAO;AAAA,EACT;AAEA,UAAQ,UAAU;AAGlB,YAAU,SAAS,SAAS,sBAAsB;AAElD,SAAO;AACT;AAEA,MAAM,yBAAyB,CAAC,QAAuB,SAAmB;AAExE,MAAI,OAAO,SAAS,eAAe,OAAO,aAAa,MAAM;AAC3D,WAAO,OAAO,CAAC,OAAO,MAAM,MAAM;AAClC,WAAO,OAAO;AAAA,EAChB;AAGA,MAAI,OAAO,qBAAqB,MAAM;AACpC,WAAO,mBAAmB,OAAO;AACjC,WAAO,OAAO;AAAA,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,IACF;AAEA,QAAI,OAAO,WAAW,QAAQ;AAC5B,YAAM,aAAa,KAAK,MAAM,GAAG,EAAE;AACnC,YAAM,mBAAmB,WAAW,KAAK,CAAC,GAAG,UAAU,KAAK,QAAQ,CAAC,MAAM,SAAS;AACpF,aAAO;AAAA,QACL,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -6,4 +6,4 @@ import type { UnknownObject } from '@scalar/types/utils';
6
6
  * https://swagger.io/blog/news/whats-new-in-openapi-3-0/
7
7
  */
8
8
  export declare function upgradeFromTwoToThree(originalSpecification: UnknownObject): OpenAPIV3.Document<{}> | UnknownObject;
9
- //# sourceMappingURL=upgradeFromTwoToThree.d.ts.map
9
+ //# sourceMappingURL=upgrade-from-two-to-three.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-from-two-to-three.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade-from-two-to-three.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,0CAsQzE"}
@@ -225,4 +225,4 @@ function transformParameterObject(parameter) {
225
225
  export {
226
226
  upgradeFromTwoToThree
227
227
  };
228
- //# sourceMappingURL=upgradeFromTwoToThree.js.map
228
+ //# sourceMappingURL=upgrade-from-two-to-three.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/upgradeFromTwoToThree.ts"],
3
+ "sources": ["../../src/utils/upgrade-from-two-to-three.ts"],
4
4
  "sourcesContent": ["import type { OpenAPIV2, OpenAPIV3 } from '@scalar/openapi-types'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport { traverse } from './traverse'\n\n/**\n * Upgrade Swagger 2.0 to OpenAPI 3.0\n *\n * https://swagger.io/blog/news/whats-new-in-openapi-3-0/\n */\nexport function upgradeFromTwoToThree(originalSpecification: UnknownObject) {\n let specification = originalSpecification\n\n // Version\n if (\n specification !== null &&\n typeof specification === 'object' &&\n typeof specification.swagger === 'string' &&\n specification.swagger?.startsWith('2.0')\n ) {\n specification.openapi = '3.0.4'\n delete specification.swagger\n } else {\n // Skip if it\u2019s something else than 3.0.x\n return specification\n }\n\n // Servers\n if (specification.host) {\n const schemes =\n Array.isArray(specification.schemes) && specification.schemes?.length ? specification.schemes : ['http']\n\n specification.servers = schemes.map((scheme: string[]) => ({\n url: `${scheme}://${specification.host}${specification.basePath ?? ''}`,\n }))\n\n delete specification.basePath\n delete specification.schemes\n delete specification.host\n } else if (specification.basePath) {\n specification.servers = [{ url: specification.basePath }]\n delete specification.basePath\n }\n\n // Schemas\n if (specification.definitions) {\n specification.components = Object.assign({}, specification.components, {\n schemas: specification.definitions,\n })\n\n delete specification.definitions\n\n // Rewrite $refs to definitions\n specification = traverse(specification, (schema) => {\n // Rewrite $refs to components\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/definitions/')) {\n schema.$ref = schema.$ref.replace(/^#\\/definitions\\//, '#/components/schemas/')\n }\n\n return schema\n })\n }\n\n // Transform file type to string with binary format\n specification = traverse(specification, (schema) => {\n if (schema.type === 'file') {\n schema.type = 'string'\n schema.format = 'binary'\n }\n\n return schema\n })\n\n // Paths\n if (typeof specification.paths === 'object') {\n for (const path in specification.paths) {\n if (Object.hasOwn(specification.paths, path)) {\n const pathItem = specification.paths[path]\n\n for (const method in pathItem) {\n if (Object.hasOwn(pathItem, method)) {\n const operationItem = pathItem[method]\n\n // Request bodies\n if (operationItem.parameters) {\n const bodyParameter = structuredClone(\n operationItem.parameters.find((parameter: OpenAPIV3.ParameterObject) => parameter.in === 'body') ?? {},\n )\n\n if (bodyParameter && Object.keys(bodyParameter).length) {\n delete bodyParameter.name\n delete bodyParameter.in\n\n const consumes = specification.consumes ?? operationItem.consumes ?? ['application/json']\n\n if (typeof operationItem.requestBody !== 'object') {\n operationItem.requestBody = {}\n }\n\n if (typeof operationItem.requestBody.content !== 'object') {\n operationItem.requestBody.content = {}\n }\n\n const { schema, ...requestBody } = bodyParameter\n\n operationItem.requestBody = {\n ...operationItem.requestBody,\n ...requestBody,\n }\n\n for (const type of consumes) {\n operationItem.requestBody.content[type] = {\n schema: schema,\n }\n }\n }\n\n // Delete body parameter\n operationItem.parameters = operationItem.parameters.filter(\n (parameter: OpenAPIV2.ParameterObject) => parameter.in !== 'body',\n )\n\n delete operationItem.consumes\n\n // formData parameters\n const formDataParameters = operationItem.parameters.filter(\n (parameter: OpenAPIV2.ParameterObject) => parameter.in === 'formData',\n )\n\n if (formDataParameters.length > 0) {\n if (typeof operationItem.requestBody !== 'object') {\n operationItem.requestBody = {}\n }\n\n if (typeof operationItem.requestBody.content !== 'object') {\n operationItem.requestBody.content = {}\n }\n\n operationItem.requestBody.content['application/x-www-form-urlencoded'] = {\n schema: {\n type: 'object',\n properties: {},\n required: [], // Initialize required array\n },\n }\n\n for (const param of formDataParameters) {\n operationItem.requestBody.content['application/x-www-form-urlencoded'].schema.properties[param.name] =\n {\n type: param.type,\n description: param.description,\n }\n\n // Add to required array if param is required\n if (param.required) {\n operationItem.requestBody.content['application/x-www-form-urlencoded'].schema.required.push(\n param.name,\n )\n }\n }\n\n // Remove formData parameters from the parameters array\n operationItem.parameters = operationItem.parameters.filter(\n (parameter: OpenAPIV2.ParameterObject) => parameter.in !== 'formData',\n )\n }\n\n operationItem.parameters = operationItem.parameters.map((parameter) =>\n transformParameterObject(parameter),\n )\n }\n\n // Responses\n if (operationItem.responses) {\n for (const response in operationItem.responses) {\n if (Object.hasOwn(operationItem.responses, response)) {\n const responseItem = operationItem.responses[response]\n\n if (responseItem.headers) {\n responseItem.headers = Object.entries(responseItem.headers).reduce((acc, [name, header]) => {\n return {\n [name]: transformParameterObject(header),\n ...acc,\n }\n }, {})\n }\n if (responseItem.schema) {\n const produces = specification.produces ?? operationItem.produces ?? ['application/json']\n\n if (typeof responseItem.content !== 'object') {\n responseItem.content = {}\n }\n\n for (const type of produces) {\n responseItem.content[type] = {\n schema: responseItem.schema,\n }\n }\n\n delete responseItem.schema\n }\n }\n }\n }\n\n delete operationItem.produces\n\n // Delete empty parameters\n if (operationItem.parameters?.length === 0) {\n delete operationItem.parameters\n }\n }\n }\n }\n }\n }\n\n // Upgrade securityDefinitions\n if (specification.securityDefinitions) {\n if (typeof specification.components !== 'object') {\n specification.components = {}\n }\n\n // Assert that components is of type OpenAPIV3.ComponentsObject\n specification.components = specification.components as OpenAPIV3.ComponentsObject\n\n Object.assign(specification.components, { securitySchemes: {} })\n\n for (const [key, securityScheme] of Object.entries(specification.securityDefinitions)) {\n if (typeof securityScheme === 'object') {\n if ('type' in securityScheme && securityScheme.type === 'oauth2') {\n const { flow, authorizationUrl, tokenUrl, scopes } = securityScheme as {\n type: 'oauth2'\n flow?: string\n authorizationUrl?: string\n tokenUrl?: string\n scopes?: Record<string, string>\n }\n\n // Assert that securitySchemes is of type OpenAPIV3.SecuritySchemeObject\n Object.assign((specification.components as OpenAPIV3.ComponentsObject).securitySchemes, {\n [key]: {\n type: 'oauth2',\n flows: {\n [flow as string]: Object.assign(\n {},\n authorizationUrl && { authorizationUrl },\n tokenUrl && { tokenUrl },\n scopes && { scopes },\n ),\n },\n },\n })\n } else if ('type' in securityScheme && securityScheme.type === 'basic') {\n Object.assign((specification.components as OpenAPIV3.ComponentsObject).securitySchemes, {\n [key]: {\n type: 'http',\n scheme: 'basic',\n },\n })\n } else {\n Object.assign((specification.components as OpenAPIV3.ComponentsObject).securitySchemes, {\n [key]: securityScheme,\n })\n }\n }\n }\n\n delete specification.securityDefinitions\n }\n\n return specification as OpenAPIV3.Document\n}\n\nfunction transformItemsObject<T extends Record<PropertyKey, unknown>>(obj: T): OpenAPIV3.SchemaObject {\n const schemaProperties = [\n 'type',\n 'format',\n 'items',\n 'maximum',\n 'exclusiveMaximum',\n 'minimum',\n 'exclusiveMinimum',\n 'maxLength',\n 'minLength',\n 'pattern',\n 'maxItems',\n 'minItems',\n 'uniqueItems',\n 'enum',\n 'multipleOf',\n ]\n\n return schemaProperties.reduce((acc, property) => {\n if (Object.hasOwn(obj, property)) {\n acc[property] = obj[property]\n delete obj[property]\n }\n\n return acc\n }, {} as OpenAPIV3.SchemaObject)\n}\n\nfunction transformParameterObject(parameter: OpenAPIV2.ParameterObject): OpenAPIV3.ParameterObject {\n delete parameter.collectionFormat\n delete parameter.default\n\n return {\n schema: transformItemsObject(parameter),\n ...parameter,\n }\n}\n"],
5
5
  "mappings": "AAGA,SAAS,gBAAgB;AAOlB,SAAS,sBAAsB,uBAAsC;AAC1E,MAAI,gBAAgB;AAGpB,MACE,kBAAkB,QAClB,OAAO,kBAAkB,YACzB,OAAO,cAAc,YAAY,YACjC,cAAc,SAAS,WAAW,KAAK,GACvC;AACA,kBAAc,UAAU;AACxB,WAAO,cAAc;AAAA,EACvB,OAAO;AAEL,WAAO;AAAA,EACT;AAGA,MAAI,cAAc,MAAM;AACtB,UAAM,UACJ,MAAM,QAAQ,cAAc,OAAO,KAAK,cAAc,SAAS,SAAS,cAAc,UAAU,CAAC,MAAM;AAEzG,kBAAc,UAAU,QAAQ,IAAI,CAAC,YAAsB;AAAA,MACzD,KAAK,GAAG,MAAM,MAAM,cAAc,IAAI,GAAG,cAAc,YAAY,EAAE;AAAA,IACvE,EAAE;AAEF,WAAO,cAAc;AACrB,WAAO,cAAc;AACrB,WAAO,cAAc;AAAA,EACvB,WAAW,cAAc,UAAU;AACjC,kBAAc,UAAU,CAAC,EAAE,KAAK,cAAc,SAAS,CAAC;AACxD,WAAO,cAAc;AAAA,EACvB;AAGA,MAAI,cAAc,aAAa;AAC7B,kBAAc,aAAa,OAAO,OAAO,CAAC,GAAG,cAAc,YAAY;AAAA,MACrE,SAAS,cAAc;AAAA,IACzB,CAAC;AAED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, describe, expect } from "vitest";
2
2
  import { upgrade } from "./upgrade.js";
3
- import { upgradeFromTwoToThree } from "./upgradeFromTwoToThree.js";
3
+ import { upgradeFromTwoToThree } from "./upgrade-from-two-to-three.js";
4
4
  const STRIPE = await fetch(
5
5
  "https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/openapi/spec3.json"
6
6
  ).then((r) => r.json());
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/upgrade.bench.ts"],
4
- "sourcesContent": ["import { bench, describe, expect } from 'vitest'\n\n// import { upgrade as upgradeOld } from './slow/upgrade'\n// import { upgradeFromTwoToThree as upgradeFromTwoToThreeOld } from './slow/upgradeFromTwoToThree'\nimport { upgrade } from './upgrade'\nimport { upgradeFromTwoToThree } from './upgradeFromTwoToThree'\n\n// Setup the test data\nconst STRIPE = await fetch(\n 'https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/openapi/spec3.json',\n).then((r) => r.json())\n\nconst PETSTORE = await fetch('https://petstore.swagger.io/v2/swagger.json').then((r) => r.json())\n\ndescribe('upgrade', () => {\n describe('Petstore: Swagger 2.0 to OpenAPI 3.0', () => {\n bench('new', () => {\n expect(PETSTORE.swagger).toBe('2.0')\n\n const result = upgradeFromTwoToThree({ ...PETSTORE })\n\n expect(result.openapi).toBe('3.0.4')\n })\n\n // bench('old', () => {\n // expect(PETSTORE.swagger).toBe('2.0')\n\n // const result = upgradeFromTwoToThreeOld({ ...PETSTORE })\n\n // expect(result.openapi).toBe('3.0.4')\n // })\n })\n\n describe('Stripe: OpenAPI 3.0 to 3.1', () => {\n bench('new', () => {\n expect(STRIPE.openapi).toBe('3.0.0')\n\n const { specification } = upgrade(JSON.stringify(STRIPE))\n\n expect(specification?.openapi).toBe('3.1.1')\n })\n\n // bench('old', () => {\n // expect(STRIPE.openapi).toBe('3.0.0')\n\n // const { specification } = upgradeOld(JSON.stringify(STRIPE))\n\n // expect(specification?.openapi).toBe('3.1.1')\n // })\n })\n\n describe('Petstore: Swagger 2.0 to OpenAPI 3.1', () => {\n bench('new', () => {\n expect(PETSTORE.swagger).toBe('2.0')\n\n const { specification } = upgrade(JSON.stringify(PETSTORE))\n\n expect(specification?.openapi).toBe('3.1.1')\n })\n\n // bench('old', () => {\n // expect(PETSTORE.swagger).toBe('2.0')\n\n // const { specification } = upgradeOld(JSON.stringify(PETSTORE))\n\n // expect(specification?.openapi).toBe('3.1.1')\n // })\n })\n})\n"],
4
+ "sourcesContent": ["import { bench, describe, expect } from 'vitest'\n\n// import { upgrade as upgradeOld } from './slow/upgrade'\n// import { upgradeFromTwoToThree as upgradeFromTwoToThreeOld } from './slow/upgradeFromTwoToThree'\nimport { upgrade } from './upgrade'\nimport { upgradeFromTwoToThree } from './upgrade-from-two-to-three'\n\n// Setup the test data\nconst STRIPE = await fetch(\n 'https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/openapi/spec3.json',\n).then((r) => r.json())\n\nconst PETSTORE = await fetch('https://petstore.swagger.io/v2/swagger.json').then((r) => r.json())\n\ndescribe('upgrade', () => {\n describe('Petstore: Swagger 2.0 to OpenAPI 3.0', () => {\n bench('new', () => {\n expect(PETSTORE.swagger).toBe('2.0')\n\n const result = upgradeFromTwoToThree({ ...PETSTORE })\n\n expect(result.openapi).toBe('3.0.4')\n })\n\n // bench('old', () => {\n // expect(PETSTORE.swagger).toBe('2.0')\n\n // const result = upgradeFromTwoToThreeOld({ ...PETSTORE })\n\n // expect(result.openapi).toBe('3.0.4')\n // })\n })\n\n describe('Stripe: OpenAPI 3.0 to 3.1', () => {\n bench('new', () => {\n expect(STRIPE.openapi).toBe('3.0.0')\n\n const { specification } = upgrade(JSON.stringify(STRIPE))\n\n expect(specification?.openapi).toBe('3.1.1')\n })\n\n // bench('old', () => {\n // expect(STRIPE.openapi).toBe('3.0.0')\n\n // const { specification } = upgradeOld(JSON.stringify(STRIPE))\n\n // expect(specification?.openapi).toBe('3.1.1')\n // })\n })\n\n describe('Petstore: Swagger 2.0 to OpenAPI 3.1', () => {\n bench('new', () => {\n expect(PETSTORE.swagger).toBe('2.0')\n\n const { specification } = upgrade(JSON.stringify(PETSTORE))\n\n expect(specification?.openapi).toBe('3.1.1')\n })\n\n // bench('old', () => {\n // expect(PETSTORE.swagger).toBe('2.0')\n\n // const { specification } = upgradeOld(JSON.stringify(PETSTORE))\n\n // expect(specification?.openapi).toBe('3.1.1')\n // })\n })\n})\n"],
5
5
  "mappings": "AAAA,SAAS,OAAO,UAAU,cAAc;AAIxC,SAAS,eAAe;AACxB,SAAS,6BAA6B;AAGtC,MAAM,SAAS,MAAM;AAAA,EACnB;AACF,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;AAEtB,MAAM,WAAW,MAAM,MAAM,6CAA6C,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;AAEhG,SAAS,WAAW,MAAM;AACxB,WAAS,wCAAwC,MAAM;AACrD,UAAM,OAAO,MAAM;AACjB,aAAO,SAAS,OAAO,EAAE,KAAK,KAAK;AAEnC,YAAM,SAAS,sBAAsB,EAAE,GAAG,SAAS,CAAC;AAEpD,aAAO,OAAO,OAAO,EAAE,KAAK,OAAO;AAAA,IACrC,CAAC;AAAA,EASH,CAAC;AAED,WAAS,8BAA8B,MAAM;AAC3C,UAAM,OAAO,MAAM;AACjB,aAAO,OAAO,OAAO,EAAE,KAAK,OAAO;AAEnC,YAAM,EAAE,cAAc,IAAI,QAAQ,KAAK,UAAU,MAAM,CAAC;AAExD,aAAO,eAAe,OAAO,EAAE,KAAK,OAAO;AAAA,IAC7C,CAAC;AAAA,EASH,CAAC;AAED,WAAS,wCAAwC,MAAM;AACrD,UAAM,OAAO,MAAM;AACjB,aAAO,SAAS,OAAO,EAAE,KAAK,KAAK;AAEnC,YAAM,EAAE,cAAc,IAAI,QAAQ,KAAK,UAAU,QAAQ,CAAC;AAE1D,aAAO,eAAe,OAAO,EAAE,KAAK,OAAO;AAAA,IAC7C,CAAC;AAAA,EASH,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGxD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAc1E;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAmBnG"}
1
+ {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAezE;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAmBnG"}
@@ -1,8 +1,8 @@
1
- import { getEntrypoint } from "./getEntrypoint.js";
2
- import { isFilesystem } from "./isFilesystem.js";
1
+ import { getEntrypoint } from "./get-entrypoint.js";
2
+ import { isFilesystem } from "./is-filesystem.js";
3
3
  import { normalize } from "./normalize.js";
4
- import { upgradeFromThreeToThreeOne } from "./upgradeFromThreeToThreeOne.js";
5
- import { upgradeFromTwoToThree } from "./upgradeFromTwoToThree.js";
4
+ import { upgradeFromThreeToThreeOne } from "./upgrade-from-three-to-three-one.js";
5
+ import { upgradeFromTwoToThree } from "./upgrade-from-two-to-three.js";
6
6
  const upgraders = [
7
7
  // Swagger 2.0 -> OpenAPI 3.0
8
8
  upgradeFromTwoToThree,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/upgrade.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nimport type { UnknownObject } from '@scalar/types/utils'\nimport type { AnyObject, Filesystem, UpgradeResult } from '../types/index'\nimport { getEntrypoint } from './getEntrypoint'\nimport { isFilesystem } from './isFilesystem'\nimport { normalize } from './normalize'\nimport { upgradeFromThreeToThreeOne } from './upgradeFromThreeToThreeOne'\nimport { upgradeFromTwoToThree } from './upgradeFromTwoToThree'\n\nconst upgraders = [\n // Swagger 2.0 -> OpenAPI 3.0\n upgradeFromTwoToThree,\n // OpenAPI 3.0 -> OpenAPI 3.1\n upgradeFromThreeToThreeOne,\n]\n\n/**\n * Upgrade specification to OpenAPI 3.1.0\n */\nexport function upgrade(value: string | AnyObject | Filesystem): UpgradeResult<OpenAPIV3_1.Document> {\n if (!value) {\n return {\n specification: null,\n version: '3.1',\n }\n }\n\n // TODO: Run upgrade over the whole filesystem\n const result = upgraders.reduce(\n (currentSpecification, upgrader) => upgrader(currentSpecification as UnknownObject),\n isFilesystem(value) ? getEntrypoint(value).specification : normalize(value),\n ) as OpenAPIV3_1.Document\n\n return {\n specification: result,\n // TODO: Make dynamic\n version: '3.1',\n } as UpgradeResult<OpenAPIV3_1.Document>\n}\n"],
4
+ "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nimport type { AnyObject, Filesystem, UpgradeResult } from '@/types/index'\nimport type { UnknownObject } from '@scalar/types/utils'\nimport { getEntrypoint } from './get-entrypoint'\nimport { isFilesystem } from './is-filesystem'\nimport { normalize } from './normalize'\nimport { upgradeFromThreeToThreeOne } from './upgrade-from-three-to-three-one'\nimport { upgradeFromTwoToThree } from './upgrade-from-two-to-three'\n\nconst upgraders = [\n // Swagger 2.0 -> OpenAPI 3.0\n upgradeFromTwoToThree,\n // OpenAPI 3.0 -> OpenAPI 3.1\n upgradeFromThreeToThreeOne,\n]\n\n/**\n * Upgrade specification to OpenAPI 3.1.0\n */\nexport function upgrade(value: string | AnyObject | Filesystem): UpgradeResult<OpenAPIV3_1.Document> {\n if (!value) {\n return {\n specification: null,\n version: '3.1',\n }\n }\n\n // TODO: Run upgrade over the whole filesystem\n const result = upgraders.reduce(\n (currentSpecification, upgrader) => upgrader(currentSpecification as UnknownObject),\n isFilesystem(value) ? getEntrypoint(value).specification : normalize(value),\n ) as OpenAPIV3_1.Document\n\n return {\n specification: result,\n // TODO: Make dynamic\n version: '3.1',\n } as UpgradeResult<OpenAPIV3_1.Document>\n}\n"],
5
5
  "mappings": "AAIA,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,kCAAkC;AAC3C,SAAS,6BAA6B;AAEtC,MAAM,YAAY;AAAA;AAAA,EAEhB;AAAA;AAAA,EAEA;AACF;AAKO,SAAS,QAAQ,OAA6E;AACnG,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,MACL,eAAe;AAAA,MACf,SAAS;AAAA,IACX;AAAA,EACF;AAGA,QAAM,SAAS,UAAU;AAAA,IACvB,CAAC,sBAAsB,aAAa,SAAS,oBAAqC;AAAA,IAClF,aAAa,KAAK,IAAI,cAAc,KAAK,EAAE,gBAAgB,UAAU,KAAK;AAAA,EAC5E;AAEA,SAAO;AAAA,IACL,eAAe;AAAA;AAAA,IAEf,SAAS;AAAA,EACX;AACF;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG/F,MAAM,MAAM,eAAe,GAAG,kBAAkB,CAAA;AAEhD;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EACtC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CAWzB"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAG9F,MAAM,MAAM,eAAe,GAAG,kBAAkB,CAAA;AAEhD;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EACtC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CAWzB"}
@@ -1,5 +1,5 @@
1
1
  import { Validator } from "../lib/Validator/Validator.js";
2
- import { makeFilesystem } from "./makeFilesystem.js";
2
+ import { makeFilesystem } from "./make-filesystem.js";
3
3
  async function validate(value, options) {
4
4
  const filesystem = makeFilesystem(value);
5
5
  const validator = new Validator();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/validate.ts"],
4
- "sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\n\nimport { Validator } from '../lib/Validator/Validator'\nimport type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '../types/index'\nimport { makeFilesystem } from './makeFilesystem'\n\nexport type ValidateOptions = ThrowOnErrorOption\n\n/**\n * Validates an OpenAPI document\n */\nexport async function validate(\n value: string | AnyObject | Filesystem,\n options?: ValidateOptions,\n): Promise<ValidateResult> {\n const filesystem = makeFilesystem(value)\n\n const validator = new Validator()\n const result = await validator.validate(filesystem, options)\n\n return {\n ...result,\n specification: validator.specification as OpenAPI.Document,\n version: validator.version,\n }\n}\n"],
4
+ "sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\n\nimport { Validator } from '@/lib/Validator/Validator'\nimport type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '@/types/index'\nimport { makeFilesystem } from './make-filesystem'\n\nexport type ValidateOptions = ThrowOnErrorOption\n\n/**\n * Validates an OpenAPI document\n */\nexport async function validate(\n value: string | AnyObject | Filesystem,\n options?: ValidateOptions,\n): Promise<ValidateResult> {\n const filesystem = makeFilesystem(value)\n\n const validator = new Validator()\n const result = await validator.validate(filesystem, options)\n\n return {\n ...result,\n specification: validator.specification as OpenAPI.Document,\n version: validator.version,\n }\n}\n"],
5
5
  "mappings": "AAEA,SAAS,iBAAiB;AAE1B,SAAS,sBAAsB;AAO/B,eAAsB,SACpB,OACA,SACyB;AACzB,QAAM,aAAa,eAAe,KAAK;AAEvC,QAAM,YAAY,IAAI,UAAU;AAChC,QAAM,SAAS,MAAM,UAAU,SAAS,YAAY,OAAO;AAE3D,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,UAAU;AAAA,IACzB,SAAS,UAAU;AAAA,EACrB;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "parser",
18
18
  "typescript"
19
19
  ],
20
- "version": "0.11.1",
20
+ "version": "0.13.0",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -57,14 +57,14 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@apidevtools/swagger-parser": "^10.1.0",
60
- "@babel/code-frame": "^7.24.7",
61
60
  "@types/node": "^20.17.10",
62
61
  "glob": "^10.3.10",
63
62
  "json-to-ast": "^2.1.0",
64
63
  "just-diff": "^6.0.2",
65
64
  "tinybench": "^2.8.0",
66
- "@scalar/build-tooling": "0.2.0",
65
+ "vite": "5.4.19",
67
66
  "@scalar/openapi-types": "0.3.1",
67
+ "@scalar/build-tooling": "0.2.1",
68
68
  "@scalar/types": "0.2.1"
69
69
  },
70
70
  "scripts": {
@@ -1,8 +0,0 @@
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
@@ -1,7 +0,0 @@
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 +0,0 @@
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,7 +0,0 @@
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
- }
@@ -1,50 +0,0 @@
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
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/fetch-urls/fetchUrls.test.ts"],
4
- "sourcesContent": ["import { beforeEach, describe, expect, it, vi } from 'vitest'\n\nimport { fetchUrls } from './fetchUrls'\n\nglobal.fetch = vi.fn()\n\ndescribe('fetchUrls', async () => {\n beforeEach(() => {\n // @ts-expect-error\n global.fetch.mockReset()\n })\n\n it('returns true for an url', async () => {\n expect(fetchUrls().check('http://example.com/specification/openapi.yaml')).toBe(true)\n })\n\n it('returns false for a filename', async () => {\n expect(fetchUrls().check('openapi.yaml')).toBe(false)\n })\n\n it('returns false for a path', async () => {\n expect(fetchUrls().check('specification/openapi.yaml')).toBe(false)\n })\n\n it('returns false for an object', async () => {\n expect(fetchUrls().check({})).toBe(false)\n })\n\n it('returns false for undefinded', async () => {\n expect(fetchUrls().check()).toBe(false)\n })\n\n it('fetches the URL', async () => {\n // @ts-expect-error\n fetch.mockImplementation(async (url: string) => ({\n text: async () => {\n if (url === 'http://example.com/specification/openapi.yaml') {\n return 'OK'\n }\n\n throw new Error('Not found')\n },\n }))\n\n expect(await fetchUrls().get('http://example.com/specification/openapi.yaml')).toBe('OK')\n })\n\n it('rewrites the URL', async () => {\n // @ts-expect-error\n fetch.mockImplementation(async (url: string) => ({\n text: async () => {\n if (url === 'http://foobar.com/specification/openapi.yaml') {\n return 'OK'\n }\n throw new Error('Not found')\n },\n }))\n\n expect(\n await fetchUrls({\n fetch: (url) => fetch(url.replace('example', 'foobar')),\n }).get('http://foobar.com/specification/openapi.yaml'),\n ).toBe('OK')\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,YAAY,UAAU,QAAQ,IAAI,UAAU;AAErD,SAAS,iBAAiB;AAE1B,OAAO,QAAQ,GAAG,GAAG;AAErB,SAAS,aAAa,YAAY;AAChC,aAAW,MAAM;AAEf,WAAO,MAAM,UAAU;AAAA,EACzB,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,WAAO,UAAU,EAAE,MAAM,+CAA+C,CAAC,EAAE,KAAK,IAAI;AAAA,EACtF,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,cAAc,CAAC,EAAE,KAAK,KAAK;AAAA,EACtD,CAAC;AAED,KAAG,4BAA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2
- "version": 3,
3
- "sources": ["../../../src/plugins/read-files/readFiles.ts"],
4
- "sourcesContent": ["import fs from 'node:fs'\n\nimport { ERRORS } from '../../configuration/index'\nimport { dirname, join } from '../../polyfills/path'\nimport { isJson } from '../../utils/isJson'\nimport { isYaml } from '../../utils/isYaml'\nimport type { LoadPlugin } from '../../utils/load/load'\n\nexport const readFiles: () => LoadPlugin = () => {\n return {\n check(value?: any) {\n // Not a string\n if (typeof value !== 'string') {\n return false\n }\n\n // URL\n if (value.startsWith('http://') || value.startsWith('https://')) {\n return false\n }\n\n // Line breaks\n if (value.includes('\\n')) {\n return false\n }\n\n // JSON\n if (isJson(value)) {\n return false\n }\n\n // YAML (run through YAML.parse)\n if (isYaml(value)) {\n return false\n }\n\n return true\n },\n async get(value?: any) {\n if (!fs.existsSync(value)) {\n throw new Error(ERRORS.FILE_DOES_NOT_EXIST.replace('%s', value))\n }\n\n try {\n return fs.readFileSync(value, 'utf-8')\n } catch (error) {\n console.error('[readFiles]', error)\n return false\n }\n },\n resolvePath(value: any, reference: string) {\n const dir = dirname(value)\n return join(dir, reference)\n },\n getDir(value: any) {\n return dirname(value)\n },\n getFilename(value: any) {\n return value.split('/').pop()\n },\n }\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AAEf,SAAS,cAAc;AACvB,SAAS,SAAS,YAAY;AAC9B,SAAS,cAAc;AACvB,SAAS,cAAc;AAGhB,MAAM,YAA8B,MAAM;AAC/C,SAAO;AAAA,IACL,MAAM,OAAa;AAEjB,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAGA,UAAI,MAAM,WAAW,SAAS,KAAK,MAAM,WAAW,UAAU,GAAG;AAC/D,eAAO;AAAA,MACT;AAGA,UAAI,MAAM,SAAS,IAAI,GAAG;AACxB,eAAO;AAAA,MACT;AAGA,UAAI,OAAO,KAAK,GAAG;AACjB,eAAO;AAAA,MACT;AAGA,UAAI,OAAO,KAAK,GAAG;AACjB,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,IAAI,OAAa;AACrB,UAAI,CAAC,GAAG,WAAW,KAAK,GAAG;AACzB,cAAM,IAAI,MAAM,OAAO,oBAAoB,QAAQ,MAAM,KAAK,CAAC;AAAA,MACjE;AAEA,UAAI;AACF,eAAO,GAAG,aAAa,OAAO,OAAO;AAAA,MACvC,SAAS,OAAO;AACd,gBAAQ,MAAM,eAAe,KAAK;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,YAAY,OAAY,WAAmB;AACzC,YAAM,MAAM,QAAQ,KAAK;AACzB,aAAO,KAAK,KAAK,SAAS;AAAA,IAC5B;AAAA,IACA,OAAO,OAAY;AACjB,aAAO,QAAQ,KAAK;AAAA,IACtB;AAAA,IACA,YAAY,OAAY;AACtB,aAAO,MAAM,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9B;AAAA,EACF;AACF;",
6
- "names": []
7
- }
@@ -1,20 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { readFiles } from "./readFiles.js";
3
- describe("readFiles", async () => {
4
- it("returns true for a filename", async () => {
5
- expect(readFiles().check("openapi.yaml")).toBe(true);
6
- });
7
- it("returns true for a path", async () => {
8
- expect(readFiles().check("../specification/openapi.yaml")).toBe(true);
9
- });
10
- it("returns false for an object", async () => {
11
- expect(readFiles().check({})).toBe(false);
12
- });
13
- it("returns false for undefinded", async () => {
14
- expect(readFiles().check()).toBe(false);
15
- });
16
- it("returns false for an url", async () => {
17
- expect(readFiles().check("http://example.com/specification/openapi.yaml")).toBe(false);
18
- });
19
- });
20
- //# sourceMappingURL=readFiles.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/read-files/readFiles.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { readFiles } from './readFiles'\n\ndescribe('readFiles', async () => {\n it('returns true for a filename', async () => {\n expect(readFiles().check('openapi.yaml')).toBe(true)\n })\n\n it('returns true for a path', async () => {\n expect(readFiles().check('../specification/openapi.yaml')).toBe(true)\n })\n\n it('returns false for an object', async () => {\n expect(readFiles().check({})).toBe(false)\n })\n\n it('returns false for undefinded', async () => {\n expect(readFiles().check()).toBe(false)\n })\n\n it('returns false for an url', async () => {\n expect(readFiles().check('http://example.com/specification/openapi.yaml')).toBe(false)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,iBAAiB;AAE1B,SAAS,aAAa,YAAY;AAChC,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,cAAc,CAAC,EAAE,KAAK,IAAI;AAAA,EACrD,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,WAAO,UAAU,EAAE,MAAM,+BAA+B,CAAC,EAAE,KAAK,IAAI;AAAA,EACtE,CAAC;AAED,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK;AAAA,EAC1C,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,EACxC,CAAC;AAED,KAAG,4BAA4B,YAAY;AACzC,WAAO,UAAU,EAAE,MAAM,+CAA+C,CAAC,EAAE,KAAK,KAAK;AAAA,EACvF,CAAC;AACH,CAAC;",
6
- "names": []
7
- }