-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema_merge_tool.ts
25 lines (21 loc) · 1.07 KB
/
schema_merge_tool.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// We use Formly to show forms in Kendraio App. Formly currently (23rd January 2025) lacks
// support for resolving JSON schemas that have external references.
// This script merges together the referenced JSON schemas using `@apidevtools/json-schema-ref-parser`
// The output can then be used in the config of a Kendraio Form block's JSON schema property.
// It does so for this example URL:
const schemaUrl = "https://test-library.murmurations.network/v2/schemas/people_schema-v0.1.0";
// Usage:
// I was able to run this script like so, on a GitHub Codespace with Ubuntu 20.04.6 LTS,
// with the following bash terminal commands:
`
curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
~/.bun/bin/bun install @apidevtools/json-schema-ref-parser
~/.bun/bin/bun run schema_merge_tool.ts > merged_schema.json
`
import $RefParser from "@apidevtools/json-schema-ref-parser";
try {
const resolvedSchema = await new $RefParser().dereference(schemaUrl);
console.log(JSON.stringify(resolvedSchema, null, 2));
} catch (error) {
console.error("An error occurred:", error);
}