@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,300 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { dereference } from "./dereference.js";
3
- describe("dereference", async () => {
4
- it("dereferences an OpenAPI 3.1.0 file", async () => {
5
- const result = await dereference(`{
6
- "openapi": "3.1.0",
7
- "info": {
8
- "title": "Hello World",
9
- "version": "1.0.0"
10
- },
11
- "paths": {}
12
- }`);
13
- expect(result.errors).toStrictEqual([]);
14
- expect(result.schema.info.title).toBe("Hello World");
15
- });
16
- it("dereferences an OpenAPI 3.0.0 file", async () => {
17
- const result = await dereference(`{
18
- "openapi": "3.0.0",
19
- "info": {
20
- "title": "Hello World",
21
- "version": "1.0.0"
22
- },
23
- "paths": {}
24
- }`);
25
- expect(result.errors).toStrictEqual([]);
26
- expect(result.schema.info.title).toBe("Hello World");
27
- });
28
- it("dereferences an Swagger 2.0 file", async () => {
29
- const result = await dereference(`{
30
- "swagger": "2.0",
31
- "info": {
32
- "title": "Hello World",
33
- "version": "1.0.0"
34
- },
35
- "paths": {}
36
- }`);
37
- expect(result.errors).toStrictEqual([]);
38
- expect(result.schema.info.title).toBe("Hello World");
39
- });
40
- it("returns version 3.1", async () => {
41
- const result = await dereference(`{
42
- "openapi": "3.1.0",
43
- "info": {
44
- "title": "Hello World",
45
- "version": "1.0.0"
46
- },
47
- "paths": {}
48
- }`);
49
- expect(result.errors).toStrictEqual([]);
50
- expect(result.version).toBe("3.1");
51
- });
52
- it("returns version 3.0", async () => {
53
- const result = await dereference(`{
54
- "openapi": "3.0.0",
55
- "info": {
56
- "title": "Hello World",
57
- "version": "1.0.0"
58
- },
59
- "paths": {}
60
- }`);
61
- expect(result.errors).toStrictEqual([]);
62
- expect(result.version).toBe("3.0");
63
- });
64
- it("returns version 2.0", async () => {
65
- const result = await dereference(`{
66
- "swagger": "2.0",
67
- "info": {
68
- "title": "Hello World",
69
- "version": "1.0.0"
70
- },
71
- "paths": {}
72
- }`);
73
- expect(result.errors).toStrictEqual([]);
74
- expect(result.version).toBe("2.0");
75
- });
76
- it("doesn\u2019t return version 4.0", async () => {
77
- const result = await dereference(`{
78
- "openapi": "4.0",
79
- "info": {
80
- "title": "Hello World",
81
- "version": "1.0.0"
82
- },
83
- "paths": {}
84
- }`);
85
- expect(result.version).toBe(void 0);
86
- });
87
- it("dereferences a simple reference", async () => {
88
- const openapi = {
89
- openapi: "3.1.0",
90
- info: {
91
- title: "Hello World",
92
- version: "1.0.0"
93
- },
94
- paths: {
95
- "/test": {
96
- get: {
97
- responses: {
98
- "200": {
99
- // TODO: This is valid in @apidevtools/swagger, but not with our implementation
100
- description: "foobar",
101
- content: {
102
- "application/json": {
103
- schema: {
104
- $ref: "#/components/schemas/Test"
105
- }
106
- }
107
- }
108
- }
109
- }
110
- }
111
- }
112
- },
113
- components: {
114
- schemas: {
115
- Test: {
116
- type: "object",
117
- properties: {
118
- id: {
119
- type: "string"
120
- }
121
- }
122
- }
123
- }
124
- }
125
- };
126
- const result = await dereference(openapi);
127
- expect(result.errors).toStrictEqual([]);
128
- expect(result.specification.paths["/test"].get.responses["200"].content["application/json"].schema).toEqual({
129
- $ref: "#/components/schemas/Test"
130
- });
131
- expect(result.schema.paths["/test"].get.responses["200"].content["application/json"].schema).toEqual({
132
- type: "object",
133
- properties: {
134
- id: {
135
- type: "string"
136
- }
137
- }
138
- });
139
- });
140
- it("throws an error", async () => {
141
- expect(async () => {
142
- await dereference(
143
- {
144
- openapi: "3.1.0",
145
- info: {},
146
- paths: {
147
- "/foobar": {
148
- post: {
149
- requestBody: {
150
- $ref: "#/components/requestBodies/DoesNotExist"
151
- }
152
- }
153
- }
154
- }
155
- },
156
- {
157
- throwOnError: true
158
- }
159
- );
160
- }).rejects.toThrowError("Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist");
161
- });
162
- it("resolves external file references", async () => {
163
- const filesystem = [
164
- {
165
- isEntrypoint: true,
166
- specification: {
167
- openapi: "3.1.0",
168
- info: {
169
- title: "File Reference",
170
- version: "1.0.0"
171
- },
172
- paths: {},
173
- components: {
174
- schemas: {
175
- ExternalSchema: {
176
- $ref: "valid.yaml#/components/schemas/ExampleSchema"
177
- }
178
- }
179
- }
180
- },
181
- filename: "file-reference.yaml",
182
- dir: "./",
183
- references: ["valid.yaml"]
184
- },
185
- {
186
- isEntrypoint: false,
187
- specification: {
188
- openapi: "3.1.0",
189
- info: {
190
- title: "Hello World",
191
- version: "1.0.0"
192
- },
193
- paths: {},
194
- components: {
195
- schemas: {
196
- ExampleSchema: {
197
- type: "object",
198
- properties: {
199
- id: {
200
- type: "integer",
201
- description: "Unique identifier for the example"
202
- },
203
- name: {
204
- type: "string",
205
- description: "Name of the example"
206
- },
207
- description: {
208
- type: "string",
209
- description: "Detailed description of the example"
210
- }
211
- },
212
- required: ["id", "name"]
213
- }
214
- }
215
- }
216
- },
217
- filename: "valid.yaml",
218
- dir: "./",
219
- references: []
220
- }
221
- ];
222
- const result = await dereference(filesystem);
223
- expect(result.errors).toStrictEqual([]);
224
- expect(result.schema.components.schemas.ExternalSchema).toEqual({
225
- type: "object",
226
- properties: {
227
- id: {
228
- type: "integer",
229
- description: "Unique identifier for the example"
230
- },
231
- name: {
232
- type: "string",
233
- description: "Name of the example"
234
- },
235
- description: {
236
- type: "string",
237
- description: "Detailed description of the example"
238
- }
239
- },
240
- required: ["id", "name"]
241
- });
242
- });
243
- it("calls onDereference when resolving references", async () => {
244
- const openapi = {
245
- openapi: "3.1.0",
246
- info: {
247
- title: "Hello World",
248
- version: "1.0.0"
249
- },
250
- paths: {
251
- "/test": {
252
- get: {
253
- responses: {
254
- "200": {
255
- description: "foobar",
256
- content: {
257
- "application/json": {
258
- schema: {
259
- $ref: "#/components/schemas/Test"
260
- }
261
- }
262
- }
263
- }
264
- }
265
- }
266
- }
267
- },
268
- components: {
269
- schemas: {
270
- Test: {
271
- type: "object",
272
- properties: {
273
- id: {
274
- type: "string"
275
- }
276
- }
277
- }
278
- }
279
- }
280
- };
281
- const dereferencedSchemas = [];
282
- const result = await dereference(openapi, {
283
- onDereference: ({ schema, ref }) => {
284
- expect(schema).toEqual({
285
- type: "object",
286
- properties: {
287
- id: {
288
- type: "string"
289
- }
290
- }
291
- });
292
- expect(ref).toEqual("#/components/schemas/Test");
293
- dereferencedSchemas.push({ schema, ref });
294
- }
295
- });
296
- expect(result.errors).toStrictEqual([]);
297
- expect(dereferencedSchemas).toHaveLength(1);
298
- });
299
- });
300
- //# sourceMappingURL=dereference.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/dereference.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { dereference } from './dereference'\n\ndescribe('dereference', async () => {\n it('dereferences an OpenAPI 3.1.0 file', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('dereferences an OpenAPI 3.0.0 file', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.0.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('dereferences an Swagger 2.0 file', async () => {\n const result = await dereference(`{\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('returns version 3.1', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.version).toBe('3.1')\n })\n\n it('returns version 3.0', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.0.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.version).toBe('3.0')\n })\n\n it('returns version 2.0', async () => {\n const result = await dereference(`{\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.version).toBe('2.0')\n })\n\n it('doesn\u2019t return version 4.0', async () => {\n const result = await dereference(`{\n \"openapi\": \"4.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.version).toBe(undefined)\n })\n\n it('dereferences a simple reference', async () => {\n const openapi = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n responses: {\n '200': {\n // TODO: This is valid in @apidevtools/swagger, but not with our implementation\n description: 'foobar',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/Test',\n },\n },\n },\n },\n },\n },\n },\n },\n components: {\n schemas: {\n Test: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n },\n },\n },\n }\n\n const result = await dereference(openapi)\n\n expect(result.errors).toStrictEqual([])\n\n // Original\n expect(result.specification.paths['/test'].get.responses['200'].content['application/json'].schema).toEqual({\n $ref: '#/components/schemas/Test',\n })\n\n // Resolved references\n expect(result.schema.paths['/test'].get.responses['200'].content['application/json'].schema).toEqual({\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n })\n })\n\n it('throws an error', async () => {\n expect(async () => {\n await dereference(\n {\n openapi: '3.1.0',\n info: {},\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: '#/components/requestBodies/DoesNotExist',\n },\n },\n },\n },\n },\n {\n throwOnError: true,\n },\n )\n }).rejects.toThrowError('Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist')\n })\n\n it('resolves external file references', async () => {\n const filesystem = [\n {\n isEntrypoint: true,\n specification: {\n openapi: '3.1.0',\n info: {\n title: 'File Reference',\n version: '1.0.0',\n },\n paths: {},\n components: {\n schemas: {\n ExternalSchema: {\n $ref: 'valid.yaml#/components/schemas/ExampleSchema',\n },\n },\n },\n },\n filename: 'file-reference.yaml',\n dir: './',\n references: ['valid.yaml'],\n },\n {\n isEntrypoint: false,\n specification: {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n components: {\n schemas: {\n ExampleSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'integer',\n description: 'Unique identifier for the example',\n },\n name: {\n type: 'string',\n description: 'Name of the example',\n },\n description: {\n type: 'string',\n description: 'Detailed description of the example',\n },\n },\n required: ['id', 'name'],\n },\n },\n },\n },\n filename: 'valid.yaml',\n dir: './',\n references: [],\n },\n ]\n\n const result = await dereference(filesystem)\n\n expect(result.errors).toStrictEqual([])\n\n // Check if the external reference was resolved\n expect(result.schema.components.schemas.ExternalSchema).toEqual({\n type: 'object',\n properties: {\n id: {\n type: 'integer',\n description: 'Unique identifier for the example',\n },\n name: {\n type: 'string',\n description: 'Name of the example',\n },\n description: {\n type: 'string',\n description: 'Detailed description of the example',\n },\n },\n required: ['id', 'name'],\n })\n })\n\n it('calls onDereference when resolving references', async () => {\n const openapi = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n responses: {\n '200': {\n description: 'foobar',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/Test',\n },\n },\n },\n },\n },\n },\n },\n },\n components: {\n schemas: {\n Test: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n },\n },\n },\n }\n\n const dereferencedSchemas: Array<{ schema: any; ref: string }> = []\n\n const result = await dereference(openapi, {\n onDereference: ({ schema, ref }) => {\n expect(schema).toEqual({\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n })\n\n expect(ref).toEqual('#/components/schemas/Test')\n\n dereferencedSchemas.push({ schema, ref })\n },\n })\n\n expect(result.errors).toStrictEqual([])\n expect(dereferencedSchemas).toHaveLength(1)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAA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QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,sBAA2D,CAAC;AAElE,UAAM,SAAS,MAAM,YAAY,SAAS;AAAA,MACxC,eAAe,CAAC,EAAE,QAAQ,IAAI,MAAM;AAClC,eAAO,MAAM,EAAE,QAAQ;AAAA,UACrB,MAAM;AAAA,UACN,YAAY;AAAA,YACV,IAAI;AAAA,cACF,MAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF,CAAC;AAED,eAAO,GAAG,EAAE,QAAQ,2BAA2B;AAE/C,4BAAoB,KAAK,EAAE,QAAQ,IAAI,CAAC;AAAA,MAC1C;AAAA,IACF,CAAC;AAED,WAAO,OAAO,MAAM,EAAE,cAAc,CAAC,CAAC;AACtC,WAAO,mBAAmB,EAAE,aAAa,CAAC;AAAA,EAC5C,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,48 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { validate } from "./validate.js";
3
- describe("errors", () => {
4
- it("info required", async () => {
5
- const result = await validate({
6
- openapi: "3.1.0",
7
- paths: {}
8
- });
9
- expect(result).toMatchObject({
10
- errors: [
11
- {
12
- message: `must have required property 'info'`
13
- }
14
- ],
15
- valid: false
16
- });
17
- });
18
- it("unevaluated property", async () => {
19
- const spec = {
20
- openapi: "3.1.0",
21
- info: {
22
- title: "Hello World",
23
- version: "1.0.0"
24
- },
25
- paths: {
26
- "/test": {
27
- foobar: {
28
- responses: {
29
- 200: {
30
- description: "OK"
31
- }
32
- }
33
- }
34
- }
35
- }
36
- };
37
- const result = await validate(spec);
38
- expect(result).toMatchObject({
39
- errors: [
40
- {
41
- message: "Property foobar is not expected to be here"
42
- }
43
- ],
44
- valid: false
45
- });
46
- });
47
- });
48
- //# sourceMappingURL=errors.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/errors.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { validate } from './validate'\n\ndescribe('errors', () => {\n it('info required', async () => {\n const result = await validate({\n openapi: '3.1.0',\n paths: {},\n })\n\n expect(result).toMatchObject({\n errors: [\n {\n message: `must have required property 'info'`,\n },\n ],\n valid: false,\n })\n })\n\n it('unevaluated property', async () => {\n const spec = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n foobar: {\n responses: {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n },\n }\n const result = await validate(spec)\n\n expect(result).toMatchObject({\n errors: [\n {\n message: 'Property foobar is not expected to be here',\n },\n ],\n valid: false,\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,gBAAgB;AAEzB,SAAS,UAAU,MAAM;AACvB,KAAG,iBAAiB,YAAY;AAC9B,UAAM,SAAS,MAAM,SAAS;AAAA,MAC5B,SAAS;AAAA,MACT,OAAO,CAAC;AAAA,IACV,CAAC;AAED,WAAO,MAAM,EAAE,cAAc;AAAA,MAC3B,QAAQ;AAAA,QACN;AAAA,UACE,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAAA,EACH,CAAC;AAED,KAAG,wBAAwB,YAAY;AACrC,UAAM,OAAO;AAAA,MACX,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,OAAO;AAAA,QACL,SAAS;AAAA,UACP,QAAQ;AAAA,YACN,WAAW;AAAA,cACT,KAAK;AAAA,gBACH,aAAa;AAAA,cACf;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,UAAM,SAAS,MAAM,SAAS,IAAI;AAElC,WAAO,MAAM,EAAE,cAAc;AAAA,MAC3B,QAAQ;AAAA,QACN;AAAA,UACE,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"escapeJsonPointer.d.ts","sourceRoot":"","sources":["../../src/utils/escapeJsonPointer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,UAE5C"}
@@ -1,11 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { escapeJsonPointer } from "./escapeJsonPointer.js";
3
- describe("escapeJsonPointer", async () => {
4
- it("should escape a slash", () => {
5
- expect(escapeJsonPointer("application/json")).toBe("application~1json");
6
- });
7
- it("should escape multiple slashes", () => {
8
- expect(escapeJsonPointer("/api/users/{id}/reports")).toBe("~1api~1users~1{id}~1reports");
9
- });
10
- });
11
- //# sourceMappingURL=escapeJsonPointer.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/escapeJsonPointer.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { escapeJsonPointer } from './escapeJsonPointer'\n\ndescribe('escapeJsonPointer', async () => {\n it('should escape a slash', () => {\n expect(escapeJsonPointer('application/json')).toBe('application~1json')\n })\n\n it('should escape multiple slashes', () => {\n expect(escapeJsonPointer('/api/users/{id}/reports')).toBe('~1api~1users~1{id}~1reports')\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,yBAAyB;AAElC,SAAS,qBAAqB,YAAY;AACxC,KAAG,yBAAyB,MAAM;AAChC,WAAO,kBAAkB,kBAAkB,CAAC,EAAE,KAAK,mBAAmB;AAAA,EACxE,CAAC;AAED,KAAG,kCAAkC,MAAM;AACzC,WAAO,kBAAkB,yBAAyB,CAAC,EAAE,KAAK,6BAA6B;AAAA,EACzF,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"getEntrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/getEntrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEjE;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS,CAElF"}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/getEntrypoint.ts"],
4
- "sourcesContent": ["import type { Filesystem, FilesystemEntry } from '../types/index'\n\n/**\n * Return just the entrypoint of the filesystem.\n */\nexport function getEntrypoint(filesystem?: Filesystem): FilesystemEntry | undefined {\n return filesystem?.find((file) => file.isEntrypoint)\n}\n"],
5
- "mappings": "AAKO,SAAS,cAAc,YAAsD;AAClF,SAAO,YAAY,KAAK,CAAC,SAAS,KAAK,YAAY;AACrD;",
6
- "names": []
7
- }
@@ -1,18 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { getEntrypoint } from "./getEntrypoint.js";
3
- import { makeFilesystem } from "./makeFilesystem.js";
4
- describe("getEntrypoint", () => {
5
- it("keeps the object reference", () => {
6
- const result = makeFilesystem({
7
- foo: "bar"
8
- });
9
- const entrypoint = getEntrypoint(result);
10
- entrypoint.specification.foo = "baz";
11
- expect(result[0].specification.foo).toBe("baz");
12
- });
13
- it("returns undefined for an empty filesystem", () => {
14
- const entrypoint = getEntrypoint([]);
15
- expect(entrypoint).toBe(void 0);
16
- });
17
- });
18
- //# sourceMappingURL=getEntrypoint.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/getEntrypoint.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { getEntrypoint } from './getEntrypoint'\nimport { makeFilesystem } from './makeFilesystem'\n\ndescribe('getEntrypoint', () => {\n it('keeps the object reference', () => {\n const result = makeFilesystem({\n foo: 'bar',\n })\n\n const entrypoint = getEntrypoint(result)\n\n // Modify the entrypoint\n entrypoint.specification.foo = 'baz'\n\n // Check whether the original was modified\n expect(result[0].specification.foo).toBe('baz')\n })\n\n it('returns undefined for an empty filesystem', () => {\n const entrypoint = getEntrypoint([])\n\n // Check whether the original was modified\n expect(entrypoint).toBe(undefined)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAE/B,SAAS,iBAAiB,MAAM;AAC9B,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,eAAe;AAAA,MAC5B,KAAK;AAAA,IACP,CAAC;AAED,UAAM,aAAa,cAAc,MAAM;AAGvC,eAAW,cAAc,MAAM;AAG/B,WAAO,OAAO,CAAC,EAAE,cAAc,GAAG,EAAE,KAAK,KAAK;AAAA,EAChD,CAAC;AAED,KAAG,6CAA6C,MAAM;AACpD,UAAM,aAAa,cAAc,CAAC,CAAC;AAGnC,WAAO,UAAU,EAAE,KAAK,MAAS;AAAA,EACnC,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"getListOfReferences.d.ts","sourceRoot":"","sources":["../../src/utils/getListOfReferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,YAmB3D"}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/getListOfReferences.ts"],
4
- "sourcesContent": ["import type { AnyObject } from '../types/index'\nimport { traverse } from './traverse'\n\n/**\n * Walks through the specification and returns all references as an array.\n *\n * Warning: Doesn\u2019t return internal references.\n */\nexport function getListOfReferences(specification: AnyObject) {\n const references: string[] = []\n\n // Make sure we\u2019re dealing with an object\n if (!specification || typeof specification !== 'object') {\n return references\n }\n\n // Traverse the specification and collect all references\n traverse(specification, (value: any) => {\n if (value.$ref && typeof value.$ref === 'string' && !value.$ref.startsWith('#')) {\n references.push(value.$ref.split('#')[0])\n }\n\n return value\n })\n\n // Remove duplicates\n return [...new Set(references)]\n}\n"],
5
- "mappings": "AACA,SAAS,gBAAgB;AAOlB,SAAS,oBAAoB,eAA0B;AAC5D,QAAM,aAAuB,CAAC;AAG9B,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AAGA,WAAS,eAAe,CAAC,UAAe;AACtC,QAAI,MAAM,QAAQ,OAAO,MAAM,SAAS,YAAY,CAAC,MAAM,KAAK,WAAW,GAAG,GAAG;AAC/E,iBAAW,KAAK,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,IAC1C;AAEA,WAAO;AAAA,EACT,CAAC;AAGD,SAAO,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC;AAChC;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSegmentsFromPath.d.ts","sourceRoot":"","sources":["../../src/utils/getSegmentsFromPath.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,YAW/C"}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/getSegmentsFromPath.ts"],
4
- "sourcesContent": ["import { unescapeJsonPointer } from './unescapeJsonPointer'\n\n/**\n * Translate `/paths/~1test` to `['paths', '/test']`\n */\nexport function getSegmentsFromPath(path: string) {\n return (\n // /paths/~1test\n path\n // ['', 'paths', '~1test']\n .split('/')\n // ['paths', '~test']\n .slice(1)\n // ['paths', '/test']\n .map(unescapeJsonPointer)\n )\n}\n"],
5
- "mappings": "AAAA,SAAS,2BAA2B;AAK7B,SAAS,oBAAoB,MAAc;AAChD;AAAA;AAAA,IAEE,KAEG,MAAM,GAAG,EAET,MAAM,CAAC,EAEP,IAAI,mBAAmB;AAAA;AAE9B;",
6
- "names": []
7
- }
@@ -1,13 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { getSegmentsFromPath } from "./getSegmentsFromPath.js";
3
- describe("getSegmentsFromPath", () => {
4
- it("returns path segments", () => {
5
- const result = getSegmentsFromPath("/paths/test");
6
- expect(result).toEqual(["paths", "test"]);
7
- });
8
- it("unsescapes slashes", () => {
9
- const result = getSegmentsFromPath("/paths/~1test");
10
- expect(result).toEqual(["paths", "/test"]);
11
- });
12
- });
13
- //# sourceMappingURL=getSegmentsFromPath.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/getSegmentsFromPath.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { getSegmentsFromPath } from './getSegmentsFromPath'\n\ndescribe('getSegmentsFromPath', () => {\n it('returns path segments', () => {\n const result = getSegmentsFromPath('/paths/test')\n\n expect(result).toEqual(['paths', 'test'])\n })\n\n it('unsescapes slashes', () => {\n const result = getSegmentsFromPath('/paths/~1test')\n\n expect(result).toEqual(['paths', '/test'])\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,2BAA2B;AAEpC,SAAS,uBAAuB,MAAM;AACpC,KAAG,yBAAyB,MAAM;AAChC,UAAM,SAAS,oBAAoB,aAAa;AAEhD,WAAO,MAAM,EAAE,QAAQ,CAAC,SAAS,MAAM,CAAC;AAAA,EAC1C,CAAC;AAED,KAAG,sBAAsB,MAAM;AAC7B,UAAM,SAAS,oBAAoB,eAAe;AAElD,WAAO,MAAM,EAAE,QAAQ,CAAC,SAAS,OAAO,CAAC;AAAA,EAC3C,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,27 +0,0 @@
1
- export * from './dereference.js';
2
- export * from './details.js';
3
- export * from './escapeJsonPointer.js';
4
- export * from './filter.js';
5
- export * from './getEntrypoint.js';
6
- export * from './getListOfReferences.js';
7
- export * from './getSegmentsFromPath.js';
8
- export * from './isFilesystem.js';
9
- export * from './isJson.js';
10
- export * from './isObject.js';
11
- export * from './isYaml.js';
12
- export * from './load/index.js';
13
- export * from './load/load.js';
14
- export * from './normalize.js';
15
- export * from './openapi/index.js';
16
- export * from './resolveReferences.js';
17
- export * from './toJson.js';
18
- export * from './toYaml.js';
19
- export * from './transformErrors.js';
20
- export * from './traverse.js';
21
- export * from './unescapeJsonPointer.js';
22
- export * from './upgrade.js';
23
- export * from './upgradeFromThreeToThreeOne.js';
24
- export * from './upgradeFromTwoToThree.js';
25
- export * from './validate.js';
26
- export * from './transform/index.js';
27
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA"}
@@ -1,27 +0,0 @@
1
- export * from "./dereference.js";
2
- export * from "./details.js";
3
- export * from "./escapeJsonPointer.js";
4
- export * from "./filter.js";
5
- export * from "./getEntrypoint.js";
6
- export * from "./getListOfReferences.js";
7
- export * from "./getSegmentsFromPath.js";
8
- export * from "./isFilesystem.js";
9
- export * from "./isJson.js";
10
- export * from "./isObject.js";
11
- export * from "./isYaml.js";
12
- export * from "./load/index.js";
13
- export * from "./load/load.js";
14
- export * from "./normalize.js";
15
- export * from "./openapi/index.js";
16
- export * from "./resolveReferences.js";
17
- export * from "./toJson.js";
18
- export * from "./toYaml.js";
19
- export * from "./transformErrors.js";
20
- export * from "./traverse.js";
21
- export * from "./unescapeJsonPointer.js";
22
- export * from "./upgrade.js";
23
- export * from "./upgradeFromThreeToThreeOne.js";
24
- export * from "./upgradeFromTwoToThree.js";
25
- export * from "./validate.js";
26
- export * from "./transform/index.js";
27
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/index.ts"],
4
- "sourcesContent": ["export * from './dereference'\nexport * from './details'\nexport * from './escapeJsonPointer'\nexport * from './filter'\nexport * from './getEntrypoint'\nexport * from './getListOfReferences'\nexport * from './getSegmentsFromPath'\nexport * from './isFilesystem'\nexport * from './isJson'\nexport * from './isObject'\nexport * from './isYaml'\nexport * from './load/index'\nexport * from './load/load'\nexport * from './normalize'\nexport * from './openapi/index'\nexport * from './resolveReferences'\nexport * from './toJson'\nexport * from './toYaml'\nexport * from './transformErrors'\nexport * from './traverse'\nexport * from './unescapeJsonPointer'\nexport * from './upgrade'\nexport * from './upgradeFromThreeToThreeOne'\nexport * from './upgradeFromTwoToThree'\nexport * from './validate'\nexport * from './transform/index'\n"],
5
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"isFilesystem.d.ts","sourceRoot":"","sources":["../../src/utils/isFilesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,UAAU,CAO5D"}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/isFilesystem.ts"],
4
- "sourcesContent": ["import type { Filesystem } from '../types'\n\n/**\n * Check if the value is a filesystem\n */\nexport function isFilesystem(value: any): value is Filesystem {\n return (\n typeof value !== 'undefined' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.some((file) => file.isEntrypoint === true)\n )\n}\n"],
5
- "mappings": "AAKO,SAAS,aAAa,OAAiC;AAC5D,SACE,OAAO,UAAU,eACjB,MAAM,QAAQ,KAAK,KACnB,MAAM,SAAS,KACf,MAAM,KAAK,CAAC,SAAS,KAAK,iBAAiB,IAAI;AAEnD;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"isJson.d.ts","sourceRoot":"","sources":["../../src/utils/isJson.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,WAQnC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isObject.d.ts","sourceRoot":"","sources":["../../src/utils/isObject.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAS,GAAG,YAAmE,CAAA"}
@@ -1,23 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { isObject } from "./isObject.js";
3
- describe("isObject", () => {
4
- it("returns true for an object", () => {
5
- const result = isObject({
6
- foo: "bar"
7
- });
8
- expect(result).toBe(true);
9
- });
10
- it("returns true for an empty object", () => {
11
- const result = isObject({});
12
- expect(result).toBe(true);
13
- });
14
- it("returns false for a string", () => {
15
- const result = isObject("foo");
16
- expect(result).toBe(false);
17
- });
18
- it("returns false for an array", () => {
19
- const result = isObject([]);
20
- expect(result).toBe(false);
21
- });
22
- });
23
- //# sourceMappingURL=isObject.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/isObject.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isObject } from './isObject'\n\ndescribe('isObject', () => {\n it('returns true for an object', () => {\n const result = isObject({\n foo: 'bar',\n })\n expect(result).toBe(true)\n })\n\n it('returns true for an empty object', () => {\n const result = isObject({})\n expect(result).toBe(true)\n })\n\n it('returns false for a string', () => {\n const result = isObject('foo')\n expect(result).toBe(false)\n })\n\n it('returns false for an array', () => {\n const result = isObject([])\n expect(result).toBe(false)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,gBAAgB;AAEzB,SAAS,YAAY,MAAM;AACzB,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS;AAAA,MACtB,KAAK;AAAA,IACP,CAAC;AACD,WAAO,MAAM,EAAE,KAAK,IAAI;AAAA,EAC1B,CAAC;AAED,KAAG,oCAAoC,MAAM;AAC3C,UAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,WAAO,MAAM,EAAE,KAAK,IAAI;AAAA,EAC1B,CAAC;AAED,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS,KAAK;AAC7B,WAAO,MAAM,EAAE,KAAK,KAAK;AAAA,EAC3B,CAAC;AAED,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,WAAO,MAAM,EAAE,KAAK,KAAK;AAAA,EAC3B,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"isYaml.d.ts","sourceRoot":"","sources":["../../src/utils/isYaml.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,WAenC"}