class Openapi3Parser::Validators::Reference
Attributes
given_reference[R]
Public Class Methods
new(given_reference)
click to toggle source
# File lib/openapi3_parser/validators/reference.rb, line 6 def initialize(given_reference) @given_reference = given_reference end
Public Instance Methods
errors()
click to toggle source
# File lib/openapi3_parser/validators/reference.rb, line 14 def errors @errors ||= Array(build_errors) end
valid?()
click to toggle source
# File lib/openapi3_parser/validators/reference.rb, line 10 def valid? errors.empty? end
Private Instance Methods
build_errors()
click to toggle source
# File lib/openapi3_parser/validators/reference.rb, line 22 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
check_fragment(uri)
click to toggle source
# File lib/openapi3_parser/validators/reference.rb, line 33 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