code: function deref (schema, options) {
    options = _.defaults(options, defaults)
  
    const bf = options.baseFolder
    let cwd = bf
    if (!utils.isAbsolute(bf)) {
      cwd = path.resolve(process.cwd(), bf)
    }
  
    const state = {
      graph: new DAG(),
      circular: false,
      circularRefs: [],
      cwd: cwd,
      missing: [],
      history: []
    }
  
    try {
      const str = JSON.stringify(schema)
      state.current = md5(str)
    } catch (e) {
      return e
    }
  
    const baseSchema = clone(schema)
  
    cache = {}
  
    let ret = derefSchema(baseSchema, options, state)
    if (ret instanceof Error === false && state.error) {
      return state.error
    }
    return ret
  }
docs: Derefs <code>$ref</code>'s in JSON Schema to actual resolved values. Supports local, and file refs.
  @param {Object} schema - The JSON schema
  @param {Object} options - options
  @param {String} options.baseFolder - the base folder to get relative path files from. Default is <code>process.cwd()</code>
  @param {Boolean} options.failOnMissing - By default missing / unresolved refs will be left as is with their ref value intact.
  If set to <code>true</code> we will error out on first missing ref that we cannot
  resolve. Default: <code>false</code>.
  @param {Boolean} options.mergeAdditionalProperties - By default properties in a object with $ref will be removed in the output.
  If set to <code>true</code> they will be added/overwrite the output. This will use lodash's merge function.
  Default: <code>false</code>.
  @param {Boolean} options.removeIds - By default <code>$id</code> fields will get copied when dereferencing.
  If set to <code>true</code> they will be removed.
  Default: <code>false</code>.
  @param {Object} options.loaders - A hash mapping reference types (e.g., 'file') to loader functions.
  @return {Object|Error} the deref schema oran instance of <code>Error</code> if error.