Sha256: 0711798179f1d630e920c06f05795fcc272ac602cc3cb9ebb288570a9bb3acb6

Contents?: true

Size: 549 Bytes

Versions: 1

Compression:

Stored size: 549 Bytes

Contents

module Fakeit
  module Openapi
    class << self
      def load(src)
        URI
          .open(src, &:read)
          .then { parse(src, _1) }
          .then { OpenAPIParser.parse(_1, { strict_reference_validation: true }) }
      end

      private

      def parse(src, content)
        case File.extname(src)
        when '.json'
          JSON.parse(content)
        when '.yml', '.yaml'
          YAML.safe_load(content, [Date, Time])
        else
          raise 'Invalid openapi specification file'
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fakeit-0.11.0 lib/fakeit/openapi/loader.rb