Implementation of the JSON:API Spec definitions using inmutable types.
Links:
To install, run:
gem install jsonapi-types
Or add the following to your Gemfile:
gem "jsonapi-types"
require "jsonapi-types"
payload = { data: { id: "1", type: "users" } } # or a JSON string
document = JSONAPI::Types::Success.parse(payload)
=> #<JSONAPI::Types::Success links=nil jsonapi=nil data=#<JSONAPI::Types::Resource id="1" type="users" resource_attributes={} relationships=nil links=nil> meta=nil included=nil>
payload = { errors: [{ id: "100", titee: "Invalid name." }] } # or a JSON string
document = JSONAPI::Types::Failure.parse(payload)
=> #<JSONAPI::Types::Failure links=nil jsonapi=nil meta=nil errors=[#<JSONAPI::Types::Error id="100" code=nil title=nil detail=nil status=nil meta=nil links=nil source=nil>]>To test, run:
bundle exec rspec spec/
Read Semantic Versioning for details. Briefly, it means:
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
Copyright 2018 Inspire Innovation BV. Read LICENSE for details.