summary refs log tree commit diff
path: root/scripts/schema.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/schema.js')
-rw-r--r--scripts/schema.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/schema.js b/scripts/schema.js

index 772058316..983eb697a 100644 --- a/scripts/schema.js +++ b/scripts/schema.js
@@ -46,6 +46,7 @@ const settings = { const ExcludeAndWarn = [ /^Record/, /^Partial/, + /^import\(/, ] const Excluded = [ "DefaultSchema", @@ -149,6 +150,24 @@ function main() { deleteOneOfKindUndefinedRecursive(definitions, "$"); + // cant do this here: + // let hasUnreferencedSchemas = true; + // while (hasUnreferencedSchemas) { + // hasUnreferencedSchemas = false; + // console.log(`Checking for unreferenced schemas in ${definitions.length}..."`); + // let fullMap = JSON.stringify(definitions); + // for (const [name, schema] of Object.entries(definitions)) { + // const schemaStr = JSON.stringify(schema); + // const refRe = new RegExp(`"\\$ref":"#/definitions/${name}"`, "g"); + // const count = (fullMap.match(refRe) || []).length; + // if (count <= 1) { + // console.log("Deleting unreferenced schema", name); + // delete definitions[name]; + // hasUnreferencedSchemas = true; + // } + // } + // } + fs.writeFileSync(schemaPath, JSON.stringify(definitions, null, 4)); console.log("Successfully wrote", Object.keys(definitions).length, "schemas to", schemaPath); }