Skip to content

Releases: cerebris/jsonapi-resources

v0.3.1

08 Apr 15:12
Compare
Choose a tag to compare

Fix returning nil for empty related resource
Fix handling of empty data for POST

0.3.0

07 Apr 15:16
Compare
Choose a tag to compare

Fix sort param plus symbol handling [Issue #120] Spaces are now supported
Fixes issues with non "acts as set" associations not returning correct error codes. Now creates routes in order to return a 405 instead of 404.
Fixes issue with associations not using the correct version (namespace) of a resource.

Supports the latest JSON API linkage format.

Updates README section for routing.

JSONAPI RC2b

23 Mar 17:32
Compare
Choose a tag to compare
JSONAPI RC2b Pre-release
Pre-release

More changes for JSONAPI RC2 compliance. Since the JSONAPI RC has changed some of these changes will break code built with the v0.2.0 release.

As JSONAPI 1.0 isn't fully locked down there may be more changes. In addition this project may still be missing some changes to be fully compliant with the current draft. Please raise an issue if you find that's the case.

Changes:

  • Removes support for Ruby 1.9
  • Updates to README
  • Allow {"data":null} to clear has-one relationship
  • Fetching multiple resources by ids has been removed
  • linked key has been renamed included
  • resource key has been renamed related
  • PATCH is now used for updates
  • Adds new records_for method to allow overriding the process of fetching related resource records
  • General code cleanup

Bug fixes:

  • Routes were being generated wrong for associations
  • Fields and includes formats were not being enforced for non underscored keys

JSONAPI RC2

20 Feb 14:57
Compare
Choose a tag to compare

This is a big set of changes that start to bring JSONAPI-Resources into compliance with JSONAPI RC2. There a many breaking changes from the v0.1.1 release, and it may not be prudent to use this release unless you are looking to test out the new JSON API RC2. There are still a few outstanding areas where we are not up to the spec, and future releases will be coming soon.

I'm not going to document the format changes here that needed to take place to meet the new spec, since those are spelled out in the JSONAPI update. Below are the major new features, besides formatting, that have been added:

  • Pagination has been added through the use of Paginators. Two paginators have been provided to support offset and paged pagination. Custom paginators can also be created.
  • Sorting has been changed to use the required direction (+ or -). This led to a minor rework of the sort logic.
  • Serializer options are now provided in the initializer and the serialization methods simply provide the objects to serialize. This allowed for dryer code between the new serialize_to_links_hash and serialize_to_hash methods. The controller is also, I hope, a bit clearer since this has been separated.
  • Serializer now emits generated urls for associations and associated resources, based on a base url. This assumes the creation of routes for each related resource in the primary resource's namespace.
  • CreateHasOneAssociationOperation operation has been removed along with create_has_one_link resource method.
  • Request parsing has been cleaned up. Now makes more use of Strong Parameters (still more work to go though).
  • id and ids special handling in request has been removed.
  • Related resources may now be fetched. This has new routes and controller methods.

v0.1.0

23 Jan 20:06
Compare
Choose a tag to compare

This release adds callbacks to resources based on ActiveSupport::Callbacks. See the README for more details.

This release breaks the existing callback scheme for JSONAPI:: OperationsProcessor. The old callbacks have been replaced with the callback system based on ActiveSupport::Callbacks.

Conversion should be simple. Here's an example. This:

class ApprovingOperationsProcessor < JSONAPI::ActiveRecordOperationsProcessor

  def before_operation(context, operation)
    operation.resource_klass.approve_operation(context, operation)
  end
end

will need to be converted to this:

class ApprovingOperationsProcessor < JSONAPI::ActiveRecordOperationsProcessor
  before_operation :approve_operation

  def approve_operation
    @operation.resource_klass.approve_operation(@context, @operation)
  end
end

A key difference is that the parameters are no longer passed in to the callback. Instead they are accessible as instance variables on the OperationsProcessor. You also have access to @result, @results, and @operations instance variables.

In addition there are callbacks for the set of operations as well as the individual operations. And all callbacks support before, after and around.