From 4e9640c8241ac2a01f95a3714b07c00668552e0f Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Sun, 12 Nov 2023 15:11:38 -0800 Subject: [PATCH] test when $dynamicRef references a boolean schema --- tests/draft-next/dynamicRef.json | 30 ++++++++++++++++++++++++++++++ tests/draft2020-12/dynamicRef.json | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/tests/draft-next/dynamicRef.json b/tests/draft-next/dynamicRef.json index 428c83b3..94124fff 100644 --- a/tests/draft-next/dynamicRef.json +++ b/tests/draft-next/dynamicRef.json @@ -612,5 +612,35 @@ "valid": false } ] + }, + { + "description": "$dynamicRef points to a boolean schema", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$defs": { + "true": true, + "false": false + }, + "properties": { + "true": { + "$dynamicRef": "#/$defs/true" + }, + "false": { + "$dynamicRef": "#/$defs/false" + } + } + }, + "tests": [ + { + "description": "follow $dynamicRef to a true schema", + "data": { "true": 1 }, + "valid": true + }, + { + "description": "follow $dynamicRef to a false schema", + "data": { "false": 1 }, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/dynamicRef.json b/tests/draft2020-12/dynamicRef.json index c1c56cb8..bff26ad6 100644 --- a/tests/draft2020-12/dynamicRef.json +++ b/tests/draft2020-12/dynamicRef.json @@ -726,5 +726,35 @@ "valid": false } ] + }, + { + "description": "$dynamicRef points to a boolean schema", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "true": true, + "false": false + }, + "properties": { + "true": { + "$dynamicRef": "#/$defs/true" + }, + "false": { + "$dynamicRef": "#/$defs/false" + } + } + }, + "tests": [ + { + "description": "follow $dynamicRef to a true schema", + "data": { "true": 1 }, + "valid": true + }, + { + "description": "follow $dynamicRef to a false schema", + "data": { "false": 1 }, + "valid": false + } + ] } ]