X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9364cbd0174e9fd8f4394721ff575c59f8d42ff1..4d9a9766999dda4657bce039a1d56a5591201e95:/services/api/app/controllers/arvados/v1/schema_controller.rb diff --git a/services/api/app/controllers/arvados/v1/schema_controller.rb b/services/api/app/controllers/arvados/v1/schema_controller.rb index 0a0e664b09..f118457157 100644 --- a/services/api/app/controllers/arvados/v1/schema_controller.rb +++ b/services/api/app/controllers/arvados/v1/schema_controller.rb @@ -23,6 +23,12 @@ class Arvados::V1::SchemaController < ApplicationController protected + ActionNameMap = { + 'destroy' => 'delete', + 'index' => 'list', + 'show' => 'get', + } + def discovery_doc Rails.application.eager_load! remoteHosts = {} @@ -216,14 +222,14 @@ class Arvados::V1::SchemaController < ApplicationController "https://api.arvados.org/auth/arvados.readonly" ] }, - index: { - id: "arvados.#{k.to_s.underscore.pluralize}.index", + list: { + id: "arvados.#{k.to_s.underscore.pluralize}.list", path: k.to_s.underscore.pluralize, httpMethod: "GET", description: - %|Index #{k.to_s.pluralize}. + %|List #{k.to_s.pluralize}. - The index method returns a + The list method returns a resource list of matching #{k.to_s.pluralize}. For example: @@ -331,18 +337,20 @@ class Arvados::V1::SchemaController < ApplicationController httpMethod = ['GET', 'POST', 'PUT', 'DELETE'].map { |method| method if route.verb.match(method) }.compact.first - if httpMethod and - route.defaults[:controller] == 'arvados/v1/' + k.to_s.underscore.pluralize and - ctl_class.action_methods.include? action - if !d_methods[action.to_sym] + if httpMethod && + route.defaults[:controller] == 'arvados/v1/' + k.to_s.underscore.pluralize && + ctl_class.action_methods.include?(action) + method_name = ActionNameMap[action] || action + method_key = method_name.to_sym + if !d_methods[method_key] method = { - id: "arvados.#{k.to_s.underscore.pluralize}.#{action}", + id: "arvados.#{k.to_s.underscore.pluralize}.#{method_name}", path: route.path.spec.to_s.sub('/arvados/v1/','').sub('(.:format)','').sub(/:(uu)?id/,'{uuid}'), httpMethod: httpMethod, - description: "#{action} #{k.to_s.underscore.pluralize}", + description: "#{method_name} #{k.to_s.underscore.pluralize}", parameters: {}, response: { - "$ref" => (action == 'index' ? "#{k.to_s}List" : k.to_s) + "$ref" => (method_name == 'list' ? "#{k.to_s}List" : k.to_s) }, scopes: [ "https://api.arvados.org/auth/arvados" @@ -363,7 +371,7 @@ class Arvados::V1::SchemaController < ApplicationController # We already built a generic method description, but we # might find some more required parameters through # introspection. - method = d_methods[action.to_sym] + method = d_methods[method_key] end if ctl_class.respond_to? "_#{action}_requires_parameters".to_sym ctl_class.send("_#{action}_requires_parameters".to_sym).each do |l, v| @@ -384,15 +392,7 @@ class Arvados::V1::SchemaController < ApplicationController end end end - d_methods[action.to_sym] = method - - if action == 'index' - list_method = method.dup - list_method[:id].sub!('index', 'list') - list_method[:description].sub!('Index', 'List') - list_method[:description].sub!('index', 'list') - d_methods[:list] = list_method - end + d_methods[method_key] = method end end end