finds all $ref instances and replaces with the actual object similar to dojox.json.ref.resolveJson, but doesn't get hung up on circular references TODO: should we assume all schemas have been resolved prior, and remove this step?
767147
function resolveRef(subobj, parent, parentKey) {
                    if (!subobj.resolved) {
                        Object.keys(subobj).forEach(function (key) {
                            var Ref, value = subobj[key];
                            if (key === "$ref") {
                                logger.debug("Resolving $ref: " + value);
                                Ref = refResolver(value);
                                value = typeof Ref === 'function' ? new Ref() : Ref;
                                if (!util.isUndefined(value) && !value.resolved) {
                                    subobj.resolved = true;
                                    resolveRef(value, subobj, key);
                                }
                                parent[parentKey] = value;
                            } else if (typeof value === "object") {
                                resolveRef(value, subobj, key);
                            }
                        });
                    }
                }
186600
function processRefs (instance) {
  return Object.keys(instance.$refs)
    .filter(key => instance.$refs[key])
    .map(key => getCustomRefDetails(instance, key, instance.$refs[key]))
}
1232860
def schema_helper(self, name, _, schema=None, **kwargs):
        
        if schema is None:
            return None

        schema_instance = resolve_schema_instance(schema)

        schema_key = make_schema_key(schema_instance)
        self.warn_if_schema_already_in_spec(schema_key)
        self.openapi.refs[schema_key] = name

        json_schema = self.openapi.schema2jsonschema(schema_instance)

        return json_schema
1254461
def resolve_json_reference(reference, deep_dereference: false, base_path: nil)
      # Try to extract JSON from file or webpage
      reference = join_paths(base_path, reference)
      resolved_reference = load_json(reference)
      if deep_dereference == true
        dereference_descriptor(resolved_reference, base_path: base_path)
      else
        resolved_reference
      end
    end
259365
function _getRef (refOrQuery) {
  if (typeof refOrQuery.ref === 'function') {
    refOrQuery = refOrQuery.ref()
  } else if (typeof refOrQuery.ref === 'object') {
    refOrQuery = refOrQuery.ref
  }

  return refOrQuery
}
645810
function reref(obj,options) {
    let master = obj;
    recurse(obj,{identityDetection:true},function(obj,key,state){
        if (state.identity) {
            let replacement = jptr(master,state.identityPath);
            // ensure it's still there and we've not reffed it away
            let newRef = state.identityPath;
            if (state.identityPath !== state.path) {
                if (options && options.prefix) newRef = newRef.replace('#/',options.prefix);
                if (replacement !== false) obj[key] = { $ref: newRef }
                else if (options && options.verbose) console.warn(state.identityPath,'gone away at',state.path);
            }
        }
    });
    return obj;
}
363544
function resolveReference(x, isModule) {
	if (x instanceof TReference) {
        if (isBuiltin(x.name))
            return new TBuiltin(x.name)
		if (x.resolution)
			return x.resolution
		if (x.resolving)
			throw new TypeError("Cyclic reference involving " + x)
		x.resolving = true
		var t = lookupInScope(x.scope, x.name, isModule)
		if (!t) {
            t = new TQualifiedReference(x.name) // XXX: for now assume global reference
			// throw new TypeError("Unresolved type: " + x.name)
		}
		t = resolveReference(t, isModule)
		x.resolution = t;
		return t;
	} else if (x instanceof TMember) {
		if (x.resolution)
			return x.resolution
		if (x.resolving)
			throw new TypeError("Cyclic reference involving " + x)
		x.resolving = true
		var base = resolveReference(x.base, true)
		var t = resolveReference(lookupInType(base, x.name, isModule), isModule)
		x.resolution = t
		return t;
    } else if (x instanceof TTypeQuery) {
        if (x.resolution)
            return x.resolution;
        if (x.resolving)
            throw new TypeError("Cyclic reference involving " + x)
        x.resolving = true
        var t = lookupPrtyInScope(x.scope, x.names[0])
        if (!t)
            throw new TypeError("Name not found: " + x.names[0])
        t = resolveReference(t)
        for (var i=1; i<x.names.length; i++) {
            var prty = t.properties.get(x.names[i])
            var module = t.modules.get(x.names[i])
            var t = prty ? prty.type : module;
            if (!t)
                throw new TypeError("Name not found: " + x.names.slice(0,i).join('.'))
            t = resolveReference(t)
        }
        if (t instanceof TObject && !t.qname) {
            t = synthesizeName(t) // don't create aliasing
        }
        x.resolution = t;
        return t;
	} else {
		return x;
	}
}
261404
function resolveReferences() {

    var elementsById = context.elementsById;
    var references = context.references;

    var i, r;

    for (i = 0; (r = references[i]); i++) {
      var element = r.element;
      var reference = elementsById[r.id];
      var property = getModdleDescriptor(element).propertiesByName[r.property];

      if (!reference) {
        context.addWarning({
          message: 'unresolved reference <' + r.id + '>',
          element: r.element,
          property: r.property,
          value: r.id
        });
      }

      if (property.isMany) {
        var collection = element.get(property.name),
            idx = collection.indexOf(r);

        // we replace an existing place holder (idx != -1) or
        // append to the collection instead
        if (idx === -1) {
          idx = collection.length;
        }

        if (!reference) {
          // remove unresolvable reference
          collection.splice(idx, 1);
        } else {
          // add or update reference in collection
          collection[idx] = reference;
        }
      } else {
        element.set(property.name, reference);
      }
    }
  }
1120060
def references_json(references):
    ''' 

    '''

    references_json = []
    for r in references:
        ref = r.ref
        ref['attributes'] = r._to_json_like(include_defaults=False)
        references_json.append(ref)

    return references_json
198111
function Pointer ($ref, path, friendlyPath) {
  /**
   * The {@link $Ref} object that contains this {@link Pointer} object.
   * @type {$Ref}
   */
  this.$ref = $ref;

  /**
   * The file path or URL, containing the JSON pointer in the hash.
   * This path is relative to the path of the main JSON schema file.
   * @type {string}
   */
  this.path = path;

  /**
   * The original path or URL, used for error messages.
   * @type {string}
   */
  this.originalPath = friendlyPath || path;

  /**
   * The value of the JSON pointer.
   * Can be any JSON type, not just objects. Unknown file types are represented as Buffers (byte arrays).
   * @type {?*}
   */
  this.value = undefined;

  /**
   * Indicates whether the pointer references itself.
   * @type {boolean}
   */
  this.circular = false;

  /**
   * The number of indirect references that were traversed to resolve the value.
   * Resolving a single pointer may require resolving multiple $Refs.
   * @type {number}
   */
  this.indirections = 0;
}
547690
function findResolver (reference, resolvers) {
  const refParts = reference.split(':')

  for (const resolver of resolvers) {
    if (resolver.canResolve(refParts)) {
      return resolver.resolver
    }
  }

  return null
}
533772
def lookup_json_pointer(ref)
      elements = ref.split('/')
      elements.shift
      @schema.dig(*elements) || raise("Definition `#{ref}` not found in the schema")
    end
538785
function fixrefs(scope, i) {
                        // do children first; order shouldn't matter
                        for (i = scope.children.length; --i >= 0;)
                                fixrefs(scope.children[i]);
                        for (i in scope.refs) if (HOP(scope.refs, i)) {
                                // find origin scope and propagate the reference to origin
                                for (var origin = scope.has(i), s = scope; s; s = s.parent) {
                                        s.refs[i] = origin;
                                        if (s === origin) break;
                                }
                        }
                }
740755
def _get_ref(data, position, obj_end, opts, element_name):
    """"""
    collection, position = _get_string(
        data, position, obj_end, opts, element_name)
    oid, position = _get_oid(data, position, obj_end, opts, element_name)
    return DBRef(collection, oid), position
389315
private function resolve(Reference $reference, $class)
    {
        $result = $reference;

        do {
            $refString = (string) $reference->getMergedUri();
            $result = $result->resolve(function ($data) use ($result, $class) {
                return $this->denormalizer->denormalize($data, $class, 'json', [
                    'document-origin' => (string) $result->getMergedUri()->withFragment(''),
                ]);
            });
        } while ($result instanceof Reference);

        return [$refString, $result];
    }
851925
function resolve(ref, context) {
    if (typeof ref !== 'string') return ref;
    if (/^#/.test(ref)) { ref = (context._href || '/') + ref; }
    return generator.fragment$[ref];
  }
15894
function resolve(opt) {
	if (opt instanceof Serializers.Base) {
		return opt;
	} else if (_.isString(opt)) {
		let SerializerClass = getByName(opt);
		if (SerializerClass)
			return new SerializerClass();
		else
			throw new BrokerOptionsError(`Invalid serializer type '${opt}'.`, { type: opt });

	} else if (_.isObject(opt)) {
		let SerializerClass = getByName(opt.type || "JSON");
		if (SerializerClass)
			return new SerializerClass(opt.options);
		else
			throw new BrokerOptionsError(`Invalid serializer type '${opt.type}'.`, { type: opt.type });
	}

	return new Serializers.JSON();
}