@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.
- package/CHANGELOG.md +6 -0
- package/dist/configuration/index.js +24 -24
- package/dist/index.js +24 -45
- package/dist/lib/Validator/Validator.js +125 -108
- package/dist/plugins/fetch-urls/fetch-urls.js +39 -38
- package/dist/plugins/fetch-urls/index.js +1 -6
- package/dist/plugins/read-files/index.js +1 -5
- package/dist/plugins/read-files/read-files.js +53 -51
- package/dist/schemas/v2.0/schema.js +1373 -1377
- package/dist/schemas/v3.0/schema.js +1411 -1415
- package/dist/schemas/v3.1/schema.js +1196 -1200
- package/dist/schemas/v3.2/schema.js +1417 -1421
- package/dist/types/index.js +1 -1
- package/dist/utils/betterAjvErrors/helpers.js +138 -112
- package/dist/utils/betterAjvErrors/index.js +11 -15
- package/dist/utils/betterAjvErrors/utils.js +17 -30
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js +14 -18
- package/dist/utils/betterAjvErrors/validation-errors/base.js +20 -21
- package/dist/utils/betterAjvErrors/validation-errors/default.js +14 -18
- package/dist/utils/betterAjvErrors/validation-errors/enum.js +33 -37
- package/dist/utils/betterAjvErrors/validation-errors/index.js +6 -15
- package/dist/utils/betterAjvErrors/validation-errors/pattern.js +14 -18
- package/dist/utils/betterAjvErrors/validation-errors/required.js +13 -17
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +14 -18
- package/dist/utils/dereference.js +22 -18
- package/dist/utils/details.js +28 -29
- package/dist/utils/filter.js +13 -14
- package/dist/utils/get-entrypoint.js +5 -6
- package/dist/utils/get-list-of-references.js +20 -16
- package/dist/utils/get-segments-from-path.js +13 -9
- package/dist/utils/is-filesystem.js +8 -6
- package/dist/utils/is-json.js +8 -11
- package/dist/utils/is-yaml.js +15 -17
- package/dist/utils/join/index.js +1 -5
- package/dist/utils/join/join.js +267 -153
- package/dist/utils/join/merge-objects.js +35 -18
- package/dist/utils/load/index.js +1 -5
- package/dist/utils/load/load.js +114 -90
- package/dist/utils/make-filesystem.js +20 -21
- package/dist/utils/normalize.js +32 -29
- package/dist/utils/openapi/actions/details.js +9 -10
- package/dist/utils/openapi/actions/files.js +7 -8
- package/dist/utils/openapi/actions/get.js +9 -10
- package/dist/utils/openapi/actions/toJson.js +9 -10
- package/dist/utils/openapi/actions/toYaml.js +9 -10
- package/dist/utils/openapi/commands/dereferenceCommand.js +25 -26
- package/dist/utils/openapi/commands/filterCommand.js +24 -25
- package/dist/utils/openapi/commands/loadCommand.js +40 -41
- package/dist/utils/openapi/commands/upgradeCommand.js +27 -28
- package/dist/utils/openapi/commands/validateCommand.js +31 -32
- package/dist/utils/openapi/openapi.js +16 -14
- package/dist/utils/openapi/openapi.test-d.js +13 -13
- package/dist/utils/openapi/utils/queueTask.js +8 -9
- package/dist/utils/openapi/utils/workThroughQueue.js +64 -50
- package/dist/utils/resolve-references.js +168 -110
- package/dist/utils/to-json.js +1 -5
- package/dist/utils/to-yaml.js +2 -6
- package/dist/utils/transform/sanitize.js +22 -22
- package/dist/utils/transform/utils/addInfoObject.js +9 -14
- package/dist/utils/transform/utils/addLatestOpenApiVersion.js +4 -9
- package/dist/utils/transform/utils/addMissingTags.js +26 -27
- package/dist/utils/transform/utils/normalizeSecuritySchemes.js +39 -37
- package/dist/utils/transform/utils/rejectSwaggerDocuments.js +5 -9
- package/dist/utils/transform-errors.js +62 -55
- package/dist/utils/traverse.js +21 -22
- package/dist/utils/unescape-json-pointer.js +8 -6
- package/dist/utils/upgrade.js +19 -22
- package/dist/utils/validate-path-parameters.js +76 -80
- package/dist/utils/validate.js +23 -19
- package/package.json +9 -14
- package/dist/configuration/index.js.map +0 -7
- package/dist/declarations.d.js +0 -1
- package/dist/declarations.d.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/lib/Validator/Validator.js.map +0 -7
- package/dist/plugins/fetch-urls/fetch-urls.js.map +0 -7
- package/dist/plugins/fetch-urls/index.js.map +0 -7
- package/dist/plugins/read-files/index.js.map +0 -7
- package/dist/plugins/read-files/read-files.js.map +0 -7
- package/dist/schemas/v2.0/schema.js.map +0 -7
- package/dist/schemas/v3.0/schema.js.map +0 -7
- package/dist/schemas/v3.1/schema.js.map +0 -7
- package/dist/schemas/v3.2/schema.js.map +0 -7
- package/dist/types/index.js.map +0 -7
- package/dist/utils/betterAjvErrors/helpers.js.map +0 -7
- package/dist/utils/betterAjvErrors/index.js.map +0 -7
- package/dist/utils/betterAjvErrors/utils.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/base.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/default.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/enum.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/index.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/pattern.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/required.js.map +0 -7
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js.map +0 -7
- package/dist/utils/dereference.js.map +0 -7
- package/dist/utils/details.js.map +0 -7
- package/dist/utils/filter.js.map +0 -7
- package/dist/utils/get-entrypoint.js.map +0 -7
- package/dist/utils/get-list-of-references.js.map +0 -7
- package/dist/utils/get-segments-from-path.js.map +0 -7
- package/dist/utils/is-filesystem.js.map +0 -7
- package/dist/utils/is-json.js.map +0 -7
- package/dist/utils/is-yaml.js.map +0 -7
- package/dist/utils/join/index.js.map +0 -7
- package/dist/utils/join/join.js.map +0 -7
- package/dist/utils/join/merge-objects.js.map +0 -7
- package/dist/utils/load/index.js.map +0 -7
- package/dist/utils/load/load.js.map +0 -7
- package/dist/utils/make-filesystem.js.map +0 -7
- package/dist/utils/normalize.js.map +0 -7
- package/dist/utils/openapi/actions/details.js.map +0 -7
- package/dist/utils/openapi/actions/files.js.map +0 -7
- package/dist/utils/openapi/actions/get.js.map +0 -7
- package/dist/utils/openapi/actions/toJson.js.map +0 -7
- package/dist/utils/openapi/actions/toYaml.js.map +0 -7
- package/dist/utils/openapi/commands/dereferenceCommand.js.map +0 -7
- package/dist/utils/openapi/commands/filterCommand.js.map +0 -7
- package/dist/utils/openapi/commands/loadCommand.js.map +0 -7
- package/dist/utils/openapi/commands/upgradeCommand.js.map +0 -7
- package/dist/utils/openapi/commands/validateCommand.js.map +0 -7
- package/dist/utils/openapi/openapi.js.map +0 -7
- package/dist/utils/openapi/openapi.test-d.js.map +0 -7
- package/dist/utils/openapi/utils/queueTask.js.map +0 -7
- package/dist/utils/openapi/utils/workThroughQueue.js.map +0 -7
- package/dist/utils/resolve-references.js.map +0 -7
- package/dist/utils/to-json.js.map +0 -7
- package/dist/utils/to-yaml.js.map +0 -7
- package/dist/utils/transform/sanitize.js.map +0 -7
- package/dist/utils/transform/utils/addInfoObject.js.map +0 -7
- package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +0 -7
- package/dist/utils/transform/utils/addMissingTags.js.map +0 -7
- package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +0 -7
- package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +0 -7
- package/dist/utils/transform-errors.js.map +0 -7
- package/dist/utils/traverse.js.map +0 -7
- package/dist/utils/unescape-json-pointer.js.map +0 -7
- package/dist/utils/upgrade.js.map +0 -7
- package/dist/utils/validate-path-parameters.js.map +0 -7
- package/dist/utils/validate.js.map +0 -7
package/dist/utils/load/load.js
CHANGED
|
@@ -1,98 +1,122 @@
|
|
|
1
|
-
import { ERRORS } from
|
|
2
|
-
import { getEntrypoint } from
|
|
3
|
-
import { getListOfReferences } from
|
|
4
|
-
import { makeFilesystem } from
|
|
5
|
-
import { normalize } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
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
|
-
|
|
73
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
84
|
-
|
|
82
|
+
specification: getEntrypoint(filesystem)?.specification,
|
|
83
|
+
filesystem,
|
|
84
|
+
errors,
|
|
85
85
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
|
2
|
-
import { isFilesystem } from
|
|
3
|
-
import { normalize } from
|
|
4
|
-
function makeFilesystem(value, overwrites = {}) {
|
|
5
|
-
|
|
6
|
-
|
|
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
|
package/dist/utils/normalize.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { parse } from
|
|
2
|
-
import { isFilesystem } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
2
|
-
import { details as detailsUtility } from
|
|
3
|
-
import { workThroughQueue } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
2
|
-
import { toJson as toJsonUtility } from
|
|
3
|
-
import { workThroughQueue } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
2
|
-
import { toYaml as toYamlUtility } from
|
|
3
|
-
import { workThroughQueue } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
2
|
-
import { files } from
|
|
3
|
-
import { get } from
|
|
4
|
-
import { toJson } from
|
|
5
|
-
import { toYaml } from
|
|
6
|
-
import { queueTask } from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
2
|
-
import { files } from
|
|
3
|
-
import { get } from
|
|
4
|
-
import { toJson } from
|
|
5
|
-
import { toYaml } from
|
|
6
|
-
import { queueTask } from
|
|
7
|
-
import { dereferenceCommand } from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
2
|
-
import { files } from
|
|
3
|
-
import { get } from
|
|
4
|
-
import { toJson } from
|
|
5
|
-
import { toYaml } from
|
|
6
|
-
import { queueTask } from
|
|
7
|
-
import { dereferenceCommand } from
|
|
8
|
-
import { filterCommand } from
|
|
9
|
-
import { upgradeCommand } from
|
|
10
|
-
import { validateCommand } from
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|