MCPcopy
hub / github.com/thesysdev/openui / compileSchema

Function compileSchema

packages/lang-core/src/parser/parser.ts:640–656  ·  view source on GitHub ↗
(schema: LibraryJSONSchema)

Source from the content-addressed store, hash-verified

638}
639
640export function compileSchema(schema: LibraryJSONSchema): ParamMap {
641 const map: ParamMap = new Map();
642 const defs = schema.$defs ?? {};
643
644 for (const [name, def] of Object.entries(defs)) {
645 const properties = def.properties ?? {};
646 const required = def.required ?? [];
647 const params = Object.keys(properties).map((key) => ({
648 name: key,
649 required: required.includes(key),
650 defaultValue: getSchemaDefaultValue(properties[key]),
651 }));
652 map.set(name, { params });
653 }
654
655 return map;
656}
657
658/**
659 * Create a parser from a library JSON Schema document.

Callers 3

jsonToOpenUIFunction · 0.90
createParserFunction · 0.85
createStreamingParserFunction · 0.85

Calls 2

getSchemaDefaultValueFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected