Sha256: 4c62027c41cee9fd1504acc91fbc48c4f148c7b706161ae40c7b13c3282223ed
Contents?: true
Size: 865 Bytes
Versions: 7
Compression:
Stored size: 865 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
7 entries across 7 versions & 2 rubygems