import { Ajv } from "ajv" ; import { JSONSchema6 } from "json-schema" ; import { default as ResolveLib , getSchemaId } from "../libs/resolve" ; param { string } $id param { JSONSchema6 } schema param { Ajv } ajv return { JSONSchema6 } export default ( $id , schema , ajv ) : JSONSchema6 => { if ( ! schema ) { return schema ; } let anyOf = schema . anyOf ; if ( anyOf && anyOf . constructor === Array ) { schema . anyOf = anyOf . map ( ( schemaOfOne , index ) => { let { mergeSchema } = new ResolveLib ( ajv , schemaOfOne , ( schema . $id || getSchemaId ( schema . $ref || "" ) ) ? undefined : getSchemaId ( $id ) ) ; return mergeSchema ; } ) ; } return schema ; } ;