Sha256: 0ab8762d680045f8d571f0345d7f01456f1f87b29dbabb9c5fb45fe6cd416c0d
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
class OpenAPI::Loader::Translator # # Denormalizes 'consumes' setting for requestBody # # @private # class DenormalizeConsumes < SimpleDelegator def call paths.each do |path| path_consumes = path.delete("consumes") || root_consumes operations(path).each do |operation| consumes = operation.delete("consumes") || path_consumes operation["consumes"] = consumes if consumes?(operation) end end end private def root_consumes @root_consumes ||= delete("consumes") end def paths Enumerator.new do |yielder| fetch("paths", {}).each_value do |item| yielder << item if item.is_a? Hash end end end def operations(path) Enumerator.new do |yielder| path.each_value { |item| yielder << item if item.is_a? Hash } end end def consumes?(operation) Array(operation["parameters"]).any? do |item| item.is_a?(Hash) && %w[body formData].include?(item["in"]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
open_api-loader-0.0.1 | lib/open_api/loader/translator/denormalize_consumes.rb |