lib/dereference.js
function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
  // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);

  var $refPath = url.resolve(path, $ref.$ref);
  var pointer = $refs._resolve($refPath, options);

  // Check for circular references
  var directCircular = pointer.circular;
  var circular = directCircular || parents.indexOf(pointer.value) !== -1;
  circular && foundCircularReference(path, $refs, options);

  // Dereference the JSON reference
  var dereferencedValue = $Ref.dereference($ref, pointer.value);

  // Crawl the dereferenced value (unless it's circular)
  if (!circular) {
    // Determine if the dereferenced value is circular
    var dereferenced = crawl(dereferencedValue, pointer.path, pathFromRoot, parents, $refs, options);
    circular = dereferenced.circular;
    dereferencedValue = dereferenced.value;
  }

  if (circular && !directCircular && options.dereference.circular === "ignore") {
    // The user has chosen to "ignore" circular references, so don't change the value
    dereferencedValue = $ref;
  }

  if (directCircular) {
    // The pointer is a DIRECT circular reference (i.e. it references itself).
    // So replace the $ref path with the absolute path from the JSON Schema root
    dereferencedValue.$ref = pathFromRoot;
  }

  return {
    circular: circular,
    value: dereferencedValue
  };
}
function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
  // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);

  var $refPath = url.resolve(path, $ref.$ref);
  var pointer = $refs._resolve($refPath, options);

  // Check for circular references
  var directCircular = pointer.circular;
  var circular = directCircular || parents.indexOf(pointer.value) !== -1;
  circular && foundCircularReference(path, $refs, options);

  // Dereference the JSON reference
  var dereferencedValue = $Ref.dereference($ref, pointer.value);

  // Crawl the dereferenced value (unless it's circular)
  if (!circular) {
    // Determine if the dereferenced value is circular
    var dereferenced = crawl(dereferencedValue, pointer.path, pathFromRoot, parents, $refs, options);
    circular = dereferenced.circular;
    dereferencedValue = dereferenced.value;
  }

  if (circular && !directCircular && options.dereference.circular === "ignore") {
    // The user has chosen to "ignore" circular references, so don't change the value
    dereferencedValue = $ref;
  }

  if (directCircular) {
    // The pointer is a DIRECT circular reference (i.e. it references itself).
    // So replace the $ref path with the absolute path from the JSON Schema root
    dereferencedValue.$ref = pathFromRoot;
  }

  return {
    circular: circular,
    value: dereferencedValue
  };
}
function dereference$Ref ( $ref , path , pathFromRoot , parents , $refs , options ) { // console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);
 var $refPath = url . resolve ( path , $ref . $ref ) ; var pointer = $refs . _resolve ( $refPath , options ) ; // Check for circular references
 var directCircular = pointer . circular ; var circular = directCircular || parents . indexOf ( pointer . value ) !== - 1 ; circular && foundCircularReference ( path , $refs , options ) ; // Dereference the JSON reference
 var dereferencedValue = $Ref . dereference ( $ref , pointer . value ) ; // Crawl the dereferenced value (unless it's circular)
 if ( ! circular ) { // Determine if the dereferenced value is circular
 var dereferenced = crawl ( dereferencedValue , pointer . path , pathFromRoot , parents , $refs , options ) ; circular = dereferenced . circular ; dereferencedValue = dereferenced . value ; } if ( circular && ! directCircular && options . dereference . circular === "ignore" ) { // The user has chosen to "ignore" circular references, so don't change the value
 dereferencedValue = $ref ; } if ( directCircular ) { // The pointer is a DIRECT circular reference (i.e. it references itself).
 // So replace the $ref path with the absolute path from the JSON Schema root
 dereferencedValue . $ref = pathFromRoot ; } return { circular : circular , value : dereferencedValue } ; }
Dereferences the given JSON Reference, and then crawls the resulting value.

@param {{$ref: string}} $ref - The JSON Reference to resolve
@param {string} path - The full path of `$ref`, possibly with a JSON Pointer in the hash
@param {string} pathFromRoot - The path of `$ref` from the schema root
@param {object[]} parents - An array of the parent objects that have already been dereferenced
@param {$Refs} $refs
@param {$RefParserOptions} options
@returns {{value: object, circular: boolean}}
Dereferences the given JSON Reference and then crawls the resulting value .