@scalar/openapi-parser 0.25.4 → 0.25.5

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 (140) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/configuration/index.js +24 -24
  3. package/dist/index.js +24 -45
  4. package/dist/lib/Validator/Validator.js +125 -108
  5. package/dist/plugins/fetch-urls/fetch-urls.js +39 -38
  6. package/dist/plugins/fetch-urls/index.js +1 -6
  7. package/dist/plugins/read-files/index.js +1 -5
  8. package/dist/plugins/read-files/read-files.js +53 -51
  9. package/dist/schemas/v2.0/schema.js +1373 -1377
  10. package/dist/schemas/v3.0/schema.js +1411 -1415
  11. package/dist/schemas/v3.1/schema.js +1196 -1200
  12. package/dist/schemas/v3.2/schema.js +1417 -1421
  13. package/dist/types/index.js +1 -1
  14. package/dist/utils/betterAjvErrors/helpers.js +138 -112
  15. package/dist/utils/betterAjvErrors/index.js +11 -15
  16. package/dist/utils/betterAjvErrors/utils.js +17 -30
  17. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js +14 -18
  18. package/dist/utils/betterAjvErrors/validation-errors/base.js +20 -21
  19. package/dist/utils/betterAjvErrors/validation-errors/default.js +14 -18
  20. package/dist/utils/betterAjvErrors/validation-errors/enum.js +33 -37
  21. package/dist/utils/betterAjvErrors/validation-errors/index.js +6 -15
  22. package/dist/utils/betterAjvErrors/validation-errors/pattern.js +14 -18
  23. package/dist/utils/betterAjvErrors/validation-errors/required.js +13 -17
  24. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +14 -18
  25. package/dist/utils/dereference.js +22 -18
  26. package/dist/utils/details.js +28 -29
  27. package/dist/utils/filter.js +13 -14
  28. package/dist/utils/get-entrypoint.js +5 -6
  29. package/dist/utils/get-list-of-references.js +20 -16
  30. package/dist/utils/get-segments-from-path.js +13 -9
  31. package/dist/utils/is-filesystem.js +8 -6
  32. package/dist/utils/is-json.js +8 -11
  33. package/dist/utils/is-yaml.js +15 -17
  34. package/dist/utils/join/index.js +1 -5
  35. package/dist/utils/join/join.js +267 -153
  36. package/dist/utils/join/merge-objects.js +35 -18
  37. package/dist/utils/load/index.js +1 -5
  38. package/dist/utils/load/load.js +114 -90
  39. package/dist/utils/make-filesystem.js +20 -21
  40. package/dist/utils/normalize.js +32 -29
  41. package/dist/utils/openapi/actions/details.js +9 -10
  42. package/dist/utils/openapi/actions/files.js +7 -8
  43. package/dist/utils/openapi/actions/get.js +9 -10
  44. package/dist/utils/openapi/actions/toJson.js +9 -10
  45. package/dist/utils/openapi/actions/toYaml.js +9 -10
  46. package/dist/utils/openapi/commands/dereferenceCommand.js +25 -26
  47. package/dist/utils/openapi/commands/filterCommand.js +24 -25
  48. package/dist/utils/openapi/commands/loadCommand.js +40 -41
  49. package/dist/utils/openapi/commands/upgradeCommand.js +27 -28
  50. package/dist/utils/openapi/commands/validateCommand.js +31 -32
  51. package/dist/utils/openapi/openapi.js +16 -14
  52. package/dist/utils/openapi/openapi.test-d.js +13 -13
  53. package/dist/utils/openapi/utils/queueTask.js +8 -9
  54. package/dist/utils/openapi/utils/workThroughQueue.js +64 -50
  55. package/dist/utils/resolve-references.js +168 -110
  56. package/dist/utils/to-json.js +1 -5
  57. package/dist/utils/to-yaml.js +2 -6
  58. package/dist/utils/transform/sanitize.js +22 -22
  59. package/dist/utils/transform/utils/addInfoObject.js +9 -14
  60. package/dist/utils/transform/utils/addLatestOpenApiVersion.js +4 -9
  61. package/dist/utils/transform/utils/addMissingTags.js +26 -27
  62. package/dist/utils/transform/utils/normalizeSecuritySchemes.js +39 -37
  63. package/dist/utils/transform/utils/rejectSwaggerDocuments.js +5 -9
  64. package/dist/utils/transform-errors.js +62 -55
  65. package/dist/utils/traverse.js +21 -22
  66. package/dist/utils/unescape-json-pointer.js +8 -6
  67. package/dist/utils/upgrade.js +19 -22
  68. package/dist/utils/validate-path-parameters.js +76 -80
  69. package/dist/utils/validate.js +23 -19
  70. package/package.json +9 -14
  71. package/dist/configuration/index.js.map +0 -7
  72. package/dist/declarations.d.js +0 -1
  73. package/dist/declarations.d.js.map +0 -7
  74. package/dist/index.js.map +0 -7
  75. package/dist/lib/Validator/Validator.js.map +0 -7
  76. package/dist/plugins/fetch-urls/fetch-urls.js.map +0 -7
  77. package/dist/plugins/fetch-urls/index.js.map +0 -7
  78. package/dist/plugins/read-files/index.js.map +0 -7
  79. package/dist/plugins/read-files/read-files.js.map +0 -7
  80. package/dist/schemas/v2.0/schema.js.map +0 -7
  81. package/dist/schemas/v3.0/schema.js.map +0 -7
  82. package/dist/schemas/v3.1/schema.js.map +0 -7
  83. package/dist/schemas/v3.2/schema.js.map +0 -7
  84. package/dist/types/index.js.map +0 -7
  85. package/dist/utils/betterAjvErrors/helpers.js.map +0 -7
  86. package/dist/utils/betterAjvErrors/index.js.map +0 -7
  87. package/dist/utils/betterAjvErrors/utils.js.map +0 -7
  88. package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js.map +0 -7
  89. package/dist/utils/betterAjvErrors/validation-errors/base.js.map +0 -7
  90. package/dist/utils/betterAjvErrors/validation-errors/default.js.map +0 -7
  91. package/dist/utils/betterAjvErrors/validation-errors/enum.js.map +0 -7
  92. package/dist/utils/betterAjvErrors/validation-errors/index.js.map +0 -7
  93. package/dist/utils/betterAjvErrors/validation-errors/pattern.js.map +0 -7
  94. package/dist/utils/betterAjvErrors/validation-errors/required.js.map +0 -7
  95. package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js.map +0 -7
  96. package/dist/utils/dereference.js.map +0 -7
  97. package/dist/utils/details.js.map +0 -7
  98. package/dist/utils/filter.js.map +0 -7
  99. package/dist/utils/get-entrypoint.js.map +0 -7
  100. package/dist/utils/get-list-of-references.js.map +0 -7
  101. package/dist/utils/get-segments-from-path.js.map +0 -7
  102. package/dist/utils/is-filesystem.js.map +0 -7
  103. package/dist/utils/is-json.js.map +0 -7
  104. package/dist/utils/is-yaml.js.map +0 -7
  105. package/dist/utils/join/index.js.map +0 -7
  106. package/dist/utils/join/join.js.map +0 -7
  107. package/dist/utils/join/merge-objects.js.map +0 -7
  108. package/dist/utils/load/index.js.map +0 -7
  109. package/dist/utils/load/load.js.map +0 -7
  110. package/dist/utils/make-filesystem.js.map +0 -7
  111. package/dist/utils/normalize.js.map +0 -7
  112. package/dist/utils/openapi/actions/details.js.map +0 -7
  113. package/dist/utils/openapi/actions/files.js.map +0 -7
  114. package/dist/utils/openapi/actions/get.js.map +0 -7
  115. package/dist/utils/openapi/actions/toJson.js.map +0 -7
  116. package/dist/utils/openapi/actions/toYaml.js.map +0 -7
  117. package/dist/utils/openapi/commands/dereferenceCommand.js.map +0 -7
  118. package/dist/utils/openapi/commands/filterCommand.js.map +0 -7
  119. package/dist/utils/openapi/commands/loadCommand.js.map +0 -7
  120. package/dist/utils/openapi/commands/upgradeCommand.js.map +0 -7
  121. package/dist/utils/openapi/commands/validateCommand.js.map +0 -7
  122. package/dist/utils/openapi/openapi.js.map +0 -7
  123. package/dist/utils/openapi/openapi.test-d.js.map +0 -7
  124. package/dist/utils/openapi/utils/queueTask.js.map +0 -7
  125. package/dist/utils/openapi/utils/workThroughQueue.js.map +0 -7
  126. package/dist/utils/resolve-references.js.map +0 -7
  127. package/dist/utils/to-json.js.map +0 -7
  128. package/dist/utils/to-yaml.js.map +0 -7
  129. package/dist/utils/transform/sanitize.js.map +0 -7
  130. package/dist/utils/transform/utils/addInfoObject.js.map +0 -7
  131. package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +0 -7
  132. package/dist/utils/transform/utils/addMissingTags.js.map +0 -7
  133. package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +0 -7
  134. package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +0 -7
  135. package/dist/utils/transform-errors.js.map +0 -7
  136. package/dist/utils/traverse.js.map +0 -7
  137. package/dist/utils/unescape-json-pointer.js.map +0 -7
  138. package/dist/utils/upgrade.js.map +0 -7
  139. package/dist/utils/validate-path-parameters.js.map +0 -7
  140. package/dist/utils/validate.js.map +0 -7
@@ -1,98 +1,122 @@
1
- import { ERRORS } from "../../configuration/index.js";
2
- import { getEntrypoint } from "../../utils/get-entrypoint.js";
3
- import { getListOfReferences } from "../../utils/get-list-of-references.js";
4
- import { makeFilesystem } from "../../utils/make-filesystem.js";
5
- import { normalize } from "../../utils/normalize.js";
6
- async function load(value, options) {
7
- const errors = [];
8
- if (options?.filesystem?.find((entry) => entry.filename === value)) {
9
- return {
10
- specification: getEntrypoint(options.filesystem)?.specification,
11
- filesystem: options.filesystem,
12
- errors
13
- };
14
- }
15
- const plugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(value));
16
- let content;
17
- if (plugin) {
18
- try {
19
- content = normalize(await plugin.get(value));
20
- } catch (_error) {
21
- if (options?.throwOnError) {
22
- throw new Error(ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace("%s", value));
23
- }
24
- errors.push({
25
- code: "EXTERNAL_REFERENCE_NOT_FOUND",
26
- message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace("%s", value)
27
- });
28
- return {
29
- specification: null,
30
- filesystem: [],
31
- errors
32
- };
1
+ import { ERRORS } from '../../configuration/index.js';
2
+ import { getEntrypoint } from '../../utils/get-entrypoint.js';
3
+ import { getListOfReferences } from '../../utils/get-list-of-references.js';
4
+ import { makeFilesystem } from '../../utils/make-filesystem.js';
5
+ import { normalize } from '../../utils/normalize.js';
6
+ /**
7
+ * @deprecated This function is deprecated and will be removed in a future version.
8
+ * Please use the new bundler utility instead:
9
+ * ```ts
10
+ * import { bundle } from "@scalar/json-magic/bundle"
11
+ * ```
12
+ *
13
+ * Loads an OpenAPI document, including any external references.
14
+ *
15
+ * This function handles loading content from various sources, normalizes the content,
16
+ * and recursively loads any external references found within the definition.
17
+ *
18
+ * It builds a filesystem representation of all loaded content and collects any errors
19
+ * encountered during the process.
20
+ */
21
+ export async function load(value, options) {
22
+ const errors = [];
23
+ // Don't load a reference twice, check the filesystem before fetching something
24
+ if (options?.filesystem?.find((entry) => entry.filename === value)) {
25
+ return {
26
+ specification: getEntrypoint(options.filesystem)?.specification,
27
+ filesystem: options.filesystem,
28
+ errors,
29
+ };
33
30
  }
34
- } else {
35
- content = normalize(value);
36
- }
37
- if (content === void 0) {
38
- if (options?.throwOnError) {
39
- throw new Error("No content to load");
31
+ // Check whether the value is an URL or file path
32
+ const plugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(value));
33
+ let content;
34
+ if (plugin) {
35
+ try {
36
+ content = normalize(await plugin.get(value));
37
+ }
38
+ catch (_error) {
39
+ if (options?.throwOnError) {
40
+ throw new Error(ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value));
41
+ }
42
+ errors.push({
43
+ code: 'EXTERNAL_REFERENCE_NOT_FOUND',
44
+ message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value),
45
+ });
46
+ return {
47
+ specification: null,
48
+ filesystem: [],
49
+ errors,
50
+ };
51
+ }
40
52
  }
41
- errors.push({
42
- code: "NO_CONTENT",
43
- message: ERRORS.NO_CONTENT
44
- });
45
- return {
46
- specification: null,
47
- filesystem: [],
48
- errors
49
- };
50
- }
51
- let filesystem = makeFilesystem(content, {
52
- filename: options?.filename ?? null
53
- });
54
- const newEntry = options?.filename ? filesystem.find((entry) => entry.filename === options?.filename) : getEntrypoint(filesystem);
55
- const listOfReferences = newEntry.references ?? getListOfReferences(content);
56
- if (listOfReferences.length === 0) {
57
- return {
58
- specification: getEntrypoint(filesystem)?.specification,
59
- filesystem,
60
- errors
61
- };
62
- }
63
- for (const reference of listOfReferences) {
64
- const otherPlugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(reference));
65
- if (!otherPlugin) {
66
- continue;
53
+ else {
54
+ content = normalize(value);
67
55
  }
68
- const target = otherPlugin.check(reference) && otherPlugin.resolvePath ? otherPlugin.resolvePath(value, reference) : reference;
69
- if (filesystem.find((entry) => entry.filename === reference)) {
70
- continue;
56
+ // No content
57
+ if (content === undefined) {
58
+ if (options?.throwOnError) {
59
+ throw new Error('No content to load');
60
+ }
61
+ errors.push({
62
+ code: 'NO_CONTENT',
63
+ message: ERRORS.NO_CONTENT,
64
+ });
65
+ return {
66
+ specification: null,
67
+ filesystem: [],
68
+ errors,
69
+ };
71
70
  }
72
- const { filesystem: referencedFiles, errors: newErrors } = await load(target, {
73
- ...options,
74
- // Make the filename the exact same value as the $ref
75
- // TODO: This leads to problems, if there are multiple references with the same file name but in different folders
76
- filename: reference
71
+ let filesystem = makeFilesystem(content, {
72
+ filename: options?.filename ?? null,
77
73
  });
78
- errors.push(...newErrors);
79
- filesystem = [
80
- ...filesystem,
81
- ...referencedFiles.map((file) => {
74
+ // Get references from file system entry, or from the content
75
+ const newEntry = options?.filename
76
+ ? filesystem.find((entry) => entry.filename === options?.filename)
77
+ : getEntrypoint(filesystem);
78
+ const listOfReferences = newEntry.references ?? getListOfReferences(content);
79
+ // No other references
80
+ if (listOfReferences.length === 0) {
82
81
  return {
83
- ...file,
84
- isEntrypoint: false
82
+ specification: getEntrypoint(filesystem)?.specification,
83
+ filesystem,
84
+ errors,
85
85
  };
86
- })
87
- ];
88
- }
89
- return {
90
- specification: getEntrypoint(filesystem)?.specification,
91
- filesystem,
92
- errors
93
- };
86
+ }
87
+ // Load other external references
88
+ for (const reference of listOfReferences) {
89
+ // Find a matching plugin
90
+ const otherPlugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(reference));
91
+ // Skip if no plugin is found (internal references don't need a plugin for example)
92
+ if (!otherPlugin) {
93
+ continue;
94
+ }
95
+ const target = otherPlugin.check(reference) && otherPlugin.resolvePath ? otherPlugin.resolvePath(value, reference) : reference;
96
+ // Don't load a reference twice, check the filesystem before fetching something
97
+ if (filesystem.find((entry) => entry.filename === reference)) {
98
+ continue;
99
+ }
100
+ const { filesystem: referencedFiles, errors: newErrors } = await load(target, {
101
+ ...options,
102
+ // Make the filename the exact same value as the $ref
103
+ // TODO: This leads to problems, if there are multiple references with the same file name but in different folders
104
+ filename: reference,
105
+ });
106
+ errors.push(...newErrors);
107
+ filesystem = [
108
+ ...filesystem,
109
+ ...referencedFiles.map((file) => {
110
+ return {
111
+ ...file,
112
+ isEntrypoint: false,
113
+ };
114
+ }),
115
+ ];
116
+ }
117
+ return {
118
+ specification: getEntrypoint(filesystem)?.specification,
119
+ filesystem,
120
+ errors,
121
+ };
94
122
  }
95
- export {
96
- load
97
- };
98
- //# sourceMappingURL=load.js.map
@@ -1,23 +1,22 @@
1
- import { getListOfReferences } from "./get-list-of-references.js";
2
- import { isFilesystem } from "./is-filesystem.js";
3
- import { normalize } from "./normalize.js";
4
- function makeFilesystem(value, overwrites = {}) {
5
- if (isFilesystem(value)) {
6
- return value;
7
- }
8
- const specification = normalize(value);
9
- return [
10
- {
11
- isEntrypoint: true,
12
- specification,
13
- filename: null,
14
- dir: "./",
15
- references: getListOfReferences(specification),
16
- ...overwrites
1
+ import { getListOfReferences } from './get-list-of-references.js';
2
+ import { isFilesystem } from './is-filesystem.js';
3
+ import { normalize } from './normalize.js';
4
+ export function makeFilesystem(value, overwrites = {}) {
5
+ // Keep as is
6
+ if (isFilesystem(value)) {
7
+ return value;
17
8
  }
18
- ];
9
+ // Make an object
10
+ const specification = normalize(value);
11
+ // Create fake filesystem
12
+ return [
13
+ {
14
+ isEntrypoint: true,
15
+ specification,
16
+ filename: null,
17
+ dir: './',
18
+ references: getListOfReferences(specification),
19
+ ...overwrites,
20
+ },
21
+ ];
19
22
  }
20
- export {
21
- makeFilesystem
22
- };
23
- //# sourceMappingURL=make-filesystem.js.map
@@ -1,33 +1,36 @@
1
- import { parse } from "yaml";
2
- import { isFilesystem } from "./is-filesystem.js";
3
- function normalize(content) {
4
- if (content === null) {
5
- return void 0;
6
- }
7
- if (typeof content === "string") {
8
- if (content.trim() === "") {
9
- return void 0;
1
+ import { parse } from 'yaml';
2
+ import { isFilesystem } from './is-filesystem.js';
3
+ /**
4
+ * Normalize the OpenAPI document (YAML, JSON, object) to a JavaScript object.
5
+ *
6
+ * Doesn't modify the object if it's a `Filesystem` (multiple files) already.
7
+ */
8
+ export function normalize(content) {
9
+ if (content === null) {
10
+ return undefined;
10
11
  }
11
- try {
12
- return JSON.parse(content);
13
- } catch {
14
- const hasColon = /^[^:]+:/.test(content);
15
- const isJson = content.slice(0, 50).trimStart().startsWith("{");
16
- if (!hasColon || isJson) {
17
- return void 0;
18
- }
19
- return parse(content, {
20
- maxAliasCount: 1e4,
21
- merge: true
22
- });
12
+ if (typeof content === 'string') {
13
+ if (content.trim() === '') {
14
+ return undefined;
15
+ }
16
+ try {
17
+ return JSON.parse(content);
18
+ }
19
+ catch {
20
+ // Does it look like YAML?
21
+ const hasColon = /^[^:]+:/.test(content);
22
+ const isJson = content.slice(0, 50).trimStart().startsWith('{');
23
+ if (!hasColon || isJson) {
24
+ return undefined;
25
+ }
26
+ return parse(content, {
27
+ maxAliasCount: 10000,
28
+ merge: true,
29
+ });
30
+ }
31
+ }
32
+ if (isFilesystem(content)) {
33
+ return content;
23
34
  }
24
- }
25
- if (isFilesystem(content)) {
26
35
  return content;
27
- }
28
- return content;
29
36
  }
30
- export {
31
- normalize
32
- };
33
- //# sourceMappingURL=normalize.js.map
@@ -1,11 +1,10 @@
1
- import { getEntrypoint } from "../../../utils/get-entrypoint.js";
2
- import { details as detailsUtility } from "../../../utils/details.js";
3
- import { workThroughQueue } from "../utils/workThroughQueue.js";
4
- async function details(queue) {
5
- const { filesystem } = await workThroughQueue(queue);
6
- return detailsUtility(getEntrypoint(filesystem).specification);
1
+ import { getEntrypoint } from '../../../utils/get-entrypoint.js';
2
+ import { details as detailsUtility } from '../../../utils/details.js';
3
+ import { workThroughQueue } from '../utils/workThroughQueue.js';
4
+ /**
5
+ * Run the chained tasks and return just some basic information about the OpenAPI document
6
+ */
7
+ export async function details(queue) {
8
+ const { filesystem } = await workThroughQueue(queue);
9
+ return detailsUtility(getEntrypoint(filesystem).specification);
7
10
  }
8
- export {
9
- details
10
- };
11
- //# sourceMappingURL=details.js.map
@@ -1,9 +1,8 @@
1
- import { workThroughQueue } from "../utils/workThroughQueue.js";
2
- async function files(queue) {
3
- const { filesystem } = await workThroughQueue(queue);
4
- return filesystem;
1
+ import { workThroughQueue } from '../utils/workThroughQueue.js';
2
+ /**
3
+ * Run the chained tasks and return just the filesystem
4
+ */
5
+ export async function files(queue) {
6
+ const { filesystem } = await workThroughQueue(queue);
7
+ return filesystem;
5
8
  }
6
- export {
7
- files
8
- };
9
- //# sourceMappingURL=files.js.map
@@ -1,11 +1,10 @@
1
- import { workThroughQueue } from "../utils/workThroughQueue.js";
2
- async function get(queue) {
3
- return {
4
- filesystem: [],
5
- ...await workThroughQueue(queue)
6
- };
1
+ import { workThroughQueue } from '../utils/workThroughQueue.js';
2
+ /**
3
+ * Run the chained tasks and return the results
4
+ */
5
+ export async function get(queue) {
6
+ return {
7
+ filesystem: [],
8
+ ...(await workThroughQueue(queue)),
9
+ };
7
10
  }
8
- export {
9
- get
10
- };
11
- //# sourceMappingURL=get.js.map
@@ -1,11 +1,10 @@
1
- import { getEntrypoint } from "../../../utils/get-entrypoint.js";
2
- import { toJson as toJsonUtility } from "../../../utils/to-json.js";
3
- import { workThroughQueue } from "../utils/workThroughQueue.js";
4
- async function toJson(queue) {
5
- const { filesystem } = await workThroughQueue(queue);
6
- return toJsonUtility(getEntrypoint(filesystem).specification);
1
+ import { getEntrypoint } from '../../../utils/get-entrypoint.js';
2
+ import { toJson as toJsonUtility } from '../../../utils/to-json.js';
3
+ import { workThroughQueue } from '../utils/workThroughQueue.js';
4
+ /**
5
+ * Run the chained tasks and return the results
6
+ */
7
+ export async function toJson(queue) {
8
+ const { filesystem } = await workThroughQueue(queue);
9
+ return toJsonUtility(getEntrypoint(filesystem).specification);
7
10
  }
8
- export {
9
- toJson
10
- };
11
- //# sourceMappingURL=toJson.js.map
@@ -1,11 +1,10 @@
1
- import { getEntrypoint } from "../../../utils/get-entrypoint.js";
2
- import { toYaml as toYamlUtility } from "../../../utils/to-yaml.js";
3
- import { workThroughQueue } from "../utils/workThroughQueue.js";
4
- async function toYaml(queue) {
5
- const { filesystem } = await workThroughQueue(queue);
6
- return toYamlUtility(getEntrypoint(filesystem).specification);
1
+ import { getEntrypoint } from '../../../utils/get-entrypoint.js';
2
+ import { toYaml as toYamlUtility } from '../../../utils/to-yaml.js';
3
+ import { workThroughQueue } from '../utils/workThroughQueue.js';
4
+ /**
5
+ * Run the chained tasks and return the results
6
+ */
7
+ export async function toYaml(queue) {
8
+ const { filesystem } = await workThroughQueue(queue);
9
+ return toYamlUtility(getEntrypoint(filesystem).specification);
7
10
  }
8
- export {
9
- toYaml
10
- };
11
- //# sourceMappingURL=toYaml.js.map
@@ -1,27 +1,26 @@
1
- import { details } from "../actions/details.js";
2
- import { files } from "../actions/files.js";
3
- import { get } from "../actions/get.js";
4
- import { toJson } from "../actions/toJson.js";
5
- import { toYaml } from "../actions/toYaml.js";
6
- import { queueTask } from "../utils/queueTask.js";
7
- function dereferenceCommand(previousQueue, options) {
8
- const task = {
9
- name: "dereference",
10
- options: {
11
- throwOnError: previousQueue.options?.throwOnError,
12
- ...options ?? {}
13
- }
14
- };
15
- const queue = queueTask(previousQueue, task);
16
- return {
17
- details: () => details(queue),
18
- files: () => files(queue),
19
- get: () => get(queue),
20
- toJson: () => toJson(queue),
21
- toYaml: () => toYaml(queue)
22
- };
1
+ import { details } from '../actions/details.js';
2
+ import { files } from '../actions/files.js';
3
+ import { get } from '../actions/get.js';
4
+ import { toJson } from '../actions/toJson.js';
5
+ import { toYaml } from '../actions/toYaml.js';
6
+ import { queueTask } from '../utils/queueTask.js';
7
+ /**
8
+ * Dereference the given OpenAPI document
9
+ */
10
+ export function dereferenceCommand(previousQueue, options) {
11
+ const task = {
12
+ name: 'dereference',
13
+ options: {
14
+ throwOnError: previousQueue.options?.throwOnError,
15
+ ...(options ?? {}),
16
+ },
17
+ };
18
+ const queue = queueTask(previousQueue, task);
19
+ return {
20
+ details: () => details(queue),
21
+ files: () => files(queue),
22
+ get: () => get(queue),
23
+ toJson: () => toJson(queue),
24
+ toYaml: () => toYaml(queue),
25
+ };
23
26
  }
24
- export {
25
- dereferenceCommand
26
- };
27
- //# sourceMappingURL=dereferenceCommand.js.map
@@ -1,26 +1,25 @@
1
- import { details } from "../actions/details.js";
2
- import { files } from "../actions/files.js";
3
- import { get } from "../actions/get.js";
4
- import { toJson } from "../actions/toJson.js";
5
- import { toYaml } from "../actions/toYaml.js";
6
- import { queueTask } from "../utils/queueTask.js";
7
- import { dereferenceCommand } from "./dereferenceCommand.js";
8
- function filterCommand(previousQueue, options) {
9
- const task = {
10
- name: "filter",
11
- options
12
- };
13
- const queue = queueTask(previousQueue, task);
14
- return {
15
- dereference: (dereferenceOptions) => dereferenceCommand(queue, dereferenceOptions),
16
- details: () => details(queue),
17
- files: () => files(queue),
18
- get: () => get(queue),
19
- toJson: () => toJson(queue),
20
- toYaml: () => toYaml(queue)
21
- };
1
+ import { details } from '../actions/details.js';
2
+ import { files } from '../actions/files.js';
3
+ import { get } from '../actions/get.js';
4
+ import { toJson } from '../actions/toJson.js';
5
+ import { toYaml } from '../actions/toYaml.js';
6
+ import { queueTask } from '../utils/queueTask.js';
7
+ import { dereferenceCommand } from './dereferenceCommand.js';
8
+ /**
9
+ * Filter the given OpenAPI document
10
+ */
11
+ export function filterCommand(previousQueue, options) {
12
+ const task = {
13
+ name: 'filter',
14
+ options,
15
+ };
16
+ const queue = queueTask(previousQueue, task);
17
+ return {
18
+ dereference: (dereferenceOptions) => dereferenceCommand(queue, dereferenceOptions),
19
+ details: () => details(queue),
20
+ files: () => files(queue),
21
+ get: () => get(queue),
22
+ toJson: () => toJson(queue),
23
+ toYaml: () => toYaml(queue),
24
+ };
22
25
  }
23
- export {
24
- filterCommand
25
- };
26
- //# sourceMappingURL=filterCommand.js.map
@@ -1,42 +1,41 @@
1
- import { details } from "../actions/details.js";
2
- import { files } from "../actions/files.js";
3
- import { get } from "../actions/get.js";
4
- import { toJson } from "../actions/toJson.js";
5
- import { toYaml } from "../actions/toYaml.js";
6
- import { queueTask } from "../utils/queueTask.js";
7
- import { dereferenceCommand } from "./dereferenceCommand.js";
8
- import { filterCommand } from "./filterCommand.js";
9
- import { upgradeCommand } from "./upgradeCommand.js";
10
- import { validateCommand } from "./validateCommand.js";
11
- function loadCommand(previousQueue, input, options) {
12
- const task = {
13
- name: "load",
14
- options: {
15
- // global
16
- throwOnError: previousQueue.options?.throwOnError,
17
- // local
18
- ...options
19
- }
20
- };
21
- const queue = {
22
- // Add the load task
23
- ...queueTask(previousQueue, task),
24
- // Add input to the queue
25
- input
26
- };
27
- return {
28
- dereference: (dereferenceOptions) => dereferenceCommand(queue, dereferenceOptions),
29
- details: () => details(queue),
30
- files: () => files(queue),
31
- filter: (callback) => filterCommand(queue, callback),
32
- get: () => get(queue),
33
- upgrade: () => upgradeCommand(queue),
34
- toJson: () => toJson(queue),
35
- toYaml: () => toYaml(queue),
36
- validate: (validateOptions) => validateCommand(queue, validateOptions)
37
- };
1
+ import { details } from '../actions/details.js';
2
+ import { files } from '../actions/files.js';
3
+ import { get } from '../actions/get.js';
4
+ import { toJson } from '../actions/toJson.js';
5
+ import { toYaml } from '../actions/toYaml.js';
6
+ import { queueTask } from '../utils/queueTask.js';
7
+ import { dereferenceCommand } from './dereferenceCommand.js';
8
+ import { filterCommand } from './filterCommand.js';
9
+ import { upgradeCommand } from './upgradeCommand.js';
10
+ import { validateCommand } from './validateCommand.js';
11
+ /**
12
+ * Pass any OpenAPI document
13
+ */
14
+ export function loadCommand(previousQueue, input, options) {
15
+ const task = {
16
+ name: 'load',
17
+ options: {
18
+ // global
19
+ throwOnError: previousQueue.options?.throwOnError,
20
+ // local
21
+ ...options,
22
+ },
23
+ };
24
+ const queue = {
25
+ // Add the load task
26
+ ...queueTask(previousQueue, task),
27
+ // Add input to the queue
28
+ input,
29
+ };
30
+ return {
31
+ dereference: (dereferenceOptions) => dereferenceCommand(queue, dereferenceOptions),
32
+ details: () => details(queue),
33
+ files: () => files(queue),
34
+ filter: (callback) => filterCommand(queue, callback),
35
+ get: () => get(queue),
36
+ upgrade: () => upgradeCommand(queue),
37
+ toJson: () => toJson(queue),
38
+ toYaml: () => toYaml(queue),
39
+ validate: (validateOptions) => validateCommand(queue, validateOptions),
40
+ };
38
41
  }
39
- export {
40
- loadCommand
41
- };
42
- //# sourceMappingURL=loadCommand.js.map