Skip to content

Commit 519db4c

Browse files
committed
feat: use 2020-12 as default schema
BREAKING CHANGE: JSON Schema 2020-12 is used by default
1 parent ed6041e commit 519db4c

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
### Breaking Changes
66

7+
- By default, the _latest_ version of JSON Schema will be used when a meta
8+
schema is not provided in the `$schema` property. The default schema will be
9+
2020-12 for this release.
10+
711
- When a schema references an unknown meta schema via `$schema`, a reference
812
error will now be thrown instead of the schema being silently treated as a
913
draft 4 schema.

Sources/JSONSchema.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public struct Schema {
6666
func validator(for schema: [String: Any]) throws -> Validator {
6767
guard schema.keys.contains("$schema") else {
6868
// Default schema
69-
return Draft4Validator(schema: schema)
69+
return Draft202012Validator(schema: schema)
7070
}
7171

7272
guard let schemaURI = schema["$schema"] as? String else {

Tests/JSONSchemaTests/JSONSchemaCases.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func draft4Validator(schema: Any, instance: Any) throws -> ValidationResult {
1717
}
1818

1919
if let schema = schema as? [String: Any] {
20-
return try validate(instance, schema: schema)
20+
return try Draft4Validator(schema: schema).validate(instance: instance)
2121
}
2222

2323
fatalError()

Tests/JSONSchemaTests/JSONSchemaTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class ValidateTests: XCTestCase {
110110

111111
func testDefaultValidator() throws {
112112
let result = try validator(for: [:])
113-
XCTAssertTrue(result is Draft4Validator, "Unexpected type of validator \(result)")
113+
XCTAssertTrue(result is Draft202012Validator, "Unexpected type of validator \(result)")
114114
}
115115

116116
func testDraft4ValidatorIsAvailable() throws {

0 commit comments

Comments
 (0)