Sha256: 500fb75f516e2396f0a7c56b661cf9a36dd35ce4e4b8bc877dd70a991a86762a
Contents?: true
Size: 863 Bytes
Versions: 3
Compression:
Stored size: 863 Bytes
Contents
# frozen_string_literal: true module Openapi3Parser module Validators class Reference def initialize(given_reference) @given_reference = given_reference end def valid? errors.empty? end def errors @errors ||= Array(build_errors) end private attr_reader :given_reference def build_errors return "Expected a string" unless given_reference.is_a?(String) begin uri = URI.parse(given_reference) rescue URI::Error return "Could not parse as a URI" end check_fragment(uri) || [] end def check_fragment(uri) return if uri.fragment.nil? || uri.fragment.empty? first_char = uri.fragment[0] "Invalid JSON pointer, expected a root slash" if first_char != "/" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems