lib/open_api/dsl.rb in zero-rails_openapi-1.5.2 vs lib/open_api/dsl.rb in zero-rails_openapi-1.5.3
- old
+ new
@@ -23,20 +23,21 @@
tag[:externalDocs] = { description: 'ref', url: external_doc_url } if external_doc_url
end
def components &block
doc_tag if @doc_info.nil?
- current_doc = @doc_info[:components] = Components.new
+ structure = %i[ schemas responses parameters examples requestBodies securitySchemes ].map { |k| [k, { }] }.to_h
+ current_doc = @doc_info[:components] = Components.new.merge!(structure)
current_doc.instance_exec(&block)
current_doc.process_objs
end
def api action, summary = '', 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}$/) }
- pp "[ZRO Warning] Routing mapping failed: #{@route_base}##{action}" and return if routes.blank?
+ return puts ' ZRO'.red + " Route mapping failed: #{@route_base}##{action}" if routes.blank?
api = ApiInfo.new(action_path, skip: Array(skip), use: Array(use))
.merge! description: '', summary: summary, operationId: action, tags: [@doc_tag],
parameters: [ ], requestBody: '', responses: { }, security: [ ], servers: [ ]
[action, :all].each { |blk_key| @zro_dry_blocks&.[](blk_key)&.each { |blk| api.instance_eval(&blk) } }