Commit Graph

1188 Commits

Author SHA1 Message Date
Ryunosuke SATO
2135256004 Test against latest Ruby 2.1.x on Travis CI 2014-12-10 02:40:45 +09:00
Steve Klabnik
c67da11b96 Merge pull request #745 from jockee/patch-1
Missing a word
2014-12-04 17:20:33 +01:00
Joakim Ekström
9768da7a70 Missing a word 2014-12-04 17:05:10 +01:00
Steve Klabnik
8bbf6b8c8b Merge pull request #707 from jherdman/patch-1
A Friendly Note on Which AMS Version to Use
2014-11-20 10:27:19 -05:00
James Herdman
faa6f906d6 A Friendly Note on Which AMS Version to Use
Per the discussion in #702, I figured it might be nice to note which
version of AMS is recommended to be used in new projects.
2014-11-20 10:20:04 -05:00
Alexandre de Oliveira
a933d44673 Merge pull request #730 from rails-api/fixes-nested-has-many-links
Fixes nested has_many links in JSONAPI
2014-11-17 11:30:20 -02:00
Aaron Renoir
2ed52f96a6 merge upstream update fieldset 2014-11-13 17:45:47 -08:00
Alexandre de Oliveira
2f5626d616 Fixes nested has_many links in JSONAPI
When linked resource had has_many links, all of them would use the
association from the first resource, causing all of the items to build
`links` with the same associations.

This fixes it by iterating over the serializers, not just the
attributes array.
2014-11-13 16:38:47 -02:00
Alexandre de Oliveira
c53f1da18e Merge pull request #718 from ggordon/adapter_override
Allow overriding the adapter with render option
2014-11-13 13:59:12 -02:00
Gary Gordon
5560b49098 Allow overriding the adapter with render option
Make it easy to use multiple adapters in an app.

use "adapter: false" to not use ams

make a test override config.adapter
2014-11-13 10:23:19 -05:00
Gary Gordon
9f9715801a Explicitly set serializer for associations
Document specifying serializer for assocaition
2014-11-13 10:17:59 -05:00
Alexandre de Oliveira
08fbba9087 Merge pull request #720 from ggordon/attribute_with_key
Rename attribute with :key (0.8.x compatibility)
2014-11-13 11:38:06 -02:00
Gary Gordon
08716d20c9 Rename attribute with :key (0.8.x compatibility) 2014-11-13 08:03:22 -05:00
Alexandre de Oliveira
ac37570bff Merge pull request #728 from rails-api/linked-resources-use-type-as-key
Use type as key for linked resources
2014-11-13 10:53:59 -02:00
Alexandre de Oliveira
90b88da70a Fixes rbx gems bundling on TravisCI
Fixes https://github.com/travis-ci/travis-ci/issues/2821
2014-11-13 10:35:41 -02:00
Steve Klabnik
7dd2ee8690 Merge pull request #729 from joshk/patch-2
Use the new beta build env on Travis
2014-11-12 18:18:04 -05:00
Josh Kalderimis
9064955499 Use the new beta build env on Travis
also remove the custom bundle install line as Travis does that by default
2014-11-12 14:34:34 -08:00
Alexandre de Oliveira
4af02021ac Merge pull request #703 from ggordon/specify_serializer_from_controller
Support serializer and each_serializer options in renderer
2014-11-12 20:09:51 -02:00
Alexandre de Oliveira
7333f20285 Use type as key for linked resources
If type is `author` but the association is called `writer`, the linked
resource key should be called `authors`, e.g

    {
      ...
      linked: {
        authors: [{
          ...
        }]
      }
      ...
    }
2014-11-12 20:03:25 -02:00
Alexandre de Oliveira
5038147c4c Merge pull request #727 from rails-api/include-links-in-linked-resources
Includes links inside of linked resources
2014-11-12 19:08:50 -02:00
Alexandre de Oliveira
91b3fba509 Includes links inside of linked resources
According to
http://jsonapi.org/format/#document-structure-resource-objects,

> Resource objects have the same internal structure, regardless of
> whether they represent primary or linked resources.

And then
http://jsonapi.org/format/#document-structure-resource-object-attributes,

> There are four reserved keys in resource objects:
>
> "id"
> "type"
> "href"
> "links"

This commits includes `links` inside of linked resources.
2014-11-12 15:44:54 -02:00
Alexandre de Oliveira
7592e838ee Merge pull request #726 from rails-api/json-api-include-with-nested-has-many
Bugfix: include nested has_many associations
2014-11-11 22:51:45 -02:00
Alexandre de Oliveira
971f501e55 Bugfix: include nested has_many association
Currently, doing `include: author.bio` would work correctly, but not for
has_many associations such as `include: author.roles`. This fixes it.

The problem was basically that we were not handling arrays for has_many linked,
as happens for ArraySerializers.
2014-11-11 14:35:00 -02:00
Alexandre de Oliveira
33e8d09ad0 Merge pull request #722 from ggordon/stack_level_too_deep
Fix infinite recursion
2014-11-10 12:31:14 -02:00
Gary Gordon
3925f93df2 Merge pull request #1 from metermd/master
Allow for the implicit use of ArraySerializer when :each_serializer is specified
2014-11-07 10:21:40 -05:00
Gary Gordon
d97b2f5005 Fix infinite recursion
The method for testing whether to include an association was causing
an infinite loop when two models referenced each other.
2014-11-07 10:03:31 -05:00
Mike A. Owens
58b6c4a6b7 Allow for the implicit use of ArraySerializer when :each_serializer is specified. 2014-11-07 09:39:36 -05:00
Aaron Renoir
fc1562c04a add fields to adapter initialize function, pull in master, add tests using includes with fields 2014-11-05 18:10:37 -08:00
Aaron Renoir
c9c58e31e5 merge upstream/master 2014-11-05 16:47:15 -08:00
Gary Gordon
c84430cdad Support serializer and each_serializer in render json 2014-11-05 15:10:14 -05:00
Alexandre de Oliveira
95d122046d Merge pull request #692 from ggordon/linked_for_jsonapi_collection
Include 'linked' member for json-api collections
2014-11-04 21:59:15 -02:00
Carlos Antonio da Silva
8374396b88 Merge pull request #714 from ride/to-json-as-json
Define as_json instead of to_json
2014-11-03 22:00:36 -02:00
Guillermo Iguaran
f5411f045f Define as_json instead of to_json 2014-11-03 17:38:58 -05:00
Gary Gordon
d5bae0c2f0 Include 'linked' member for json-api collections
The options passed to the render are partitioned into adapter options
and serializer options. 'include' and 'root' are sent to the adapter,
not sure what options would go directly to serializer, but leaving this
in until I understand that better.
2014-11-03 17:13:55 -05:00
Alexandre de Oliveira
80ece39dd9 Merge pull request #710 from ride/fix-empty-linked
JSON-API: Don't include linked section if associations are empty
2014-11-02 01:53:37 -02:00
Alexandre de Oliveira
deaf55eeae Merge pull request #711 from rails-api/fixes-rbx-on-travis
Fixes rbx gems bundling on TravisCI
2014-11-02 01:51:14 -02:00
Alexandre de Oliveira
3504c1a5d8 Fixes rbx gems bundling on TravisCI 2014-11-02 01:23:29 -02:00
Guillermo Iguaran
3bba334cf8 JSON-API: Don't include linked section if associations are empty 2014-10-31 14:30:59 -05:00
Alexandre de Oliveira
5acd0be287 Merge pull request #709 from ride/add-type
Add type key when association name is different than object type
2014-10-31 15:03:32 -02:00
Guillermo Iguaran
2d21a8e83f Add type when association name is different than objects type 2014-10-31 01:54:13 -05:00
Alexandre de Oliveira
462efc0ea5 Merge pull request #708 from ride/fix-for-nil-associations
Handle correctly null associations
2014-10-31 00:53:47 -02:00
Guillermo Iguaran
19ac139880 Handle correctly null associations
null belongs_to associations are now serialized as nil instead
of raise an error during serialization.
2014-10-30 09:35:05 -05:00
Alexandre de Oliveira
baf3db1365 Merge pull request #691 from jacob-s-son/fix-embed-option-for-associations
Fix embed option for associations
2014-10-29 18:41:59 -02:00
Alexandre de Oliveira
617756623c Merge pull request #689 from ride/fix-json-api-custom-root
Fix support for custom root in JSON-API adapter
2014-10-29 15:06:13 -02:00
Aaron Renoir
be54e0bc4f remove serializer dependency from fieldset 2014-10-27 15:24:19 -07:00
Aaron Renoir
34f08477e4 fix tests, but need to understand how the serializer class attribute _associations was getting changed. 2014-10-26 14:41:14 -07:00
Aaron Renoir
39bee48ae6 implement sparse fieldsets http://jsonapi.org/format/#fetching-sparse-fieldsets 2014-10-26 13:04:14 -07:00
Edgars Jekabsons
f9b7c74235 Renamed embed test to have "test" suffix
Fixed reference to association options
2014-10-22 15:30:44 +03:00
Guillermo Iguaran
5f198667be Fix support for custom root in JSON-API adapter 2014-10-22 04:01:12 -03:00
Steve Klabnik
47deb87e81 Merge pull request #685 from ride/ids-as-strings-2
Serialize ids as strings in JSON-API adapter
2014-10-20 11:22:09 -04:00