README.md in jsonapi-serializers-0.14.0 vs README.md in jsonapi-serializers-0.15.0
- old
+ new
@@ -16,10 +16,11 @@
* [Null handling](#null-handling)
* [Multiple attributes](#multiple-attributes)
* [Custom attributes](#custom-attributes)
* [More customizations](#more-customizations)
* [Base URL](#base-url)
+ * [Root jsonapi object](#root-jsonapi-object)
* [Root metadata](#root-metadata)
* [Root links](#root-links)
* [Root errors](#root-errors)
* [Explicit serializer discovery](#explicit-serializer-discovery)
* [Namespace serializers](#namespace-serializers)
@@ -228,10 +229,16 @@
def base_url
@base_url
end
```
```ruby
+# Override this to provide a resource-object jsonapi object containing the version in use.
+# http://jsonapi.org/format/#document-jsonapi-object
+def jsonapi
+end
+```
+```ruby
def self_link
"#{base_url}/#{type}/#{id}"
end
```
```ruby
@@ -308,9 +315,17 @@
```ruby
JSONAPI::Serializer.serialize(post, base_url: 'http://example.com')
```
Note: if you override `self_link` in your serializer and leave out `base_url`, it will not be included.
+
+### Root 'jsonapi' object
+
+You can pass a `jsonapi` argument to specify a [top-level "jsonapi" key](http://jsonapi.org/format/#document-jsonapi-object) containing the version of JSON:API in use:
+
+```ruby
+JSONAPI::Serializer.serialize(post, jsonapi: {version: '1.0'})
+```
### Root metadata
You can pass a `meta` argument to specify top-level metadata: