Skip to content

Commit

Permalink
Adapt to the FieldInfo the new class for representing a field in `g…
Browse files Browse the repository at this point in the history
…enerate_context`
  • Loading branch information
candleindark committed Dec 8, 2023
1 parent ecd98ed commit be176ab
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ def generate_context() -> dict:
elif name == "digest":
fields[name] = "@nest"
elif name not in fields:
if "nskey" in field.field_info.extra:
fields[name] = {"@id": field.field_info.extra["nskey"] + ":" + name}
if (
field.json_schema_extra is not None
and "nskey" in field.json_schema_extra
):
fields[name] = {
"@id": field.json_schema_extra["nskey"] + ":" + name
}
else:
fields[name] = {"@id": "dandi:" + name}
if "List" in str(field.outer_type_):
if "List" in str(field.annotation):
fields[name]["@container"] = "@set"
if name == "contributor":
fields[name]["@container"] = "@list"
if "enum" in str(field.type_) or name in ["url", "hasMember"]:
if "enum" in str(field.annotation) or name in ["url", "hasMember"]:
fields[name]["@type"] = "@id"

for item in models.DigestType:
Expand Down

0 comments on commit be176ab

Please sign in to comment.