ApiSampler

Build Status Yard Docs Inline docs

Collect samples (request/response pairs) for API endpoints of your Rails app.

Demo (demo source).

Installation

Add this line to your application's Gemfile:

gem 'api_sampler'

And then execute:

$ bundle install

Finally, you need to run the generator:

$ rails generate api_sampler:install

This will create an initializer at config/initializers/api_sampler.rb, mount api_sampler at /api_sampler and copy and run the engine's migrations.

Run the following command to see the list of available options:

$ rails generate api_sampler:install --help

Configuration

Configuration should be placed in an initializer (api_sampler:install creates a sample initializer at config/initializers/api_sampler.rb).

TODO. See ApiSampler::Configuration for examples of confiration options usage.

Contributing

Contribution directions go here.

Testing

api_sampler is bundled with a dummy Rails app, which uses the :postgresql database adapter.

Setup

First, you need to create a database role corresponding to your user (if it doesn't exist yet):

$ sudo -u postgres createuser $USER --login --createdb --superuser

Note: superuser permissions are required to enable the "hstore" database extension.

Alternatively, you may specify the database role and password using environment variables API_SAMPLER_DB_USERNAME and API_SAMPLER_DB_PASSWORD.

Finally, setup the testing database and schema:

$ bundle exec rake db:setup RAILS_ENV=test

Running tests

Execute the following commands to run tests:

$ bundle exec rake spec         # RSpec tests
$ bundle exec rake yard:doctest # YARD documentation tests

License

The gem is available as open source under the terms of the MIT License.