Sha256: 81600c1816ff278532787391fff2f5f18140c580acb38e7aaf4e3d91d4415ff9

Contents?: true

Size: 566 Bytes

Versions: 6

Compression:

Stored size: 566 Bytes

Contents

module Fakeit
  module Openapi
    class << self
      def load(src)
        parse_method = parse_method(src)

        open(src, &:read)
          .then(&parse_method)
          .then(&OpenAPIParser.method(:parse))
          .then(&Specification.method(:new))
      end

      private

      def parse_method(src)
        case File.extname(src)
        when '.json' then
          JSON.method(:parse)
        when '.yml' then
          YAML.method(:safe_load)
        else
          raise 'Invalid openapi specification file'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fakeit-0.2.0 lib/fakeit/openapi/loader.rb
fakeit-0.1.5 lib/fakeit/openapi/loader.rb
fakeit-0.1.4 lib/fakeit/openapi/loader.rb
fakeit-0.1.3 lib/fakeit/openapi/loader.rb
fakeit-0.1.2 lib/fakeit/openapi/loader.rb
fakeit-0.1.1 lib/fakeit/openapi/loader.rb