oas-toolkit 0.7.0 → 0.7.2
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 +14 -1
- package/cli/commands/rewrite-path.js +3 -13
- package/index.js +1 -0
- package/package.json +1 -1
package/cli/bin.js
CHANGED
|
@@ -25,8 +25,21 @@ yargs(hideBin(process.argv))
|
|
|
25
25
|
require("./commands/remove-unused-tags")
|
|
26
26
|
)
|
|
27
27
|
.command(
|
|
28
|
-
"rewrite-path <openapi
|
|
28
|
+
"rewrite-path <openapi>",
|
|
29
29
|
"rewrite paths in the provided OpenAPI file",
|
|
30
|
+
(yargs) => {
|
|
31
|
+
yargs.option("oldPath", {
|
|
32
|
+
demandOption: true,
|
|
33
|
+
});
|
|
34
|
+
yargs.option("newPath", {
|
|
35
|
+
demandOption: true,
|
|
36
|
+
});
|
|
37
|
+
yargs.positional("openapi", {
|
|
38
|
+
require: true,
|
|
39
|
+
describe: "the OpenAPI file to rewrite",
|
|
40
|
+
type: "string",
|
|
41
|
+
});
|
|
42
|
+
},
|
|
30
43
|
require("./commands/rewrite-path")
|
|
31
44
|
)
|
|
32
45
|
.parse();
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const yaml = require("js-yaml");
|
|
3
3
|
|
|
4
|
-
module.exports = async function (
|
|
4
|
+
module.exports = async function (argv) {
|
|
5
5
|
try {
|
|
6
|
-
const oasFiles = argv._.slice(1);
|
|
7
|
-
if (oasFiles.length !== 1) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (!argv.oldPrefix || !argv.newPrefix) {
|
|
12
|
-
console.error(`ERROR: --oldPrefix and --newPrefix are required`);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
6
|
const p = require("../../rewrite-path");
|
|
17
|
-
let oas = yaml.load(fs.readFileSync(
|
|
18
|
-
oas = p.regex(oas, argv.
|
|
7
|
+
let oas = yaml.load(fs.readFileSync(argv.openapi));
|
|
8
|
+
oas = p.regex(oas, argv.oldPath, argv.newPath);
|
|
19
9
|
console.log(yaml.dump(oas));
|
|
20
10
|
} catch (e) {
|
|
21
11
|
console.error(`ERROR: ${e.message}`);
|
package/index.js
CHANGED