lib/openapi3_parser/validators/reference.rb in openapi3_parser-0.7.0 vs lib/openapi3_parser/validators/reference.rb in openapi3_parser-0.8.0
- old
+ new
@@ -19,19 +19,21 @@
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