lib/open_api/dsl.rb in zero-rails_openapi-1.6.1 vs lib/open_api/dsl.rb in zero-rails_openapi-1.7.0
- old
+ new
@@ -32,19 +32,19 @@
current_doc.process_objs
(@doc_info[:components] ||= { }).deep_merge!(current_doc)
end
- def api action, summary = '', id: nil, http: http_method = nil, skip: [ ], use: [ ], &block
+ def api action, summary = '', id: nil, tag: nil, http: http_method = nil, skip: [ ], use: [ ], &block
doc_tag if @doc_info.nil?
# select the routing info (corresponding to the current method) from routing list.
action_path = "#{@route_base ||= controller_path}##{action}"
- routes = ctrl_routes_list&.select { |api| api[:action_path].match?(/^#{action_path}$/) }
+ routes = ctrl_routes_list&.select { |api| api[:action_path][/^#{action_path}$/].present? }
return puts ' ZRO'.red + " Route mapping failed: #{action_path}" if routes.blank?
api = Api.new(action_path, skip: Array(skip), use: Array(use))
- .merge! description: '', summary: summary, operationId: id || "#{@doc_info[:tag][:name]}#{action.capitalize}",
- tags: [@doc_tag], parameters: [ ], requestBody: '', responses: { }, callbacks: { },
+ .merge! description: '', summary: summary, operationId: id || "#{@doc_info[:tag][:name]}_#{action.to_s.camelize}",
+ tags: [tag || @doc_tag], parameters: [ ], requestBody: '', responses: { }, callbacks: { },
links: { }, security: [ ], servers: [ ]
[action, :all].each { |blk_key| @zro_dry_blocks&.[](blk_key)&.each { |blk| api.instance_eval(&blk) } }
api.param_use = api.param_skip = [ ] # `skip` and `use` only affect `api_dry`'s blocks
api.instance_exec(&block) if block_given?
api.process_objs