-
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: fix decoding of
$id
When decoding "$id", jsonschema decoder mistakenly assumed that the schema is an object and added an object constraint with the id tag. This change postpones the attachment of id tag until an object constraint is added or the schema is finalizing. Fixes #3361 Change-Id: I7829af165af726524d48022fc87ed538b7e451cd Signed-off-by: haoqixu <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199139 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Roger Peppe <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
4 changed files
with
65 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- schema.json -- | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://test.example/foo", | ||
"oneOf": [ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://1.test.example/string", | ||
"type": "string" | ||
}, | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://2.test.example/object", | ||
"type": "object" | ||
} | ||
] | ||
} | ||
|
||
-- out/decode/cue -- | ||
@jsonschema(schema="http://json-schema.org/draft-07/schema#") | ||
@jsonschema(id="https://test.example/foo") | ||
{ | ||
@jsonschema(id="https://1.test.example/string") | ||
string | ||
} | { | ||
@jsonschema(id="https://2.test.example/object") | ||
... | ||
} |
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,12 @@ | ||
-- schema.json -- | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://cuelang.org/go/encoding/openapi/testdata/id_scalar.json", | ||
|
||
"type": "string" | ||
} | ||
|
||
-- out/decode/cue -- | ||
@jsonschema(schema="http://json-schema.org/draft-07/schema#") | ||
@jsonschema(id="http://cuelang.org/go/encoding/openapi/testdata/id_scalar.json") | ||
string |