#NEWLINE# def schema_resolve_refs( schema , ref_resolver = None , root = None ) : #NEWLINE# #INDENT# '\n    Helper method for decoding references. Self-references are resolved automatically; other references are\n    resolved using a callback function.\n\n    :param object schema:\n    :param callable ref_resolver:\n    :param None root:\n    :return:\n    ' #NEWLINE# if isinstance ( schema , dict ) : #NEWLINE# #INDENT# if ( ( len ( schema ) == 1 ) and ( '$ref' in schema ) and isinstance ( schema [ '$ref' ] , six . string_types ) ) : #NEWLINE# #INDENT# reference = schema [ '$ref' ] #NEWLINE# if reference . startswith ( '#' ) : #NEWLINE# #INDENT# return root #NEWLINE# #UNINDENT# return ref_resolver ( schema ) #NEWLINE# #UNINDENT# resolved = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( k , v ) in schema . items ( ) : #NEWLINE# #INDENT# resolved [ k ] = schema_resolve_refs ( v , ref_resolver = ref_resolver , root = ( root if ( root is not None ) else resolved ) ) #NEWLINE# #UNINDENT# return resolved #NEWLINE# #UNINDENT# if isinstance ( schema , ( list , tuple ) ) : #NEWLINE# #INDENT# return [ schema_resolve_refs ( v , ref_resolver = ref_resolver , root = root ) for v in schema ] #NEWLINE# #UNINDENT# return schema