@scalar/openapi-parser 0.10.13 → 0.10.15

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 (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +22 -0
  3. package/dist/lib/Validator/Validator.js +1 -1
  4. package/dist/plugins/fetch-urls/fetchUrls.d.ts +1 -0
  5. package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +1 -1
  6. package/dist/plugins/fetch-urls/fetchUrls.js +79 -7
  7. package/dist/plugins/fetch-urls/index.d.ts +1 -1
  8. package/dist/plugins/fetch-urls/index.d.ts.map +1 -1
  9. package/dist/plugins/fetch-urls/index.js +1 -1
  10. package/dist/plugins/read-files/index.d.ts +1 -1
  11. package/dist/plugins/read-files/index.d.ts.map +1 -1
  12. package/dist/plugins/read-files/readFiles.d.ts.map +1 -1
  13. package/dist/plugins/read-files/readFiles.js +18 -3
  14. package/dist/types/index.d.ts +23 -4
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/utils/dereference.js +2 -2
  17. package/dist/utils/filter.js +1 -1
  18. package/dist/utils/isFilesystem.d.ts +2 -1
  19. package/dist/utils/isFilesystem.d.ts.map +1 -1
  20. package/dist/utils/load/load.d.ts +11 -2
  21. package/dist/utils/load/load.d.ts.map +1 -1
  22. package/dist/utils/load/load.js +77 -38
  23. package/dist/utils/makeFilesystem.d.ts +18 -1
  24. package/dist/utils/makeFilesystem.d.ts.map +1 -1
  25. package/dist/utils/makeFilesystem.js +55 -9
  26. package/dist/utils/openapi/actions/details.js +1 -1
  27. package/dist/utils/openapi/actions/toJson.js +1 -1
  28. package/dist/utils/openapi/actions/toYaml.js +1 -1
  29. package/dist/utils/openapi/commands/loadCommand.d.ts +180 -180
  30. package/dist/utils/resolveReferences.d.ts +6 -0
  31. package/dist/utils/resolveReferences.d.ts.map +1 -1
  32. package/dist/utils/resolveReferences.js +19 -9
  33. package/dist/utils/upgrade.js +1 -1
  34. package/dist/utils/upgradeFromTwoToThree.d.ts.map +1 -1
  35. package/dist/utils/upgradeFromTwoToThree.js +58 -0
  36. package/package.json +4 -3
@@ -1,25 +1,71 @@
1
- import { getListOfReferences } from './getListOfReferences.js';
2
1
  import { isFilesystem } from './isFilesystem.js';
3
2
  import { normalize } from './normalize.js';
4
3
 
5
- function makeFilesystem(value, overwrites = {}) {
4
+ function makeFilesystem(
5
+ /**
6
+ * Pass whatever you have, it will be normalized and then used as the content.
7
+ */
8
+ value,
9
+ /**
10
+ * If you know better, you can overwrite the default values.
11
+ */
12
+ overwrites) {
6
13
  // Keep as is
7
14
  if (isFilesystem(value)) {
8
15
  return value;
9
16
  }
17
+ // Just create it from an existing entry
18
+ if (isFilesystemEntry(value)) {
19
+ return [
20
+ makeFilesystemEntry(value.content, {
21
+ isEntrypoint: true,
22
+ }),
23
+ ];
24
+ }
10
25
  // Make an object
11
- const specification = normalize(value);
26
+ const content = normalize(value);
12
27
  // Create fake filesystem
13
28
  return [
14
29
  {
15
30
  isEntrypoint: true,
16
- specification,
17
- filename: null,
18
- dir: './',
19
- references: getListOfReferences(specification),
20
- ...overwrites,
31
+ content,
32
+ uri: undefined,
33
+ references: {},
34
+ ...({}),
21
35
  },
22
36
  ];
23
37
  }
38
+ function makeFilesystemEntry(
39
+ /**
40
+ * Pass whatever you have, it will be normalized and then used as the content.
41
+ */
42
+ value,
43
+ /**
44
+ * If you know better, you can overwrite the default values.
45
+ */
46
+ overwrites) {
47
+ // Keep as is
48
+ if (isFilesystemEntry(value)) {
49
+ return {
50
+ ...value,
51
+ ...(overwrites ?? {}),
52
+ };
53
+ }
54
+ // Make an object
55
+ const content = normalize(value);
56
+ return {
57
+ isEntrypoint: true,
58
+ content,
59
+ uri: null,
60
+ references: {},
61
+ ...(overwrites ?? {}),
62
+ };
63
+ }
64
+ /**
65
+ * Check whether the value is a filesystem entry already.
66
+ */
67
+ const isFilesystemEntry = (value) => {
68
+ return typeof value === 'object' && value !== null && !Array.isArray(value) && 'isEntrypoint' in value;
69
+ };
24
70
 
25
- export { makeFilesystem };
71
+ export { makeFilesystem, makeFilesystemEntry };
@@ -7,7 +7,7 @@ import { workThroughQueue } from '../utils/workThroughQueue.js';
7
7
  */
8
8
  async function details(queue) {
9
9
  const { filesystem } = await workThroughQueue(queue);
10
- return details$1(getEntrypoint(filesystem).specification);
10
+ return details$1(getEntrypoint(filesystem).content);
11
11
  }
12
12
 
13
13
  export { details };
@@ -7,7 +7,7 @@ import { workThroughQueue } from '../utils/workThroughQueue.js';
7
7
  */
8
8
  async function toJson(queue) {
9
9
  const { filesystem } = await workThroughQueue(queue);
10
- return toJson$1(getEntrypoint(filesystem).specification);
10
+ return toJson$1(getEntrypoint(filesystem).content);
11
11
  }
12
12
 
13
13
  export { toJson };
@@ -7,7 +7,7 @@ import { workThroughQueue } from '../utils/workThroughQueue.js';
7
7
  */
8
8
  async function toYaml(queue) {
9
9
  const { filesystem } = await workThroughQueue(queue);
10
- return toYaml$1(getEntrypoint(filesystem).specification);
10
+ return toYaml$1(getEntrypoint(filesystem).content);
11
11
  }
12
12
 
13
13
  export { toYaml };