Sha256: a43d96e286b69506dbfddb5f03c36c3e1330e17400fefecc6f1f83a9226f3a8b

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require "constructor_shortcut"
require "dry-initializer"
require "json"
require "yaml"
require "uri"
require "delegate"

#
# Namespace for gems dealing with OAS specifications
#
module OpenAPI
  #
  # Loads OAS specification from a file and converts it to OAS3 format
  #
  # @see OAS2
  #   https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
  # @see OAS3
  #   https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md
  #
  module Loader
    module_function

    require_relative "loader/ref"
    require_relative "loader/reader"
    require_relative "loader/collector"
    require_relative "loader/translator"
    require_relative "loader/denormalizer"

    #
    # Loads the specification from given file
    #
    # @param  [String]  filename The name of file containing a specification
    # @option [Boolean] :denormalize Whether to denormalize specification
    # @return [Hash] the specification
    #
    def call(filename, denormalize: true)
      normalized = [Collector, Translator].inject(filename) do |output, item|
        item.call(output)
      end

      denormalize ? Denormalizer.call(normalized) : normalized
    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.rb