Sha256: 58fe3bd946fc072d9f2355bdea20ac3d142657ed99733cce8aace5c62e4098eb

Contents?: true

Size: 535 Bytes

Versions: 3

Compression:

Stored size: 535 Bytes

Contents

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

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

      private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fakeit-0.9.1 lib/fakeit/openapi/loader.rb
fakeit-0.9.0 lib/fakeit/openapi/loader.rb
fakeit-0.8.1 lib/fakeit/openapi/loader.rb