From 0091be89f840279b0f10ae4cfcd81f732f4e7f41 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Fri, 4 Sep 2015 04:28:10 -0500 Subject: [PATCH] Consistently refer to the 'JSON API' and the 'JsonApi' adapter --- CHANGELOG.md | 2 +- README.md | 15 +++++++++++---- docs/general/adapters.md | 2 +- docs/howto/add_pagination_links.md | 9 ++++++--- lib/active_model/serializer/utils.rb | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a8a744..a550a964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/README.md b/README.md index 4377b2ac..3e17220e 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 @@ -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 diff --git a/docs/general/adapters.md b/docs/general/adapters.md index 03f34e99..59d4cbae 100644 --- a/docs/general/adapters.md +++ b/docs/general/adapters.md @@ -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 diff --git a/docs/howto/add_pagination_links.md b/docs/howto/add_pagination_links.md index 4241012e..d9f01e49 100644 --- a/docs/howto/add_pagination_links.md +++ b/docs/howto/add_pagination_links.md @@ -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) diff --git a/lib/active_model/serializer/utils.rb b/lib/active_model/serializer/utils.rb index 689f48ca..ca54f420 100644 --- a/lib/active_model/serializer/utils.rb +++ b/lib/active_model/serializer/utils.rb @@ -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