diff --git a/src/caoscrawler/validator.py b/src/caoscrawler/validator.py index bb21a6117cc95c60450a6b6c8e26d165640c10b9..3051f4c42dd50496e64e9ab0871b464b5f564192 100644 --- a/src/caoscrawler/validator.py +++ b/src/caoscrawler/validator.py @@ -67,7 +67,17 @@ def load_json_schema_from_datamodel_yaml(filename: str) -> list: def representer_ordereddict(dumper, data): - # yaml.add_representer(OrderedDict, caoscrawler.validator.representer_ordereddict) + """ + Helper function to be able to represent the converted json schema objects correctly as yaml. + This representer essentially replaced OrderedDict objects with simple dict objects. + + Since Python 3.7 dicts are ordered by default, see e.g.: https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/en/ + + Example how to use the representer: + ```python + yaml.add_representer(OrderedDict, caoscrawler.validator.representer_ordereddict) + ``` + """ return dumper.represent_data(dict(data))