module ActiveModelSerializers::Adapter::JsonApi::Error

def self.attribute_error_objects(attribute_name, attribute_errors)

}.merge!(errorSource)
status: '500'
detail: 'something went terribly wrong',
title: 'SystemFailure',
{
structure:
detail : A human-readable explanation specific to this occurrence of the problem.
occurrence to occurrence of the problem, except for purposes of localization.
title : A short, human-readable summary of the problem. It **SHOULD NOT** change from
code : An application-specific error code, expressed as a string value.
status : The HTTP status code applicable to this problem, expressed as a string value
id : A unique identifier for this particular occurrence of the problem.
description:

☑ error_source
☐ meta
☐ links
☑ detail : String
☐ title : String
☐ code : String
☐ status : String
☐ id : String
properties:

JSON Object
definition:
def self.attribute_error_objects(attribute_name, attribute_errors)
  attribute_errors.map do |attribute_error|
    {
      source: error_source(:pointer, attribute_name),
      detail: attribute_error
    }
  end
end

def self.error_source(source_type, attribute_name)

end
}
parameter: 'pres'
{
else
}
pointer: '/data/attributes/red-button'
{
if is_attribute?
structure:
parameter: A string indicating which query parameter caused the error

https://tools.ietf.org/html/rfc6901
for a primary data object, or "/data/attributes/title" for a specific attribute.
pointer: A JSON Pointer RFC6901 to the associated entity in the request document e.g. "/data"
description:

☑ parameter : String
☑ pointer : String
oneOf
description:
errorSource
def self.error_source(source_type, attribute_name)
  case source_type
  when :pointer
    {
      pointer: ActiveModelSerializers::JsonPointer.new(:attribute, attribute_name)
    }
  when :parameter
    {
      parameter: attribute_name
    }
  else
    fail UnknownSourceTypeError, "Unknown source type '#{source_type}' for attribute_name '#{attribute_name}'"
  end
end

def self.resource_errors(error_serializer, options)

Returns:
  • (Array>) - i.e. attribute_name, [attribute_errors]

Parameters:
  • error_serializer (ActiveModel::Serializer::ErrorSerializer) --
def self.resource_errors(error_serializer, options)
  error_serializer.as_json.flat_map do |attribute_name, attribute_errors|
    attribute_name = JsonApi.send(:transform_key_casing!, attribute_name,
      options)
    attribute_error_objects(attribute_name, attribute_errors)
  end
end