From 95c818c206822c7d88f9eecb9c3e8667e83957cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 1 Aug 2024 12:54:18 +0100 Subject: [PATCH] encoding/jsonschema: add test case for issue 3351 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test case works with the current evaluator, but currently panics with CUE_EXPERIMENT=evalv3. For #3351. Signed-off-by: Daniel Martí Change-Id: I1fc4050296d4269feb60ffab76341a1d75d87551 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198735 Reviewed-by: Roger Peppe TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine --- encoding/jsonschema/testdata/issue3351.txtar | 93 ++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 encoding/jsonschema/testdata/issue3351.txtar diff --git a/encoding/jsonschema/testdata/issue3351.txtar b/encoding/jsonschema/testdata/issue3351.txtar new file mode 100644 index 00000000000..edff31f9531 --- /dev/null +++ b/encoding/jsonschema/testdata/issue3351.txtar @@ -0,0 +1,93 @@ +-- json-e.json -- +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://www.sourcemeta.com/schemas/vendor/json-e@1.json", + "$comment": "https://json-e.js.org", + "$defs": { + "jsone-value": { + "oneOf": [ + { + "$ref": "#" + }, + { + "type": "array", + "items": { + "$ref": "#" + } + } + ] + }, + "jsone-array": { + "type": "array", + "items": { + "$ref": "#/$defs/jsone-value" + } + }, + "jsone-object-array": { + "type": "array", + "items": { + "$ref": "#" + } + } + }, + "additionalProperties": { + "$ref": "#/$defs/jsone-value" + }, + "properties": { + "$else": { + "$ref": "#/$defs/jsone-value" + }, + "$let": { + "type": "object", + "additionalProperties": { + "additionalProperties": { + "$ref": "#" + } + } + }, + "$sort": { + "anyOf": [ + { + "$ref": "#" + }, + { + "type": "array", + "items": { + "type": "number" + } + } + ] + } + }, + "title": "JSON-e templates", + "type": "object" +} +-- out/decode/cue -- +_schema +_schema: { + // JSON-e templates + @jsonschema(schema="https://json-schema.org/draft/2019-09/schema") + @jsonschema(id="https://www.sourcemeta.com/schemas/vendor/json-e@1.json") + $else?: #["jsone-value"] + $let?: [string]: null | bool | number | string | [...] | { + [string]: _schema_1 + } + $sort?: (_schema_5 | [...number]) & _ + {[!~"^($else|$let|$sort)$"]: #["jsone-value"]} + + #: "jsone-value": _schema_A | [..._schema_8] + + #: "jsone-array": [...#["jsone-value"]] + + #: "jsone-object-array": [..._schema_E] +} + +let _schema_1 = _schema + +let _schema_5 = _schema + +let _schema_A = _schema + +let _schema_8 = _schema + +let _schema_E = _schema