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