lib/apipie/method_description.rb in apipie-rails-0.3.0 vs lib/apipie/method_description.rb in apipie-rails-0.3.1

- old
+ new

@@ -21,12 +21,11 @@ def initialize(method, resource, dsl_data) @method = method.to_s @resource = resource @from_concern = dsl_data[:from_concern] - - @apis = dsl_data[:api_args].map do |mthd, path, desc, opts| + @apis = api_data(dsl_data).map do |mthd, path, desc, opts| MethodDescription::Api.new(mthd, concern_subst(path), concern_subst(desc), opts) end desc = dsl_data[:description] || '' @full_description = Apipie.markup_to_html(desc) @@ -151,9 +150,26 @@ def from_concern? @from_concern end private + + def api_data(dsl_data) + ret = dsl_data[:api_args].dup + if dsl_data[:api_from_routes] + desc = dsl_data[:api_from_routes][:desc] + options = dsl_data[:api_from_routes][:options] + + api_from_routes = Apipie.routes_for_action(resource.controller, method, {:desc => desc, :options => options}).map do |route_info| + [route_info[:verb], + route_info[:path], + route_info[:desc], + (route_info[:options] || {}).merge(:from_routes => true)] + end + ret.concat(api_from_routes) + end + ret + end def merge_params(params, new_params) new_param_names = Set.new(new_params.map(&:name)) params.delete_if { |p| new_param_names.include?(p.name) } params.concat(new_params)