fix: Make sure to only include models that use jsonSchema

This commit is contained in:
Gerald Pinder 2025-04-28 21:30:09 -04:00
parent f4975ddb8f
commit fecdf3b39a

View file

@ -16,24 +16,30 @@ for (const module of modules) {
if (module.tsp === "") continue if (module.tsp === "") continue
const res = await fetch(module.tsp) const res = await fetch(module.tsp)
let text = await res.text() let text = await res.text()
let last_line = ''
text = text // add `...ModuleDefaults;` after the model type text = text // add `...ModuleDefaults;` after the model type
.split("\n") .split("\n")
.flatMap(line => { .flatMap(line => {
if (line.trimStart().startsWith("model")) { if (line.trimStart().startsWith("model")) {
moduleModels.push(line.split(' ')[1]); if (last_line.includes("@jsonSchema")) {
moduleModels.push(line.split(' ')[1]);
}
last_line = line
return [ return [
`@extension("additionalProperties", false)`, `@extension("additionalProperties", false)`,
line line
]; ];
} }
if (line.trimStart().startsWith(`type: "${module.name}`)) { if (line.trimStart().startsWith(`type: "${module.name}`)) {
last_line = line
return [ return [
line, line,
'', '',
' ...ModuleDefaults; // added by fetchModuleSchemas.js', ' ...ModuleDefaults; // added by fetchModuleSchemas.js',
]; ];
} else { } else {
last_line = line
return line; return line;
} }
}) })