apidoc

Minimalist API documentation generator for Rack applications.

Motivation

After searching for similar API documentation solutions and coming up dry, I stumbled upon apiary.io. While I appreciate the motivation for this project, I really wanted an API documentation tool that is:

  1. Example based: Show me what a real request looks like with real data.

  2. Self-testing and replicable: Build API documentation as part of your CI build, and know it’s up-to-date because it ran real requests against your application.

  3. Minimalist: ‘apidoc` is designed to make requests using the content type of your choice and display the request, response and a short description. Nothing more.

Install

$ gem install apidoc

Use

# my_apidoc.rb

require 'path/to/my/app'

doc = ApiDoc.new(MyApp) do
  get '/tacos.json' do
    desc "Get all tacos owned by this user"
  end

  post "/tacos.json" do
    desc "Make a fresh, delicious new taco"
    params do
      { meat: 'fish', sour_cream: true }
    end
  end
end

ApiDoc::HtmlWriter.new(doc).write(STDOUT)

See the examples folder for more examples.

Contributing to apidoc

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2012 T.J. VanSlyke. See LICENSE.txt for further details.