From 168ec0ec2ad31964bc928ce8e791fa114cef43b7 Mon Sep 17 00:00:00 2001 From: "L. Preston Sego III" Date: Fri, 30 Oct 2015 13:58:42 -0400 Subject: [PATCH 1/5] begin integration docs --- docs/README.md | 5 ++++- docs/{howto => integrations}/ember-and-json-api.md | 2 +- docs/integrations/grape.md | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) rename docs/{howto => integrations}/ember-and-json-api.md (98%) create mode 100644 docs/integrations/grape.md diff --git a/docs/README.md b/docs/README.md index a1e9d908e..e1b447509 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,7 +15,10 @@ This is the documentation of AMS, it's focused on the **0.10.x version.** - [How to add root key](howto/add_root_key.md) - [How to add pagination links](howto/add_pagination_links.md) - [Using AMS Outside Of Controllers](howto/outside_controller_use.md) -- [How to use JSON API with Ember](howto/ember-and-json-api.md) + +## Integrations +- [Ember with JSON API](integrations/ember-and-json-api.md) +- [Grape](integrations/grape.md) ## Getting Help diff --git a/docs/howto/ember-and-json-api.md b/docs/integrations/ember-and-json-api.md similarity index 98% rename from docs/howto/ember-and-json-api.md rename to docs/integrations/ember-and-json-api.md index b132aabfd..85cf3f8b1 100644 --- a/docs/howto/ember-and-json-api.md +++ b/docs/integrations/ember-and-json-api.md @@ -1,4 +1,4 @@ -# How to use JSON API Query Parameters with Ember +# Integrating with Ember and JSON API - [Preparation](./ember-and-json-api.md#preparation) - [Adapter Changes](./ember-and-json-api.md#adapter-changes) diff --git a/docs/integrations/grape.md b/docs/integrations/grape.md new file mode 100644 index 000000000..3ae97fd62 --- /dev/null +++ b/docs/integrations/grape.md @@ -0,0 +1,3 @@ +# Integration with Grape + +TODO: details on how to integrate with grape From 4cb5ad08e740ae633bff1c2495fc6d59b86d2569 Mon Sep 17 00:00:00 2001 From: "L. Preston Sego III" Date: Fri, 30 Oct 2015 14:10:17 -0400 Subject: [PATCH 2/5] update ember docs with ember-data issue tracking urlForFindRecord / the inability to use query params on a single resource find --- docs/integrations/ember-and-json-api.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/integrations/ember-and-json-api.md b/docs/integrations/ember-and-json-api.md index 85cf3f8b1..f0e6b5fb3 100644 --- a/docs/integrations/ember-and-json-api.md +++ b/docs/integrations/ember-and-json-api.md @@ -34,6 +34,8 @@ export default DS.JSONAPIAdapter.extend({ // allows queries to be sent along with a findRecord // hopefully Ember / EmberData will soon have this built in + // ember-data issue tracked here: + // https://github.com/emberjs/data/issues/3596 urlForFindRecord(id, modelName, snapshot) { let url = this._super(...arguments); let query = Ember.get(snapshot, 'adapterOptions.query'); From 21873130bb70d5b09e334b91752560855b13132c Mon Sep 17 00:00:00 2001 From: "L. Preston Sego III" Date: Fri, 27 Nov 2015 08:41:29 -0500 Subject: [PATCH 3/5] update docs with integration table, and remove the grape placeholder for now --- docs/README.md | 9 +++++++-- docs/integrations/grape.md | 3 --- 2 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 docs/integrations/grape.md diff --git a/docs/README.md b/docs/README.md index e1b447509..7708a7465 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,8 +17,13 @@ This is the documentation of AMS, it's focused on the **0.10.x version.** - [Using AMS Outside Of Controllers](howto/outside_controller_use.md) ## Integrations -- [Ember with JSON API](integrations/ember-and-json-api.md) -- [Grape](integrations/grape.md) +| Integration | Supported AMS versions | Gem name and/or link +|----|-----|---- +| Ember.js | 0.9.x | [active-model-adapter](https://github.com/ember-data/active-model-adapter) +| Ember.js | 0.10.x + | [docs/integrations/ember-and-json-api.md](integrations/ember-and-json-api.md) +| Grape | 0.10.x + | #1258 | +| Grape | 0.9.x | https://github.com/jrhe/grape-active_model_serializers/ | +| Sinatra | 0.9.x | https://github.com/SauloSilva/sinatra-active-model-serializers/ ## Getting Help diff --git a/docs/integrations/grape.md b/docs/integrations/grape.md deleted file mode 100644 index 3ae97fd62..000000000 --- a/docs/integrations/grape.md +++ /dev/null @@ -1,3 +0,0 @@ -# Integration with Grape - -TODO: details on how to integrate with grape From 21fe3abdfca7d78ef51ceaef0b2d194af560c5df Mon Sep 17 00:00:00 2001 From: "L. Preston Sego III" Date: Fri, 27 Nov 2015 08:43:15 -0500 Subject: [PATCH 4/5] make issue number a link --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 7708a7465..f3798a7e6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -21,7 +21,7 @@ This is the documentation of AMS, it's focused on the **0.10.x version.** |----|-----|---- | Ember.js | 0.9.x | [active-model-adapter](https://github.com/ember-data/active-model-adapter) | Ember.js | 0.10.x + | [docs/integrations/ember-and-json-api.md](integrations/ember-and-json-api.md) -| Grape | 0.10.x + | #1258 | +| Grape | 0.10.x + | [#1258](https://github.com/rails-api/active_model_serializers/issues/1258) | | Grape | 0.9.x | https://github.com/jrhe/grape-active_model_serializers/ | | Sinatra | 0.9.x | https://github.com/SauloSilva/sinatra-active-model-serializers/ From 2dc78c59162e5f0820e2b04ccb19da54ee7f7060 Mon Sep 17 00:00:00 2001 From: "L. Preston Sego III" Date: Tue, 1 Dec 2015 14:49:57 -0500 Subject: [PATCH 5/5] add information about server side changes --- docs/integrations/ember-and-json-api.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/integrations/ember-and-json-api.md b/docs/integrations/ember-and-json-api.md index f0e6b5fb3..cf2e52ae4 100644 --- a/docs/integrations/ember-and-json-api.md +++ b/docs/integrations/ember-and-json-api.md @@ -1,7 +1,8 @@ # Integrating with Ember and JSON API - [Preparation](./ember-and-json-api.md#preparation) - - [Adapter Changes](./ember-and-json-api.md#adapter-changes) + - [Server-Side Changes](./ember-and-json-api.md#server-side-changes) + - [Adapter Changes](./ember-and-json-api.md#adapter-changes) - [Serializer Changes](./ember-and-json-api.md#serializer-changes) - [Including Nested Resources](./ember-and-json-api.md#including-nested-resources) @@ -12,6 +13,21 @@ Note: This guide assumes that `ember-cli` is used for your ember app. The JSON API specification calls for hyphens for multi-word separators. AMS uses underscores. To solve this, in Ember, both the adapter and the serializer will need some modifications: +### Server-Side Changes + +there are multiple mimetypes for json that should all be parsed similarly, so +in `config/initializers/mime_types.rb`: +```ruby +api_mime_types = %W( + application/vnd.api+json + text/x-json + application/json +) + +Mime::Type.unregister :json +Mime::Type.register 'application/json', :json, api_mime_types +``` + ### Adapter Changes ```javascript