def _resolve_refs(uri, spec):
resolver = jsonschema.RefResolver(uri, spec)<EOL>def _do_resolve(node):<EOL><INDENT>if isinstance(node, collections.Mapping) and '<STR_LIT>' in node:<EOL><INDENT>with resolver.resolving(node['<STR_LIT>']) as resolved:<EOL><INDENT>return resolved<EOL><DEDENT><DEDENT>elif isinstance(node, collections.Mapping):<EOL><INDENT>for k, v in node.items():<EOL><INDENT>node[k] = _do_resolve(v)<EOL><DEDENT><DEDENT>elif isinstance(node, (list, tuple)):<EOL><INDENT>for i in range(len(node)):<EOL><INDENT>node[i] = _do_resolve(node[i])<EOL><DEDENT><DEDENT>return node<EOL><DEDENT>return _do_resolve(spec)<EOL>
Resolve JSON references in a given dictionary.

    OpenAPI spec may contain JSON references to its nodes or external
    sources, so any attempt to rely that there's some expected attribute
    in the spec may fail. So we need to resolve JSON references before
    we use it (i.e. replace with referenced object). For details see:

        https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-02

    The input spec is modified in-place despite being returned from
    the function.