Curlin' for Docs

590 views

Published on

You may have docs for your API, but do you have an API for your docs? With RspecApiDocumentation and Raddocs, you can cURL for your documentation. SmartLogic's Eric Oestrich tells you how. Check out the slides, or read about it here: http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
590
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Curlin' for Docs

  1. 1. cURLin for Docs Eric Oestrich @ericoestrich oestri.ch
  2. 2. Say what?$ curl -H "Accept: text/docs+plain"http://rad-example.herokuapp.com/orders
  3. 3. ExampleGetting a list of orders------------------------Parameters: * page - Current page of orders
  4. 4. RequestRequest: GET /orders?page=1 Accept: application/json Content-Type: application/json Cookie: Host: example.org page=1
  5. 5. ResponseResponse: Status: 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Length: 121 Content-Type: application/json; charset=utf-8 ETag: "6cd5831e98b0090b64672b5604d9eb2a" X-Runtime: 0.019010 X-UA-Compatible: IE=Edge,chrome=1 [{"email":"email0@example.com","name":"Order 0","paid":true},{"email":"email1@example.com","name":"Order 1","paid":true}]
  6. 6. Neat-o, how do I get that?
  7. 7. Install some gemsGemfilegroup :test do gem rspec_api_documentation gem raddocsend
  8. 8. Write RAD testsspec/acceptance/orders_spec.rbresource "Orders" do get "/orders" do it "should ..." do ... end endend
  9. 9. Configure the output formatsspec/spec_helper.rbRspecApiDocumentation.configure do |config| config.formats = [:json, :combined_text]end
  10. 10. Generate docs$ rake docs:generate
  11. 11. Mount Raddocsconfig/routes.rbApplication.routes.draw do resources :orders match "/docs" => Raddocs::App, :anchor => falseend
  12. 12. Use Raddocs::Middlewareconfig/application.rbmodule Example class Application < Rails::Application ... config.middleware.use "Raddocs::Middleware" ... endend
  13. 13. cURL Away$ curl -H "Accept: text/docs+plain" http://localhost/orders
  14. 14. Demo
  15. 15. Gems● rspec_api_documentation ○ http://github.com/zipmark/rspec_api_documentation● raddocs ○ http://github.com/oestrich/raddocs
  16. 16. Questions?

×