expandRefs (schema, recurseAllOf) {
    const _schema = extend({}, schema)

    if (!_schema.$ref) return _schema
    // This split the ref to get the Json point if it exists
    // exemple #/counter/1#/definition/address +
    // [1] -> /counter/1
    // [2] -> /definition/address
    const refWithPointerSplit = _schema.$ref.split('#')
    // If local ref
    if (refWithPointerSplit.length === 2 && !this.refs_with_info[_schema.$ref]) {
      const sub = this.expandRecursivePointer(this.schema, refWithPointerSplit[1])
      const expandedSchema = this.extendSchemas(_schema, this.expandSchema(sub))
      delete expandedSchema.$ref
      return expandedSchema
    }
    const refObj = (refWithPointerSplit.length > 2)
      ? this.refs_with_info['#' + refWithPointerSplit[1]]
      : this.refs_with_info[_schema.$ref]
    delete _schema.$ref
    const fetchUrl = refObj.$ref.startsWith('#')
      ? refObj.fetchUrl
      : ''
    const ref = this._getRef(fetchUrl, refObj)

    if (!this.refs[ref]) { /* if reference not found */
      // eslint-disable-next-line no-console
      console.warn(`reference:'${ref}' not found!`)
    } else if (recurseAllOf && hasOwnProperty(this.refs[ref], 'allOf')) {
      const allOf = this.refs[ref].allOf
      Object.keys(allOf).forEach(key => {
        allOf[key] = this.expandRefs(allOf[key], true)
      })
    }
    if (refWithPointerSplit.length > 2) {
      return this.extendSchemas(_schema, this.expandSchema(this.expandRecursivePointer(this.refs[ref], refWithPointerSplit[2])))
    } else {
      return this.extendSchemas(_schema, this.expandSchema(this.refs[ref]))
    }
  }
Recursively expands loaded references in a provided schema.

@param {object} schema - A JSON Schema with references already loaded.
@param {boolean} recurseAllOf - Set true to recurse allOf properties.
@returns {object} A JSON Schema with references expanded.