From: David Lutterkort <[email protected]>
---
server/libexec/lib/sinatra/rabbit.rb | 21 +++++++++++++++++++--
server/libexec/views/docs/collection.html.haml | 17 +++++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/server/libexec/lib/sinatra/rabbit.rb
b/server/libexec/lib/sinatra/rabbit.rb
index afaa865..7091937 100644
--- a/server/libexec/lib/sinatra/rabbit.rb
+++ b/server/libexec/lib/sinatra/rabbit.rb
@@ -130,9 +130,9 @@ module Sinatra
end
def generate_documentation
- coll, oper = self, @operations
+ coll, oper, features = self, @operations, driver.features(name)
::Sinatra::Application.get("/api/docs/#...@name}") do
- @collection, @operations = coll, oper
+ @collection, @operations, @features = coll, oper, features
respond_to do |format|
format.html { haml :'docs/collection' }
format.xml { haml :'docs/collection' }
@@ -174,6 +174,22 @@ module Sinatra
end
end
end
+
+ def add_feature_params(features)
+ features.each do |f|
+ f.operations.each do |fop|
+ if cop = operations[fop.name]
+ fop.params.each_key do |k|
+ if cop.params.has_key?(k)
+ raise DuplicateParamException, "Parameter '#{k}' for
operation #{fop.name} defined by collection #...@name} and by feature #{f.name}"
+ else
+ cop.params[k] = fop.params[k]
+ end
+ end
+ end
+ end
+ end
+ end
end
def collections
@@ -188,6 +204,7 @@ module Sinatra
def collection(name, &block)
raise DuplicateCollectionException if collections[name]
collections[name] = Collection.new(name, &block)
+ collections[name].add_feature_params(driver.features(name))
collections[name].generate
end
diff --git a/server/libexec/views/docs/collection.html.haml
b/server/libexec/views/docs/collection.html.haml
index 7bd5bd6..97b735f 100644
--- a/server/libexec/views/docs/collection.html.haml
+++ b/server/libexec/views/docs/collection.html.haml
@@ -18,3 +18,20 @@
%td{:style => "width:15em"}
%a{:href => "/api/docs/#[email protected]_s}/#{operation}"}
#{operation}
%td{:style => "width:10em"} #...@operations[operation].description}
+
+%h3 Features:
+
+%table
+ %thead
+ %tr
+ %th Name
+ %th Description
+ %th Modified Operations
+ %tbody
+ - @features.sort_by { |f| f.name.to_s }.each do |feature|
+ %tr
+ %td= feature.name
+ %td= feature.description
+ %td
+ - feature.operations.each do |op|
+ %a{:href => "/api/docs/#[email protected]_s}/#{op.name}"}
#{op.name}
--
1.6.6.1
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel