diff --git a/src/pysdmx/io/json/fusion/messages/code.py b/src/pysdmx/io/json/fusion/messages/code.py index c10dcb9f..32340dbc 100644 --- a/src/pysdmx/io/json/fusion/messages/code.py +++ b/src/pysdmx/io/json/fusion/messages/code.py @@ -41,8 +41,8 @@ def __handle_date(self, datestr: str) -> datetime: def __get_val( self, a: FusionAnnotation ) -> Tuple[Optional[datetime], Optional[datetime]]: - vals = a.title.split("/") - if a.title.startswith("/"): + vals = a.title.split("/") # type: ignore[union-attr] + if a.title.startswith("/"): # type: ignore[union-attr] return (None, self.__handle_date(vals[1])) else: valid_from = self.__handle_date(vals[0]) diff --git a/src/pysdmx/io/json/fusion/messages/core.py b/src/pysdmx/io/json/fusion/messages/core.py index fe074b8a..7828fc3e 100644 --- a/src/pysdmx/io/json/fusion/messages/core.py +++ b/src/pysdmx/io/json/fusion/messages/core.py @@ -10,13 +10,6 @@ from pysdmx.util import find_by_urn -class FusionAnnotation(msgspec.Struct, frozen=True): - """Fusion-JSON payload for annotations.""" - - title: str - type: str - - class FusionString(msgspec.Struct, frozen=True): """Fusion-JSON payload for an international string.""" @@ -24,6 +17,16 @@ class FusionString(msgspec.Struct, frozen=True): value: str +class FusionAnnotation(msgspec.Struct, frozen=True): + """Fusion-JSON payload for annotations.""" + + id: Optional[str] = None + title: Optional[str] = None + type: Optional[str] = None + value: Optional[str] = None + text: Sequence[FusionString] = () + + class FusionLink(msgspec.Struct, frozen=True): """Fusion-JSON payload for link objects.""" diff --git a/tests/api/fmr/samples/code/freq.fusion.json b/tests/api/fmr/samples/code/freq.fusion.json index a6663dad..a306570c 100644 --- a/tests/api/fmr/samples/code/freq.fusion.json +++ b/tests/api/fmr/samples/code/freq.fusion.json @@ -34,6 +34,14 @@ "value": "N:Annual" } ] + }, + { + "text": [ + { + "locale": "en", + "value": "Empty" + } + ] } ], "names": [ diff --git a/tests/api/fmr/samples/code/freq.json b/tests/api/fmr/samples/code/freq.json index f0725904..00587a31 100644 --- a/tests/api/fmr/samples/code/freq.json +++ b/tests/api/fmr/samples/code/freq.json @@ -55,6 +55,12 @@ "texts": { "en": "N:Annual" } + }, + { + "text": "Empty", + "texts": { + "en": "Empty" + } } ], "name": "Annual", diff --git a/tests/api/fmr/samples/df/tmp_dataflow_with_has.json b/tests/api/fmr/samples/df/tmp_dataflow_with_has.json index 631ef168..db8372ae 100644 --- a/tests/api/fmr/samples/df/tmp_dataflow_with_has.json +++ b/tests/api/fmr/samples/df/tmp_dataflow_with_has.json @@ -40,7 +40,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).MDD", "annotations": [ { - "title": "cemejuma", + "title": "xx000000", "type": "contact_uid" } ], @@ -82,7 +82,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).SFT", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -100,7 +100,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -158,7 +158,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).CBS", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -176,7 +176,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -268,7 +268,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).FIDA", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -286,7 +286,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -310,7 +310,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).DER", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -328,7 +328,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -403,7 +403,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).EXR", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -421,7 +421,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -445,7 +445,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).LBS", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -463,7 +463,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -600,7 +600,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).XTD", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -618,7 +618,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -1174,7 +1174,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).DEBT_SEC", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -1192,7 +1192,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -1343,7 +1343,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).GLI", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -1361,7 +1361,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -2203,7 +2203,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).TFFS", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -2221,7 +2221,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -3686,7 +3686,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).SEC", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -3704,7 +3704,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -4074,7 +4074,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).IDS", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -4092,7 +4092,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", @@ -4179,7 +4179,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).DEALOGIC", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -4197,7 +4197,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", diff --git a/tests/api/fmr/samples/pra/hierarchy_hca.fusion.json b/tests/api/fmr/samples/pra/hierarchy_hca.fusion.json index d74e4dc1..480c3f5d 100644 --- a/tests/api/fmr/samples/pra/hierarchy_hca.fusion.json +++ b/tests/api/fmr/samples/pra/hierarchy_hca.fusion.json @@ -30,7 +30,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).CBS", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -48,7 +48,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en", diff --git a/tests/api/fmr/samples/pra/no_hca.fusion.json b/tests/api/fmr/samples/pra/no_hca.fusion.json index ba46bee7..1c5a16fd 100644 --- a/tests/api/fmr/samples/pra/no_hca.fusion.json +++ b/tests/api/fmr/samples/pra/no_hca.fusion.json @@ -30,7 +30,7 @@ "urn": "urn:sdmx:org.sdmx.infomodel.base.Agency=BIS:AGENCIES(1.0).CBS", "annotations": [ { - "title": "cbmemcpa", + "title": "xx000000", "type": "contact_uid" } ], @@ -48,7 +48,7 @@ ], "contacts": [ { - "id": "cbmemcpa", + "id": "xx000000", "roles": [ { "locale": "en",