Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "JSONSchema",
platforms: [
.macOS(.v10_13),
.macOS(.v10_13), .iOS(.v11), .tvOS(.v11)
],
products: [
.library(name: "JSONSchema", targets: ["JSONSchema"]),
Expand Down
6 changes: 6 additions & 0 deletions Sources/RefResolver.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import Foundation

func urlSplitFragment(url: String) -> (String, String) {
#if swift(>=5.0)
guard let hashIndex = url.firstIndex(of: "#") else {
return (url, "")
}
#else
guard let hashIndex = url.index(of: "#") else {
return (url, "")
}
#endif

return (
String(url.prefix(upTo: hashIndex)),
Expand Down
2 changes: 2 additions & 0 deletions Sources/Validation/required.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ func required(context: Context, required: Any, instance: Any, schema: [String: A

return AnySequence(required.compactMap { key -> ValidationError? in
guard !instance.keys.contains(key) else { return nil }
context.instanceLocation.push(key)
defer { context.instanceLocation.pop() }
return ValidationError(
"Required property '\(key)' is missing",
instanceLocation: context.instanceLocation,
Expand Down
2 changes: 1 addition & 1 deletion Tests/JSONSchemaTests/Validation/TestRequired.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public let testRequired: ((ContextType) -> Void) = {
let error = errors[0]

try expect(error.description) == "Required property 'test' is missing"
try expect(error.instanceLocation.path) == "/0"
try expect(error.instanceLocation.path) == "/0/test"
try expect(error.keywordLocation.path) == "#/items/required"
}
}
Expand Down