Collect samples (request/response pairs) for API endpoints of your Rails app.
Demo (demo source).
Add this line to your application's Gemfile:
gem 'api_sampler'And then execute:
$ bundle installFinally, you need to run the generator:
$ rails generate api_sampler:installThis 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 --helpConfiguration 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.
Contribution directions go here.
api_sampler is bundled with a dummy Rails app, which uses the :postgresql database adapter.
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 --superuserNote: 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=testExecute the following commands to run tests:
$ bundle exec rake spec # RSpec tests
$ bundle exec rake yard:doctest # YARD documentation testsThe gem is available as open source under the terms of the MIT License.