API utilities for OpenStax products and tools.
Add this line to your application's Gemfile:
And then execute:
This gem includes the following classes, all under the OpenStax::Api namespace:
Your API controllers should inherit from ApiController.
current_user method will not be available in ApiController.
Instead, use the current_api_user, current_human_user and current_application methods.
Your users should NOT inherit from ApiUser. It is used only by ApiController.
ApiUser represents either a signed in user, a doorkeeper application, or a combination of both.
This gem also adds the following methods to Doorkeeper::Application:
Finally, this gem allows API routes to be simplified by using the api method, like so:
apipie api :v1 do get '/your_api_v1_routes_go_here' end api :v2, default: true do get '/your_api_v2_routes_go_here' end
The api route method takes a version argument and an options hash.
:default option is set to true, that version is the default (latest) and will always match the Accept header. It should be defined last, as any API route after that will be ignored.
From the gem's main folder, run
rake db:migrate and then
rake to run all the specs.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Create specs for your feature
- Ensure that all specs pass
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new pull request