Skip to content

Commit 4e2a068

Browse files
committed
Contacts in OGC API records no longer include default
1 parent 62ee7bf commit 4e2a068

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

deep_code/utils/ogc_api_record.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,32 @@
1717
class Contact(MappingConstructible["Contact"], JsonSerializable):
1818
def __init__(
1919
self,
20-
name: str,
21-
organization: str,
22-
position: str | None = "",
20+
name: str | None = None,
21+
organization: str | None = None,
22+
position: str | None = None,
2323
links: list[dict[str, Any]] | None = None,
24-
contactInstructions: str | None = "",
25-
roles: list[str] = None,
24+
contactInstructions: str | None = None,
25+
roles: list[str] | None = None,
2626
):
2727
self.name = name
2828
self.organization = organization
2929
self.position = position
30-
self.links = links or []
30+
self.links = links
3131
self.contactInstructions = contactInstructions
32-
self.roles = roles or ["principal investigator"]
32+
self.roles = roles
33+
34+
def to_dict(self, value_name: str | None = None) -> dict[str, JsonValue]:
35+
"""Serialize to JSON, dropping None values."""
36+
data = {
37+
"name": self.name,
38+
"organization": self.organization,
39+
"position": self.position,
40+
"links": self.links,
41+
"contactInstructions": self.contactInstructions,
42+
"roles": self.roles,
43+
}
44+
# keep only explicitly set fields
45+
return {k: v for k, v in data.items() if v is not None}
3346

3447

3548
class ThemeConcept(MappingConstructible["ThemeConcept"], JsonSerializable):

0 commit comments

Comments
 (0)