api-extensions
A collection of extensions for Hypermedia-driven APIs following the standard definitions at the api-doc repo.
Included extensions:
fields
Installation
Add this line to your application's Gemfile:
gem 'api-extensions'
And then execute:
$ bundle
Or install it yourself as:
$ gem install api-extensions
Usage
expand
extension
The behavior of this extension is best described at the api-doc repo.
By including the Api::Extensions::Expand
module in any class, you will get a process_expand
method that will handle the expansion of linked resources - as described in the linked document.
Please note that this extension requires that the including class responds to a get
method.
require 'api/extensions/expand'
class MyApiHandler
def initialize
include Api::Extensions::Expand
end
def handle(request)
response = fiddle_with request
request[:expand], response
end
end
fields
extension
The behavior of this extension is best described at the api-doc repo.
By including the Api::Extensions::Fields
module in any class, you will get a process_fields
method that will handle the creation of partial responses - as described in the linked document.
require 'api/extensions/fields'
class MyApiHandler
include Api::Extensions::Fields
def handle(request)
response = fiddle_with request
process_fields request[:fields], response, request.path
end
end
Running tests
The test suite uses Cucumber, and can be run through rake
:
$ rake features
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request