diff --git a/scripts/make_schemas.ts b/scripts/make_schemas.ts index 93189593..b4ddd37d 100644 --- a/scripts/make_schemas.ts +++ b/scripts/make_schemas.ts @@ -1,6 +1,9 @@ //import { createGenerator } from "npm:ts-json-schema-generator"; import { exec } from "https://deno.land/x/exec/mod.ts"; +/** + * An array of objects containing the path to the TypeScript file, the type to generate a schema for, and the path to the tsconfig.json file. + */ const configs = [ { path: "./npm/src/style.ts", @@ -39,6 +42,19 @@ for (const config of configs) { // console.log(command); exec(command); + + if (config.type === "Style") { + console.log("[schemas] Fixing CSL style schema ..."); + const schema = JSON.parse(await Deno.readTextFile(schemaFileName)); + // modify this property to workaround upstream bug + delete schema.properties.templates.$ref; + schema.properties.templates.type = "object"; + schema.properties.templates.patternProperties = { + "": { type: "#/definitions/InputReference" } + }; + + await Deno.writeTextFile(schemaFileName, JSON.stringify(schema)); + } } console.log("[schemas] Complete!");