diff --git a/dandischema/models.py b/dandischema/models.py index eaa98263..365aa69d 100644 --- a/dandischema/models.py +++ b/dandischema/models.py @@ -571,7 +571,6 @@ def __get_pydantic_json_schema__( if value.get("format", None) == "uri": value["maxLength"] = 1000 allOf = value.get("allOf") - anyOf = value.get("anyOf") items = value.get("items") if allOf is not None: if len(allOf) == 1 and "$ref" in allOf[0]: @@ -581,9 +580,6 @@ def __get_pydantic_json_schema__( value["oneOf"] = value["allOf"] value["type"] = "object" del value["allOf"] - if anyOf is not None: - if len(anyOf) > 1 and any(["$ref" in val for val in anyOf]): - value["type"] = "object" if items is not None: anyOf = items.get("anyOf") if ( @@ -612,7 +608,7 @@ class PropertyValue(DandiBaseModel): maxValue: Optional[float] = Field(None, json_schema_extra={"nskey": "schema"}) minValue: Optional[float] = Field(None, json_schema_extra={"nskey": "schema"}) unitText: Optional[str] = Field(None, json_schema_extra={"nskey": "schema"}) - value: Union[Any, List[Any]] = Field( + value: Any = Field( None, validate_default=True, json_schema_extra={"nskey": "schema"}, @@ -634,7 +630,7 @@ class PropertyValue(DandiBaseModel): @field_validator("value") @classmethod - def ensure_value(cls, val: Union[Any, List[Any]]) -> Union[Any, List[Any]]: + def ensure_value(cls, val: Any) -> Any: if not val: raise ValueError( "The value field of a PropertyValue cannot be None or empty." @@ -1275,7 +1271,7 @@ class PublishActivity(Activity): class Locus(DandiBaseModel): - identifier: Union[Identifier, List[Identifier]] = Field( + identifier: Identifier = Field( description="Identifier for genotyping locus.", json_schema_extra={"nskey": "schema"}, ) @@ -1287,7 +1283,7 @@ class Locus(DandiBaseModel): class Allele(DandiBaseModel): - identifier: Union[Identifier, List[Identifier]] = Field( + identifier: Identifier = Field( description="Identifier for genotyping allele.", json_schema_extra={"nskey": "schema"}, ) @@ -1386,7 +1382,7 @@ class Participant(DandiBaseModel): "available. (e.g. from OBI)", json_schema_extra={"nskey": "dandi"}, ) - genotype: Optional[Union[List[GenotypeInfo], Identifier]] = Field( + genotype: Optional[Union[GenotypeInfo, Identifier]] = Field( None, description="Genotype descriptor of participant or subject if available", json_schema_extra={"nskey": "dandi"},