View Source JSONAPI.Serializer (jsonapi v1.8.3)

Serialize a map of data into a properly formatted JSON API response object

Summary

Types

@type document() :: map()

Functions

Link to this function

build_relationships(conn, parent_info, rel_config, acc, options)

View Source
@spec build_relationships(Plug.Conn.t(), tuple(), tuple(), tuple(), list()) :: tuple()
Link to this function

build_relationships(conn, arg, relationship_name, rel_data, rel_view, acc, options)

View Source
@spec build_relationships(
  Plug.Conn.t(),
  tuple(),
  term(),
  term(),
  module(),
  tuple(),
  list()
) :: tuple()
@spec data_loaded?(map() | list()) :: boolean()
Link to this function

encode_data(view, data, conn, query_includes, options)

View Source
Link to this function

encode_rel_data(view, data)

View Source
@spec encode_rel_data(module(), map() | list()) :: map() | nil
@spec encode_relation(tuple()) :: map()
Link to this function

encode_relationships(conn, doc, view_info, options)

View Source
@spec encode_relationships(Plug.Conn.t(), document(), tuple(), list()) :: tuple()
Link to this function

extrapolate_relationship_config(arg)

View Source
@spec extrapolate_relationship_config(tuple()) ::
  {atom(), atom(), module(), boolean()}

Given the relationship config entry provided by a JSONAPI.View, produce the extrapolated config tuple containing:

  • The name of the relationship to be used when serializing
  • The key in the data the relationship is found under
  • The relationship resource's JSONAPI.View module
  • A boolean for whether the relationship is included by default or not
Link to this function

flatten_included(included)

View Source
@spec flatten_included(keyword()) :: keyword()
Link to this function

serialize(view, data, conn \\ nil, meta \\ nil, options \\ [])

View Source

Takes a view, data and a optional plug connection and returns a fully JSONAPI Serialized document. This assumes you are using the JSONAPI.View and have data in maps or structs.

Please refer to JSONAPI.View for more information. If you are in interested in relationships and includes you may also want to reference the JSONAPI.QueryParser.