JSONAPI

This module is designed to work with a Phoenix Application. You give it an View, a Ecto model, and a Plug.Conn from a phoenix endpoint and it will spit out a map to be rendered by Poison.

Source

Summary

index(mod, data, conn, params)

Encodes a single map and its associations according to the view module’s callbacks

show(mod, data, conn, params)

Encodes a single map and its associations according to the view module’s callbacks

Functions

index(mod, data, conn, params)

Encodes a single map and its associations according to the view module’s callbacks.

JSONAPI.index(UserView, user_model)

will return a map formatted in the JSONAPI Spec, which then can be encoded using your prefered JSON encoder.

Source
show(mod, data, conn, params)

Specs:

  • show(module, Map, Plug.Conn.t, Map) :: Map
  • show(module, Map, Plug.Conn.t, Map) :: Map

Encodes a single map and its associations according to the view module’s callbacks.

JSONAPI.show(UserView, user_model, conn)

will return a map formatted in the JSONAPI Spec, which then can be encoded using your prefered JSON encoder.

Source