From 93e674ff818aaf62361ec3348afeb212a111592d Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Wed, 4 Mar 2026 07:25:01 -0800 Subject: [PATCH] changed conditionals so that the watched property is required --- .../extensions/curator/schema_generation.py | 10 ++++++++-- ...ted.BulkRNA-seqAssay.display_names_schema.json | 15 ++++++++++++--- .../expected.BulkRNA-seqAssay.schema.json | 15 ++++++++++++--- .../expected.Patient.display_names_schema.json | 5 ++++- .../expected.Patient.schema.json | 5 ++++- .../extensions/unit_test_create_json_schema.py | 10 ++++++++-- 6 files changed, 48 insertions(+), 12 deletions(-) diff --git a/synapseclient/extensions/curator/schema_generation.py b/synapseclient/extensions/curator/schema_generation.py index 2d864b308..decbf2028 100644 --- a/synapseclient/extensions/curator/schema_generation.py +++ b/synapseclient/extensions/curator/schema_generation.py @@ -5198,7 +5198,10 @@ def _convert_conditional_properties_to_all_of( "Cancer" ] } - } + }, + "required":[ + "Diagnosis" + ] }, "then":{ "properties":{ @@ -5217,7 +5220,10 @@ def _convert_conditional_properties_to_all_of( enum_value, ), dependent_properties in conditional_dependencies.items(): conditional_dep = { - "if": {"properties": {watched_property: {"enum": [enum_value]}}}, + "if": { + "properties": {watched_property: {"enum": [enum_value]}}, + "required": [watched_property], + }, "then": { "properties": { prop: {"not": {"type": "null"}} for prop in dependent_properties diff --git a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.display_names_schema.json b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.display_names_schema.json index e43b8a272..40c74daa4 100644 --- a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.display_names_schema.json +++ b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.display_names_schema.json @@ -10,7 +10,10 @@ "BAM" ] } - } + }, + "required":[ + "File Format" + ] }, "then": { "properties": { @@ -33,7 +36,10 @@ "CRAM" ] } - } + }, + "required":[ + "File Format" + ] }, "then": { "properties": { @@ -62,7 +68,10 @@ "CSV/TSV" ] } - } + }, + "required":[ + "File Format" + ] }, "then": { "properties": { diff --git a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.schema.json b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.schema.json index 81c93cf1c..3ae8699f2 100644 --- a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.schema.json +++ b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.schema.json @@ -10,7 +10,10 @@ "BAM" ] } - } + }, + "required":[ + "FileFormat" + ] }, "then": { "properties": { @@ -33,7 +36,10 @@ "CRAM" ] } - } + }, + "required":[ + "FileFormat" + ] }, "then": { "properties": { @@ -62,7 +68,10 @@ "CSV/TSV" ] } - } + }, + "required":[ + "FileFormat" + ] }, "then": { "properties": { diff --git a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.display_names_schema.json b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.display_names_schema.json index 6d105a773..287f83819 100644 --- a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.display_names_schema.json +++ b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.display_names_schema.json @@ -10,7 +10,10 @@ "Cancer" ] } - } + }, + "required":[ + "Diagnosis" + ] }, "then": { "properties": { diff --git a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.schema.json b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.schema.json index 8f7eb7887..7f0ed0836 100644 --- a/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.schema.json +++ b/tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.schema.json @@ -10,7 +10,10 @@ "Cancer" ] } - } + }, + "required":[ + "Diagnosis" + ] }, "then": { "properties": { diff --git a/tests/unit/synapseclient/extensions/unit_test_create_json_schema.py b/tests/unit/synapseclient/extensions/unit_test_create_json_schema.py index 2271afa4d..e8ecfd8a4 100644 --- a/tests/unit/synapseclient/extensions/unit_test_create_json_schema.py +++ b/tests/unit/synapseclient/extensions/unit_test_create_json_schema.py @@ -327,7 +327,10 @@ def test_convert_conditional_properties_to_all_of(self) -> None: # THEN the result should match the expected structure expected_cancer = { - "if": {"properties": {"Diagnosis": {"enum": ["Cancer"]}}}, + "if": { + "properties": {"Diagnosis": {"enum": ["Cancer"]}}, + "required": ["Diagnosis"], + }, "then": { "properties": { "CancerType": {"not": {"type": "null"}}, @@ -338,7 +341,10 @@ def test_convert_conditional_properties_to_all_of(self) -> None: } expected_healthy = { - "if": {"properties": {"Diagnosis": {"enum": ["Healthy"]}}}, + "if": { + "properties": {"Diagnosis": {"enum": ["Healthy"]}}, + "required": ["Diagnosis"], + }, "then": { "properties": {"CheckupDate": {"not": {"type": "null"}}}, "required": ["CheckupDate"],