2020-08-12 17:08:37 -04:00
|
|
|
const path = require("path");
|
|
|
|
const fs = require("fs");
|
|
|
|
const toJsdoc = require("json-schema-to-jsdoc");
|
|
|
|
const schema = require("./cfg.schema.json");
|
|
|
|
const target = path.join(__dirname, "cfg.jsdoc.js");
|
2020-08-12 16:18:42 -04:00
|
|
|
|
2020-08-12 17:03:01 -04:00
|
|
|
// Fix up some custom types for the JSDoc conversion
|
|
|
|
const schemaCopy = JSON.parse(JSON.stringify(schema));
|
|
|
|
for (const propertyDef of Object.values(schemaCopy.properties)) {
|
|
|
|
if (propertyDef.$ref === "#/definitions/stringArray") {
|
|
|
|
propertyDef.type = "array";
|
|
|
|
delete propertyDef.$ref;
|
|
|
|
} else if (propertyDef.$ref === "#/definitions/customBoolean") {
|
|
|
|
propertyDef.type = "boolean";
|
|
|
|
delete propertyDef.$ref;
|
|
|
|
} else if (propertyDef.$ref === "#/definitions/multilineString") {
|
|
|
|
propertyDef.type = "string";
|
|
|
|
delete propertyDef.$ref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const result = toJsdoc(schemaCopy);
|
2020-08-12 17:08:37 -04:00
|
|
|
fs.writeFileSync(target, result, { encoding: "utf8" });
|