JSONAPI
This module is designed to work with a Phoenix Application. You give it a View, an Ecto model, and a Plug.Conn from a phoenix endpoint and it will spit out a map to be rendered by Poison.
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
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.
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.