From c27e06a00c75085c26cdb3860ca822878c1913c4 Mon Sep 17 00:00:00 2001 From: v-rocheleau Date: Wed, 14 Jun 2023 17:02:35 +0000 Subject: [PATCH] deep copy of schema in patch_project_schemas --- chord_metadata_service/restapi/schema_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chord_metadata_service/restapi/schema_utils.py b/chord_metadata_service/restapi/schema_utils.py index eeca27bc5..1801b594c 100644 --- a/chord_metadata_service/restapi/schema_utils.py +++ b/chord_metadata_service/restapi/schema_utils.py @@ -2,6 +2,7 @@ from bento_lib.search import queries as q from .description_utils import describe_schema from typing import List, Optional, Dict +from copy import deepcopy __all__ = [ "merge_schema_dictionaries", @@ -154,13 +155,13 @@ def patch_project_schemas(base_schema: dict, extension_schemas: Dict[str, object if not isinstance(base_schema, dict) or "type" not in base_schema: return base_schema - patched_schema = {**base_schema} + patched_schema = deepcopy(base_schema) if patched_schema["type"] == "object": # check if current object schema needs an extra_properties patch # Get the last term of the schema $id to match with SchemaType # e.g. 'katsu:phenopackets:phenopacket' -> 'phenopacket' - schema_id = base_schema["$id"].split(":")[-1] if "$id" in base_schema else None + schema_id = patched_schema["$id"].split(":")[-1] if "$id" in patched_schema else None if schema_id and schema_id in extension_schemas: ext_schema = extension_schemas[schema_id]