Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 790 Bytes

README.md

File metadata and controls

38 lines (26 loc) · 790 Bytes

Grape::JSONAPIResources

Use jsonapi-resources with Grape!

Installation

Add the grape and grape-jsonapi-resources gems to Gemfile.

gem 'grape'
gem 'grape-jsonapi-resources'

Usage

Require grape-jsonapi-resources

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

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

Use render to specify JSONAPI options

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

Credit

Code adapted from grape-active_model_serializers