Skip to content

EasySolutionsIO/jsonapi-types

JSONAPI::Types

Gem Depfu Inline docs CircleCI Maintainability Test Coverage

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:

  • 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.

License

Copyright 2018 Inspire Innovation BV. Read LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published