Sha256: 5c10a8cd2f9c37e39a2afc9ab47f447f4b7e49d730f07a2f6419944de524fc17

Contents?: true

Size: 520 Bytes

Versions: 14

Compression:

Stored size: 520 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))
      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

14 entries across 14 versions & 1 rubygems

Version Path
fakeit-0.8.0 lib/fakeit/openapi/loader.rb
fakeit-0.7.1 lib/fakeit/openapi/loader.rb
fakeit-0.7.0 lib/fakeit/openapi/loader.rb
fakeit-0.6.3 lib/fakeit/openapi/loader.rb
fakeit-0.6.2 lib/fakeit/openapi/loader.rb
fakeit-0.6.1 lib/fakeit/openapi/loader.rb
fakeit-0.6.0 lib/fakeit/openapi/loader.rb
fakeit-0.5.3 lib/fakeit/openapi/loader.rb
fakeit-0.5.2 lib/fakeit/openapi/loader.rb
fakeit-0.5.1 lib/fakeit/openapi/loader.rb
fakeit-0.5.0 lib/fakeit/openapi/loader.rb
fakeit-0.4.2 lib/fakeit/openapi/loader.rb
fakeit-0.4.1 lib/fakeit/openapi/loader.rb
fakeit-0.4.0 lib/fakeit/openapi/loader.rb