def resolveSchema(schema, schemaStore):
    """
    Recursively resolve all I{$ref} JSON references in a JSON Schema.

    @param schema: A L{dict} with a JSON Schema.

    @param schemaStore: A L{dict} mapping file paths to JSON Schema loaded
        as L{dict}.

    @return: The resolved JSON Schema.
    @rtype: L{dict}
    """
    result = copy.deepcopy(schema)
    resolver = LocalRefResolver(base_uri=b'', referrer=schema,
                                store=schemaStore)

    def resolve(obj):
        if isinstance(obj, list):
            for item in obj:
                resolve(item)
            return

        if isinstance(obj, dict):
            if "$ref" in obj:
                with resolver.resolving(obj[u'$ref']) as resolved:
                    resolve(resolved)
                    obj.clear()
                    obj.update(resolved)
            else:
                for value in obj.values():
                    resolve(value)

    resolve(result)
    result["$schema"] = "http://json-schema.org/draft-04/schema#"
    return result
dataset/ETHPy150Open ClusterHQ/flocker/flocker/restapi/_schema.py/resolveSchema/original