jsonapi_plug - JSON:API library for Plug and Phoenix applications

Hey,

I’ve just published the first version of a new JSON:API library. This project was born as a fork of the jsonapi library (GitHub - beam-community/jsonapi: JSON:API Serializer and Query Handler for Elixir) but has since been almost completly rewritten and is a different project.

What jsonapi_plug has to offer to users of Phoenix/Plug for building JSON:API compliant APIs:

  • An extensible system based on behaviours to convert JSON:API payloads and query parameters from/to whatever format best suits the library user. Default implementations are provided to convert payloads and query parameters to an Ecto friendly format, which is probably the most common scenario for the data source of APIs in Phoenix based applications. Behaviours are available to customize parsing and/or easily parse non-standard specified query parameters (filter, page).

  • Ability to have multiple APIs with different configurations sourced from the hosting application configuration to avoid single global configuration rigidity. This allows to serve multiple different APIs from a single Phoenix/Plug application instance.

  • A declarative resource system allowing users to control rendering, rename fields between JSON:API payloads and internal data, customize (de)serialization of fields values and more without writing additional business logic code.

I’ve been using this for some time in production, but I’d love to get some feedback. It currently targets JSON:API 1.0, but I’d love to add support for the recently finalized JSON:API 1.1 spec.

3 Likes

Totally forgot to add links:

2 Likes