Skip to content

Commit

Permalink
Merge pull request #413 from bento-platform/patch/fix-required-extra-…
Browse files Browse the repository at this point in the history
…properties

patch: fix unwanted origin schema mutation for required extra_properties
  • Loading branch information
v-rocheleau authored Jun 14, 2023
2 parents 541ba62 + c27e06a commit 8fadb60
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chord_metadata_service/restapi/schema_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 8fadb60

Please sign in to comment.