-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/jsonschema: disallow $schema at non-root for earlier versions
Before 2019-09, the specification says [1]: > The "$schema" keyword SHOULD be used in a root schema. It MUST NOT > appear in subschemas. This change makes us more spec-compliant in that respect. Also change a test case where we were using `$schema` at non-root location. [1]: https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.7 Signed-off-by: Roger Peppe <[email protected]> Change-Id: If74b25848cc3c334eaaefb46adfe4fe89d0cbb45 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202562 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
4 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
encoding/jsonschema/testdata/txtar/schema_not_at_root.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- schema.json -- | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://test.example/foo", | ||
"oneOf": [ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "string" | ||
} | ||
] | ||
} | ||
|
||
-- out/decode/extract -- | ||
ERROR: | ||
$schema can only appear at the root in JSON Schema version http://json-schema.org/draft-07/schema#: | ||
schema.json:6:11 |