Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
chore(schemas): fix schema generation bug
Browse files Browse the repository at this point in the history
Post-process the schema file to workaround upstream bug that seems
common in schema generators.

Refs: #146

Signed-off-by: Bruce D'Arcus <bdarcus@gmail.com>
  • Loading branch information
bdarcus committed May 26, 2023
1 parent d06a103 commit c19dc45
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/make_schemas.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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!");

0 comments on commit c19dc45

Please sign in to comment.