class ActiveModelSerializers::Adapter::JsonApi

def failure_document(options)

https://github.com/rails-api/active_model_serializers/pull/1004
prs:
}.reject! {|_,v| v.nil? }
jsonapi: toplevel_jsonapi
meta: toplevel_meta,
errors: toplevel_errors,
{
structure:
☐ toplevel_jsonapi
☐ toplevel_meta
☑ toplevel_errors array (required)
definition:
TODO: look into caching
{http://jsonapi.org/format/#errors JSON API Errors}
def failure_document(options)
  hash = {}
  # PR Please :)
  # Jsonapi.add!(hash)
  # toplevel_errors
  # definition:
  #   array of unique items of type 'error'
  # structure:
  #   [
  #     error,
  #     error
  #   ]
  if serializer.respond_to?(:each)
    hash[:errors] = serializer.flat_map do |error_serializer|
      Error.resource_errors(error_serializer, options)
    end
  else
    hash[:errors] = Error.resource_errors(serializer, options)
  end
  hash
end