Sha256: d556e021f41f48b8d7a2ae95bb7600caa43b7324bd4b6d208d274a3ebafea257

Contents?: true

Size: 790 Bytes

Versions: 7

Compression:

Stored size: 790 Bytes

Contents

# Grape::JSONAPIResources

Use [jsonapi-resources](https://github.com/cerebris/jsonapi-resources) with [Grape](https://github.com/intridea/grape)!

## Installation

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

```ruby
gem 'grape'
gem 'grape-jsonapi-resources'
```

## Usage

### Require grape-jsonapi-resources

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

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

### Use `render` to specify JSONAPI options

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

## Credit

Code adapted from [grape-active_model_serializers](https://github.com/jrhe/grape-active_model_serializers)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
grape-jsonapi-resources-0.0.7 README.md
grape-jsonapi-resources-0.0.6 README.md
grape-jsonapi-resources-0.0.5 README.md
grape-jsonapi-resources-0.0.4 README.md
grape-jsonapi-resources-0.0.3 README.md
grape-jsonapi-resources-0.0.2 README.md
grape-jsonapi-resources-0.0.1 README.md