mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
feature remove trailing produces and consumes
This commit is contained in:
@@ -51,6 +51,9 @@ module Rswag
|
||||
|
||||
def stop(_notification = nil)
|
||||
@config.swagger_docs.each do |url_path, doc|
|
||||
unless doc_version(doc).start_with?('2')
|
||||
remove_invalid_operation_keys!(doc)
|
||||
end
|
||||
## OA3
|
||||
# # remove 2.0 parameters
|
||||
# doc[:paths]&.each_pair do |_k, v|
|
||||
@@ -211,6 +214,16 @@ module Rswag
|
||||
swagger_doc[:components][:securitySchemes][name].merge!(flows: { flow => flow_elements })
|
||||
end
|
||||
end
|
||||
|
||||
def remove_invalid_operation_keys!(swagger_doc)
|
||||
swagger_doc[:paths]&.each_pair do |_k, v|
|
||||
v.each_pair do |_verb, value|
|
||||
is_hash = value.is_a?(Hash)
|
||||
value.delete(:consumes) if is_hash && value.dig(:consumes)
|
||||
value.delete(:produces) if is_hash && value.dig(:produces)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user