Use jsonapi-resources with Grape!
Add the grape
and grape-jsonapi-resources
gems to Gemfile.
gem 'grape'
gem 'grape-jsonapi-resources'
class API < Grape::API
format :json
formatter :json, Grape::Formatter::JSONAPIResources
end
get "/" do
user = User.find("123")
render user, include: ["account"], context: { something: :important }
end
Code adapted from grape-active_model_serializers