def dereference_descriptor(resource, base_path: nil, reference_fields: nil)
      options = {
        base_path: base_path,
        reference_fields: reference_fields,
      }
      case resource
      when Hash
        resource.inject({}) do |new_resource, (key, val)|
          if reference_fields.nil? || reference_fields.include?(key)
            new_resource[key] = dereference_descriptor(val, **options)
          else
            new_resource[key] = val
          end
          new_resource
        end
      when Enumerable
        resource.map{ |el| dereference_descriptor(el, **options)}
      when String
        begin
          resolve_json_reference(resource, deep_dereference: true, base_path: base_path)
        rescue Errno::ENOENT
          resource
        end
      else
        resource
      end
    end
def dereference_descriptor(resource, base_path: nil, reference_fields: nil)
      options = {
        base_path: base_path,
        reference_fields: reference_fields,
      }
      case resource
      when Hash
        resource.inject({}) do |new_resource, (key, val)|
          if reference_fields.nil? || reference_fields.include?(key)
            new_resource[key] = dereference_descriptor(val, **options)
          else
            new_resource[key] = val
          end
          new_resource
        end
      when Enumerable
        resource.map{ |el| dereference_descriptor(el, **options)}
      when String
        begin
          resolve_json_reference(resource, deep_dereference: true, base_path: base_path)
        rescue Errno::ENOENT
          resource
        end
      else
        resource
      end
    end
Dereference a resource that can be a URL or path to a JSON file or a hash
 Returns a Hash with all values that are URLs or paths dereferenced