Sha256: 94717747ef1c2fffa022d0327dad08226dd8ef9a34f976c829193459a33c2e26

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

class OpenAPI::Loader::Denormalizer
  #
  # Denormalizes all the 'security' definitions
  # by moving them from the root OpenAPI object
  # right into the corresponding operation objects.
  #
  # @private
  #
  class Security < SimpleDelegator
    def call
      default = delete "security"
      operations.each do |operation|
        operation["security"] ||= default if default
      end
    end

    private

    def paths
      Enumerator.new do |yielder|
        fetch("paths", {}).each_value do |path|
          yielder << path if path.is_a? Hash
        end
      end
    end

    def operations
      Enumerator.new do |yielder|
        paths.each do |path|
          path.each_value { |item| yielder << item if item.is_a? Hash }
        end
      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/denormalizer/security.rb