Files
windmill/windmill-yaml-validator/gen_openflow_schema.sh
centdix e40d52d411 fix(yaml-validator): update openflow for aiagents (#6895)
* update openflow for aiagents

* remove value from required in openflow.json

* all

---------

Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2025-10-23 07:52:25 +00:00

37 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
output_dirpath="${script_dirpath}/src/gen"
mkdir -p "${output_dirpath}"
npx @redocly/openapi-cli@latest bundle "${script_dirpath}/../openflow.openapi.yaml" --ext json > "${output_dirpath}/openflow.json"
# Remove discriminator mapping from openflow.json as it's not supported by ajv
node -e "
const fs = require('fs');
const filePath = '${output_dirpath}/openflow.json';
try {
const schema = JSON.parse(fs.readFileSync(filePath, 'utf8'));
function removeMapping(obj) {
if (obj && typeof obj === 'object') {
if (obj.discriminator?.mapping) delete obj.discriminator.mapping;
for (const v of Object.values(obj)) removeMapping(v);
}
}
removeMapping(schema);
// Remove discriminator entirely from ToolValue as it doesn't work with allOf in FlowModuleTool
if (schema.components?.schemas?.ToolValue?.discriminator) {
delete schema.components.schemas.ToolValue.discriminator;
console.log('Removed discriminator from ToolValue schema');
}
fs.writeFileSync(filePath, JSON.stringify(schema, null, 2));
console.log('Removed discriminator mappings from openflow.json');
} catch (e) {
console.error('Error removing discriminator mappings:', e);
}
"