Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions dandischema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand All @@ -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 (
Expand Down Expand Up @@ -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"},
Expand All @@ -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."
Expand Down Expand Up @@ -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"},
)
Expand All @@ -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"},
)
Expand Down Expand Up @@ -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"},
Expand Down