lib/json_schema.js
function(schema, field, reference, seenObjects, path, options) {
  // Don't resolve recursive relation
  if(reference == '#') return {$ref: '#'}

  // Get the path
  var path = reference.substr(1).split('/').slice(1);
  path = path.map(function(x) {
    x = x.replace(/~1/g, '/').replace(/~0/g, '~');
    return decodeURI(x);
  })

  // Get a pointer to the schema
  var pointer = schema;

  // Traverse the schema
  for(var i = 0; i < path.length; i++) {
    pointer = pointer[path[i]];
  }

  // Check if we have seen the object
  var objects = seenObjects.filter(function(x) {
    return x.obj === pointer;
  });

  if(objects.length == 1) {
    seenObjects[0].count = objects[0].count + 1;
  } else {
    seenObjects.push({obj: pointer, count: 1});
  }

  // Do we have a reference
  if(pointer['$ref']) {
    return deref(schema, field, pointer['$ref'], seenObjects, path, options);
  } else {
    extractReferences(schema, pointer, seenObjects, path, options);
  }

  return pointer;
}
function(schema, field, reference, seenObjects, path, options) {
  // Don't resolve recursive relation
  if(reference == '#') return {$ref: '#'}

  // Get the path
  var path = reference.substr(1).split('/').slice(1);
  path = path.map(function(x) {
    x = x.replace(/~1/g, '/').replace(/~0/g, '~');
    return decodeURI(x);
  })

  // Get a pointer to the schema
  var pointer = schema;

  // Traverse the schema
  for(var i = 0; i < path.length; i++) {
    pointer = pointer[path[i]];
  }

  // Check if we have seen the object
  var objects = seenObjects.filter(function(x) {
    return x.obj === pointer;
  });

  if(objects.length == 1) {
    seenObjects[0].count = objects[0].count + 1;
  } else {
    seenObjects.push({obj: pointer, count: 1});
  }

  // Do we have a reference
  if(pointer['$ref']) {
    return deref(schema, field, pointer['$ref'], seenObjects, path, options);
  } else {
    extractReferences(schema, pointer, seenObjects, path, options);
  }

  return pointer;
}
function ( schema , field , reference , seenObjects , path , options ) { // Don't resolve recursive relation if ( reference == '#' ) return { $ref : '#' } // Get the path var path = reference . substr ( 1 ) . split ( '/' ) . slice ( 1 ) ; path = path . map ( function ( x ) { x = x . replace ( / ~1 / g , '/' ) . replace ( / ~0 / g , '~' ) ; return decodeURI ( x ) ; } ) // Get a pointer to the schema var pointer = schema ; // Traverse the schema for ( var i = 0 ; i < path . length ; i ++ ) { pointer = pointer [ path [ i ] ] ; } // Check if we have seen the object var objects = seenObjects . filter ( function ( x ) { return x . obj === pointer ; } ) ; if ( objects . length == 1 ) { seenObjects [ 0 ] . count = objects [ 0 ] . count + 1 ; } else { seenObjects . push ( { obj : pointer , count : 1 } ) ; } // Do we have a reference if ( pointer [ '$ref' ] ) { return deref ( schema , field , pointer [ '$ref' ] , seenObjects , path , options ) ; } else { extractReferences ( schema , pointer , seenObjects , path , options ) ; } return pointer ; }
De-reference
De - reference