-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/jsonschema: decode required properties as required fields
Decode a jsonschema required property as a CUE required field instead of a regular field. Fixes #3318 Change-Id: Idc856b888e682cd0ea9124277371681d0a83898c Signed-off-by: haoqixu <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198831 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
7 changed files
with
57 additions
and
25 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
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
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,30 @@ | ||
-- schema.json -- | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"additionalProperties": false, | ||
"id": "https://example.test/example", | ||
"required": ["x", "z"], | ||
"title": "example jsonschema", | ||
"type": "object", | ||
"properties": { | ||
"x": { | ||
"description": "A required field", | ||
"type": "number" | ||
}, | ||
"y": { | ||
"description": "An optional field", | ||
"type": "number" | ||
} | ||
} | ||
} | ||
|
||
-- out/decode/cue -- | ||
// example jsonschema | ||
@jsonschema(schema="http://json-schema.org/draft-04/schema#") | ||
|
||
// A required field | ||
x!: number | ||
|
||
// An optional field | ||
y?: number | ||
z!: _ |