fix(docs): API reference bugs (#2119)

* fixed shipping method tax line schema name

* added dry run option to build openapi script

* fixed summary of endpoints

* fixed title of endpoint
This commit is contained in:
Shahed Nasser
2022-08-29 14:25:17 +03:00
committed by GitHub
parent 890732d238
commit 076b41bb89
7 changed files with 45 additions and 30 deletions

View File

@@ -3,7 +3,10 @@
const fs = require("fs")
const OAS = require("oas-normalize")
const swaggerInline = require("swagger-inline")
const { exec } = require("child_process")
const { exec } = require("child_process");
const { exit } = require("process");
const isDryRun = process.argv.indexOf('--dry-run') !== -1;
// Storefront API
swaggerInline(
@@ -16,7 +19,9 @@ swaggerInline(
oas
.validate(true)
.then(() => {
fs.writeFileSync("./docs/api/store-spec3.json", gen)
if (!isDryRun) {
fs.writeFileSync("./docs/api/store-spec3.json", gen)
}
})
.catch((err) => {
console.log("Error in store")
@@ -32,13 +37,17 @@ swaggerInline(
format: "yaml",
}
).then((gen) => {
fs.writeFileSync("./docs/api/store-spec3.yaml", gen)
exec("rm -rf docs/api/store/ && yarn run -- redocly split docs/api/store-spec3.yaml --outDir=docs/api/store/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
});
if (!isDryRun) {
fs.writeFileSync("./docs/api/store-spec3.yaml", gen)
exec("rm -rf docs/api/store/ && yarn run -- redocly split docs/api/store-spec3.yaml --outDir=docs/api/store/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
});
} else {
console.log('No errors occurred while generating Store API Reference');
}
})
// Admin API
@@ -52,7 +61,9 @@ swaggerInline(
oas
.validate(true)
.then(() => {
fs.writeFileSync("./docs/api/admin-spec3.json", gen)
if (!isDryRun) {
fs.writeFileSync("./docs/api/admin-spec3.json", gen)
}
})
.catch((err) => {
console.log("Error in admin")
@@ -68,12 +79,16 @@ swaggerInline(
format: "yaml",
}
).then((gen) => {
fs.writeFileSync("./docs/api/admin-spec3.yaml", gen)
exec("rm -rf docs/api/admin/ && yarn run -- redocly split docs/api/admin-spec3.yaml --outDir=docs/api/admin/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
return;
});
if (!isDryRun) {
fs.writeFileSync("./docs/api/admin-spec3.yaml", gen)
exec("rm -rf docs/api/admin/ && yarn run -- redocly split docs/api/admin-spec3.yaml --outDir=docs/api/admin/", (error, stdout, stderr) => {
if (error) {
throw new Error(`error: ${error.message}`)
}
console.log(`${stderr || stdout}`);
return;
});
} else {
console.log('No errors occurred while generating Admin API Reference');
}
})