Skip to content

link.py to_dict is not properly serializing RelType enum values #652

@paulfouquet

Description

@paulfouquet

The to_dict function in link.py is not serializing rel properly in case of using a RelType enum.
(rel is an Union[str, RelType])

d: Dict[str, Any] = {"rel": self.rel, "href": self.get_href()}

In my example, by default the rel is pystac.RelType.ROOT and when I call the to_dict function on a Collection object, the link included in the dictionary returned is the following:
'links': [{'rel': <RelType.ROOT: 'root'>, 'href': '/home/paul/code/linz/topo-processor/collection.json', 'type': <MediaType.JSON: 'application/json'>}]
I would expect that to_dict return the str enum value "root" in my case.

Note that causes an Unsupported type: 'RelType' error when calling a jsonschema-rs validator with this dict.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions