Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently refer to the 'JSON API' and the 'JsonApi' adapter #1174

Merged
merged 1 commit into from
Sep 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
* remove root key option and split JSON adapter [@joaomdmoura]
* adds FlattenJSON as default adapter [@joaomdmoura]
* adds support for `pagination links` at top level of JsonApi adapter [@bacarini]
* adds extended format for `include` option to JSONAPI adapter [@beauby]
* adds extended format for `include` option to JsonApi adapter [@beauby]
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ The key can be customized using `meta_key` option.
render json: @post, meta: { total: 10 }, meta_key: "custom_meta"
```

`meta` will only be included in your response if you are using an Adapter that supports `root`, as JsonAPI and Json adapters, the default adapter (FlattenJson) doesn't have `root`.
`meta` will only be included in your response if you are using an Adapter that supports `root`,
as JsonAPI and Json adapters, the default adapter (FlattenJson) doesn't have `root`.

### Using a serializer without `render`

Expand Down Expand Up @@ -199,7 +200,7 @@ Doesn't follow any specifc convention.
It also generates a json response but always with a root key. The root key **can't be overridden**, and will be automatically defined accordingly with the objects being serialized.
Doesn't follow any specifc convention.

#### JSONAPI
#### JSON API

This adapter follows 1.0 of the format specified in
[jsonapi.org/format](http://jsonapi.org/format). It will include the associated
Expand Down Expand Up @@ -285,9 +286,15 @@ And you can change the JSON key that the serializer should use for a particular

## Pagination

Pagination links will be included in your response automatically as long as the resource is paginated using [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate) and if you are using a ```JSON-API``` adapter.
Pagination links will be included in your response automatically as long
as the resource is paginated using [Kaminari](https://github.com/amatsuda/kaminari) or
[WillPaginate](https://github.com/mislav/will_paginate) and
if you are using the ```JsonApi``` adapter.

Although the others adapters does not have this feature, it is possible to implement pagination links to `JSON` adapter. For more information about it, please see in our docs [How to add pagination links](https://github.com/rails-api/active_model_serializers/blob/master/docs/howto/add_pagination_links.md)
Although the others adapters does not have this feature, it is possible to
implement pagination links to `JSON` adapter. For more information about it,
please see in our docs [How to add pagination
links](https://github.com/rails-api/active_model_serializers/blob/master/docs/howto/add_pagination_links.md).

## Caching

Expand Down
2 changes: 1 addition & 1 deletion docs/general/adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Doesn't follow any specifc convention.
It also generates a json response but always with a root key. The root key **can't be overridden**, and will be automatically defined accordingly to the objects being serialized.
Doesn't follow any specifc convention.

### JSONAPI
### JSON API

This adapter follows **version 1.0** of the format specified in
[jsonapi.org/format](http://jsonapi.org/format). It will include the associated
Expand Down
9 changes: 6 additions & 3 deletions docs/howto/add_pagination_links.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# How to add pagination links

### JSON-API adapter
### JSON API adapter

Pagination links will be included in your response automatically as long as the resource is paginated and if you are using a ```JSON-API``` adapter.
Pagination links will be included in your response automatically as long as
the resource is paginated and if you are using the ```JsonApi``` adapter.

If you want pagination links in your response, use [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate).
If you want pagination links in your response, use [Kaminari](https://github.com/amatsuda/kaminari)
or [WillPaginate](https://github.com/mislav/will_paginate).

###### Kaminari examples

```ruby
#array
@posts = Kaminari.paginate_array([1, 2, 3]).page(3).per(1)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_model/serializer/utils.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ActiveModel::Serializer::Utils
module_function

# Translates a comma separated list of dot separated paths (JSONAPI format) into a Hash.
# Translates a comma separated list of dot separated paths (JSON API format) into a Hash.
# Example: `'posts.author, posts.comments.upvotes, posts.comments.author'` would become `{ posts: { author: {}, comments: { author: {}, upvotes: {} } } }`.
#
# @param [String] included
Expand Down