docs: oas (#197)
Adds OpenAPI specification of Storefront and Admin APIs. Updates docs project.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
const fs = require("fs").promises;
|
||||
const path = require("path");
|
||||
|
||||
class FixtureWriter {
|
||||
constructor() {
|
||||
const resolvedPath = path.resolve("./docs/api/fixtures.json");
|
||||
const existing = require(resolvedPath);
|
||||
|
||||
this.toWrite_ = existing.resources;
|
||||
this.resolvedPath_ = resolvedPath;
|
||||
}
|
||||
|
||||
addFixture(key, data) {
|
||||
this.toWrite_ = {
|
||||
...this.toWrite_,
|
||||
[key]: data,
|
||||
};
|
||||
}
|
||||
|
||||
async execute() {
|
||||
const toSet = {
|
||||
resources: this.toWrite_,
|
||||
};
|
||||
const s = JSON.stringify(toSet, null, 2);
|
||||
return await fs.writeFile(this.resolvedPath_, s);
|
||||
}
|
||||
}
|
||||
|
||||
const instance = new FixtureWriter();
|
||||
export default instance;
|
||||
Reference in New Issue
Block a user