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 2ddd55f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scripts/make_schemas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//import { createGenerator } from "npm:ts-json-schema-generator";
import { exec } from "https://deno.land/x/exec/mod.ts";
import { readFileSync, writeFileSync } from "node:fs";

/**
* 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 @@ -41,4 +45,15 @@ for (const config of configs) {
exec(command);
}

const schema = JSON.parse(readFileSync('schemas/csl-style-schema.json'));

// modify this property to workaround upstream bug
delete schema.properties.templates.$ref;
schema.properties.templates.type = "object";
schema.properties.templates.patternProperties = {
"": { type: "#/definitions/InputReference" }
};

writeFileSync('schemas/csl-style-schema.json', JSON.stringify(schema, null, 2));

console.log("[schemas] Complete!");

0 comments on commit 2ddd55f

Please sign in to comment.