From 8f7d029e9fb4e947101cac5092b35017f8eede76 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Thu, 14 Mar 2024 13:55:13 +0100 Subject: [PATCH] stage: schema allows for any of schema/schema_2 Instead of requiring only one of the properties to be present require at least one of them being present; some stages specify both schema versions (`org.osbuild.rpm`) --- osbuild/meta.py | 22 +++++++++++++++++++--- test/mod/test_meta.py | 9 ++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/osbuild/meta.py b/osbuild/meta.py index 44cbe3cd..44637b8d 100644 --- a/osbuild/meta.py +++ b/osbuild/meta.py @@ -284,16 +284,32 @@ META_JSON_SCHEMA = { }, }, "required": ["summary", "description"], - "oneOf": [ + "anyOf": [ { "required": [ "schema" - ] + ], + "not": { + "required": [ + "schema_2", + ], + }, }, { "required": [ "schema_2" - ] + ], + "not": { + "required": [ + "schema", + ], + }, + }, + { + "required": [ + "schema", + "schema_2", + ], }, ], "properties": { diff --git a/test/mod/test_meta.py b/test/mod/test_meta.py index 0294c501..8a26e58a 100644 --- a/test/mod/test_meta.py +++ b/test/mod/test_meta.py @@ -317,7 +317,8 @@ def test_load_from_json_prefered(tmp_path): {"summary": "some", "description": ["many", "strings"], "schema": {}}, ""), ( {"summary": "some", "description": ["many", "strings"], "schema_2": {}}, ""), ( {"summary": "some", "description": ["many", "strings"], "schema_2": {}, "capabilities": []}, ""), ( - {"summary": "some", "description": ["many", "strings"], "schema_2": {}, "capabilities": ["cap1", "cap2"]}, ""), + {"summary": "some", "description": ["many", "strings"], "schema_2": {}, "capabilities": ["cap1", "cap2"]}, ""), ( + {"summary": "some", "description": ["many", "strings"], "schema": {}, "schema_2": {}, "capabilities": ["cap1", "cap2"]}, ""), # unhappy ( # no description @@ -331,12 +332,6 @@ def test_load_from_json_prefered(tmp_path): # schema{,_2} missing {"summary": "some", "description": ["many", "strings"]}, " is not valid", - ), - ( - # both schema{,_2} - {"summary": "some", "description": ["many", "strings"], - "schema": {}, "schema_2": {}}, - " is valid under each ", ), ( # capabilities of wrong type {"summary": "some", "description": ["many", "strings"], "schema": {},