Skip to content

Commit 5a40d1e

Browse files
authored
Merge pull request #1334 from Sage-Bionetworks/SYNPY-1787
[SYNPY-1787] Changed conditionals so that the watched property is required
2 parents ca03832 + 93e674f commit 5a40d1e

6 files changed

Lines changed: 48 additions & 12 deletions

File tree

synapseclient/extensions/curator/schema_generation.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5198,7 +5198,10 @@ def _convert_conditional_properties_to_all_of(
51985198
"Cancer"
51995199
]
52005200
}
5201-
}
5201+
},
5202+
"required":[
5203+
"Diagnosis"
5204+
]
52025205
},
52035206
"then":{
52045207
"properties":{
@@ -5217,7 +5220,10 @@ def _convert_conditional_properties_to_all_of(
52175220
enum_value,
52185221
), dependent_properties in conditional_dependencies.items():
52195222
conditional_dep = {
5220-
"if": {"properties": {watched_property: {"enum": [enum_value]}}},
5223+
"if": {
5224+
"properties": {watched_property: {"enum": [enum_value]}},
5225+
"required": [watched_property],
5226+
},
52215227
"then": {
52225228
"properties": {
52235229
prop: {"not": {"type": "null"}} for prop in dependent_properties

tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.display_names_schema.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"BAM"
1111
]
1212
}
13-
}
13+
},
14+
"required":[
15+
"File Format"
16+
]
1417
},
1518
"then": {
1619
"properties": {
@@ -33,7 +36,10 @@
3336
"CRAM"
3437
]
3538
}
36-
}
39+
},
40+
"required":[
41+
"File Format"
42+
]
3743
},
3844
"then": {
3945
"properties": {
@@ -62,7 +68,10 @@
6268
"CSV/TSV"
6369
]
6470
}
65-
}
71+
},
72+
"required":[
73+
"File Format"
74+
]
6675
},
6776
"then": {
6877
"properties": {

tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.BulkRNA-seqAssay.schema.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"BAM"
1111
]
1212
}
13-
}
13+
},
14+
"required":[
15+
"FileFormat"
16+
]
1417
},
1518
"then": {
1619
"properties": {
@@ -33,7 +36,10 @@
3336
"CRAM"
3437
]
3538
}
36-
}
39+
},
40+
"required":[
41+
"FileFormat"
42+
]
3743
},
3844
"then": {
3945
"properties": {
@@ -62,7 +68,10 @@
6268
"CSV/TSV"
6369
]
6470
}
65-
}
71+
},
72+
"required":[
73+
"FileFormat"
74+
]
6675
},
6776
"then": {
6877
"properties": {

tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.display_names_schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"Cancer"
1111
]
1212
}
13-
}
13+
},
14+
"required":[
15+
"Diagnosis"
16+
]
1417
},
1518
"then": {
1619
"properties": {

tests/unit/synapseclient/extensions/schema_files/expected_jsonschemas/expected.Patient.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"Cancer"
1111
]
1212
}
13-
}
13+
},
14+
"required":[
15+
"Diagnosis"
16+
]
1417
},
1518
"then": {
1619
"properties": {

tests/unit/synapseclient/extensions/unit_test_create_json_schema.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,10 @@ def test_convert_conditional_properties_to_all_of(self) -> None:
327327

328328
# THEN the result should match the expected structure
329329
expected_cancer = {
330-
"if": {"properties": {"Diagnosis": {"enum": ["Cancer"]}}},
330+
"if": {
331+
"properties": {"Diagnosis": {"enum": ["Cancer"]}},
332+
"required": ["Diagnosis"],
333+
},
331334
"then": {
332335
"properties": {
333336
"CancerType": {"not": {"type": "null"}},
@@ -338,7 +341,10 @@ def test_convert_conditional_properties_to_all_of(self) -> None:
338341
}
339342

340343
expected_healthy = {
341-
"if": {"properties": {"Diagnosis": {"enum": ["Healthy"]}}},
344+
"if": {
345+
"properties": {"Diagnosis": {"enum": ["Healthy"]}},
346+
"required": ["Diagnosis"],
347+
},
342348
"then": {
343349
"properties": {"CheckupDate": {"not": {"type": "null"}}},
344350
"required": ["CheckupDate"],

0 commit comments

Comments
 (0)