jsonapi-serializers 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -12
- data/lib/jsonapi-serializers/serializer.rb +1 -1
- data/lib/jsonapi-serializers/version.rb +1 -1
- data/spec/serializer_spec.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32d0b6019eb7a0da9ded6bd4fa6a62ba74ddb8a2
|
4
|
+
data.tar.gz: c027a23983f08270443743e40dcc52c1d457da22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e0177a3eba071683095c37d2a498c4834b4061535e630c95d38c6ca03cf83a3c698198b82db6453c46c398fad00f2f818d03de3ace4183839d726800fd64d30
|
7
|
+
data.tar.gz: 194a65e5ab124effa18d84de1f0924340bd71519692064074b7af4a7128af2102be9717dfef7e254087efe9034d7d4c22cfd36bba8307d92a9ed1c105ac1662f
|
data/README.md
CHANGED
@@ -29,9 +29,9 @@ This library is up-to-date with the finalized v1 JSON API spec.
|
|
29
29
|
* Supports the readonly features of the JSON:API spec.
|
30
30
|
* **Full support for compound documents** ("side-loading") and the `include` parameter.
|
31
31
|
* Similar interface to ActiveModel::Serializers, should provide an easy migration path.
|
32
|
-
* Intentionally unopinionated and simple, allows you to structure your app however you would like and then serialize the objects at the end.
|
32
|
+
* Intentionally unopinionated and simple, allows you to structure your app however you would like and then serialize the objects at the end. Easy to integrate with your existing authorization systems and service objects.
|
33
33
|
|
34
|
-
JSONAPI::Serializers was built as an intentionally simple serialization interface. It makes no assumptions about your database structure or routes and it does not provide controllers or any create/update interface to the objects. It is a library, not a framework. You will probably still need to do work to make your API fully compliant with the nuances of the [JSON:API spec](http://jsonapi.org/format/), for things like supporting `/
|
34
|
+
JSONAPI::Serializers was built as an intentionally simple serialization interface. It makes no assumptions about your database structure or routes and it does not provide controllers or any create/update interface to the objects. It is a library, not a framework. You will probably still need to do work to make your API fully compliant with the nuances of the [JSON:API spec](http://jsonapi.org/format/), for things like supporting `/relationships` routes and for supporting write actions like creating or updating objects. If you are looking for a more complete and opinionated framework, see the [jsonapi-resources](https://github.com/cerebris/jsonapi-resources) project.
|
35
35
|
|
36
36
|
## Installation
|
37
37
|
|
@@ -76,8 +76,7 @@ Returns a hash:
|
|
76
76
|
},
|
77
77
|
"links": {
|
78
78
|
"self": "/posts/1"
|
79
|
-
}
|
80
|
-
"relationships": {}
|
79
|
+
}
|
81
80
|
}
|
82
81
|
}
|
83
82
|
```
|
@@ -102,8 +101,7 @@ Returns:
|
|
102
101
|
},
|
103
102
|
"links": {
|
104
103
|
"self": "/posts/1"
|
105
|
-
}
|
106
|
-
"relationships": {}
|
104
|
+
}
|
107
105
|
},
|
108
106
|
{
|
109
107
|
"id": "2",
|
@@ -114,8 +112,7 @@ Returns:
|
|
114
112
|
},
|
115
113
|
"links": {
|
116
114
|
"self": "/posts/2"
|
117
|
-
}
|
118
|
-
"relationships": {}
|
115
|
+
}
|
119
116
|
}
|
120
117
|
]
|
121
118
|
}
|
@@ -311,8 +308,7 @@ Returns:
|
|
311
308
|
},
|
312
309
|
"links": {
|
313
310
|
"self": "/users/1"
|
314
|
-
}
|
315
|
-
"relationships": {}
|
311
|
+
}
|
316
312
|
},
|
317
313
|
{
|
318
314
|
"id": "1",
|
@@ -350,8 +346,7 @@ Returns:
|
|
350
346
|
},
|
351
347
|
"links": {
|
352
348
|
"self": "/users/2"
|
353
|
-
}
|
354
|
-
"relationships": {}
|
349
|
+
}
|
355
350
|
}
|
356
351
|
]
|
357
352
|
}
|
@@ -434,6 +429,7 @@ end
|
|
434
429
|
|
435
430
|
## Release notes
|
436
431
|
|
432
|
+
* v0.2.2: Compliance fix for excluding empty relationship objects.
|
437
433
|
* v0.2.1: Compliance fix for self links.
|
438
434
|
* v0.2.0: Initial release with support for the final v1 JSON API spec.
|
439
435
|
|
@@ -302,7 +302,7 @@ module JSONAPI
|
|
302
302
|
# http://jsonapi.org/format/#document-structure-resource-objects
|
303
303
|
data.merge!({'attributes' => serializer.attributes}) if !serializer.attributes.nil?
|
304
304
|
data.merge!({'links' => serializer.links}) if !serializer.links.nil?
|
305
|
-
data.merge!({'relationships' => serializer.relationships})
|
305
|
+
data.merge!({'relationships' => serializer.relationships}) unless serializer.relationships.empty?
|
306
306
|
data.merge!({'meta' => serializer.meta}) if !serializer.meta.nil?
|
307
307
|
data
|
308
308
|
end
|
data/spec/serializer_spec.rb
CHANGED
@@ -25,7 +25,6 @@ describe JSONAPI::Serializer do
|
|
25
25
|
'links' => {
|
26
26
|
'self' => '/posts/1',
|
27
27
|
},
|
28
|
-
'relationships' => {},
|
29
28
|
})
|
30
29
|
end
|
31
30
|
it 'can serialize primary data for a simple object with a long name' do
|
@@ -69,7 +68,6 @@ describe JSONAPI::Serializer do
|
|
69
68
|
'links' => {
|
70
69
|
'self' => '/posts/1',
|
71
70
|
},
|
72
|
-
'relationships' => {},
|
73
71
|
'meta' => {
|
74
72
|
'copyright' => 'Copyright 2015 Example Corp.',
|
75
73
|
'authors' => [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi-serializers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Fotinakis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|