JSONAPI::Types

Implementation of the JSON:API Spec definitions using inmutable types.

Links:

Requirements

  1. Ruby 2.5.0

Installation

To install, run:

gem install jsonapi-types

Or add the following to your Gemfile:

gem "jsonapi-types"

Usage

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>]>

Tests

To test, run:

bundle exec rspec spec/

Versioning

Read Semantic Versioning for details. Briefly, it means:

License

Copyright 2018 Inspire Innovation BV. Read LICENSE for details.