oas-toolkit 0.3.0 → 0.4.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.
- package/cli/bin.js +5 -0
- package/cli/commands/check-conflicts.js +26 -0
- package/merger.js +0 -5
- package/package.json +1 -2
package/cli/bin.js
CHANGED
|
@@ -9,4 +9,9 @@ yargs(hideBin(process.argv))
|
|
|
9
9
|
"merge the provided OpenAPI files",
|
|
10
10
|
require("./commands/merge")
|
|
11
11
|
)
|
|
12
|
+
.command(
|
|
13
|
+
"check-conflicts <openapi.yaml> <...more.yaml>",
|
|
14
|
+
"check for conflicting components, paths, tags, and security schemes",
|
|
15
|
+
require("./commands/check-conflicts")
|
|
16
|
+
)
|
|
12
17
|
.parse();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const yaml = require("js-yaml");
|
|
3
|
+
|
|
4
|
+
module.exports = async function ({ argv }) {
|
|
5
|
+
try {
|
|
6
|
+
const oasFiles = argv._.slice(1);
|
|
7
|
+
if (oasFiles.length < 2) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const merger = require("../../merger");
|
|
12
|
+
|
|
13
|
+
const oas = [];
|
|
14
|
+
for (let f of oasFiles) {
|
|
15
|
+
oas.push(yaml.load(fs.readFileSync(f)));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
merger.ensureNoComponentColissions(oas, argv);
|
|
19
|
+
merger.ensureNoPathColissions(oas, argv);
|
|
20
|
+
merger.ensureNoTagColissions(oas, argv);
|
|
21
|
+
merger.ensureNoSecurityColissions(oas, argv);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error(`ERROR: ${e.message}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
};
|
package/merger.js
CHANGED
|
@@ -3,11 +3,6 @@ const isEqual = require("lodash.isequal");
|
|
|
3
3
|
const uniqWith = require("lodash.uniqwith");
|
|
4
4
|
|
|
5
5
|
function merge(objects, options) {
|
|
6
|
-
ensureNoComponentColissions(objects, options);
|
|
7
|
-
ensureNoPathColissions(objects, options);
|
|
8
|
-
ensureNoTagColissions(objects, options);
|
|
9
|
-
ensureNoSecurityColissions(objects, options);
|
|
10
|
-
|
|
11
6
|
// Do the merge
|
|
12
7
|
let combinedSpec = {};
|
|
13
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oas-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"jest": "^29.5.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
20
19
|
"debug": "^4.3.4",
|
|
21
20
|
"js-yaml": "^4.1.0",
|
|
22
21
|
"jsonpath-plus": "^7.2.0",
|