Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function schemaPreprocess(schema: ExtendedSchema):
{schema: ExtendedSchema, resQueue: PriorityQueue} {
const schemaClone = cloneDeep(schema);
const anyOfQueue = new PriorityQueue((a, b): boolean => (a.depth > b.depth));
const deepScan = (scanSchema: ExtendedSchema, depth: number = 0) => {
if (scanSchema.required) {
scanSchema.required.forEach((item) => {
if (scanSchema.properties[item].readOnly) {
throw Error(`Readonly property "${item}" marked as required`);
}
});
}
if (scanSchema.properties) {
forEach(scanSchema.properties, (schemaChild) => {
deepScan(schemaChild, depth + 1);
});
}