Commit 1bf49c9034b999def3fc82288d0fa96a72cdb8de
Committed by
Rodrigo Souto
1 parent
cc60c41d
Exists in
master
and in
29 other branches
Basic API autodoc
Lists EndPoints at /api
Showing
4 changed files
with
29 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
| 1 | +<h1>EndPoints</h1> | ||
| 2 | + | ||
| 3 | +<%= @api.endpoints.map do |endpoint| | ||
| 4 | + app = endpoint.options[:app].to_s | ||
| 5 | + unless app.blank? | ||
| 6 | + content_tag(:h2, app.split('::').last.to_s, title: app) + | ||
| 7 | + (content_tag :ul do | ||
| 8 | + endpoint.routes.map do |route| | ||
| 9 | + content_tag :li do | ||
| 10 | + content_tag(:strong, route.route_method) + ' ' + | ||
| 11 | + route.route_path.gsub(':version', content_tag(:b, route.route_version)) | ||
| 12 | + end | ||
| 13 | + end.join "\n" | ||
| 14 | + end) | ||
| 15 | + end | ||
| 16 | +end.join "\n" %> |
config/routes.rb
| @@ -22,6 +22,7 @@ Noosfero::Application.routes.draw do | @@ -22,6 +22,7 @@ Noosfero::Application.routes.draw do | ||
| 22 | root :to => 'home#index', :constraints => EnvironmentDomainConstraint.new | 22 | root :to => 'home#index', :constraints => EnvironmentDomainConstraint.new |
| 23 | 23 | ||
| 24 | match 'site(/:action)', :controller => 'home' | 24 | match 'site(/:action)', :controller => 'home' |
| 25 | + match 'api(/:action)', :controller => 'api' | ||
| 25 | 26 | ||
| 26 | match 'images(/*stuff)' => 'not_found#nothing' | 27 | match 'images(/*stuff)' => 'not_found#nothing' |
| 27 | match 'stylesheets(/*stuff)' => 'not_found#nothing' | 28 | match 'stylesheets(/*stuff)' => 'not_found#nothing' |