Sha256: ad73b92d196b4ee692685e3e772c81100aa92df5986662d6b54badf6489b5dd0

Contents?: true

Size: 565 Bytes

Versions: 2

Compression:

Stored size: 565 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'
          JSON.method(:parse)
        when '.yml', '.yaml'
          YAML.method(:safe_load)
        else
          raise 'Invalid openapi specification file'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fakeit-0.3.1 lib/fakeit/openapi/loader.rb
fakeit-0.3.0 lib/fakeit/openapi/loader.rb