Grape::FastJsonapi

Use fast_jsonapi with Grape.

Installation

Add the grape and grape_fast_jsonapi gems to Gemfile.

gem 'grape'
# gem is not published to rubygems yet
gem 'grape_fast_jsonapi', git: '[email protected]:EmCousin/grape_fast_jsonapi.git'

Usage

Require grape_fast_jsonapi

Tell your API to use Grape::Formatter::FastJsonapi

class API < Grape::API
  format :json
  formatter :json, Grape::Formatter::FastJsonapi
end

Use render to specify JSONAPI options

get "/" do
  user = User.find("123")
  render user, include: [:account]
end

Credit

Code adapted from grape-jsonapi-resources