From 7c072778823e6497edee95c93c517746297f8f00 Mon Sep 17 00:00:00 2001 From: Jacob Riddle Date: Mon, 5 Aug 2024 12:43:44 -0400 Subject: [PATCH] jsonify return for yaml safe load --- ansible_specdoc/objects.py | 3 ++- tests/test_cli.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ansible_specdoc/objects.py b/ansible_specdoc/objects.py index 388bc76..f60c2ff 100644 --- a/ansible_specdoc/objects.py +++ b/ansible_specdoc/objects.py @@ -5,6 +5,7 @@ from __future__ import annotations import copy +import json from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Tuple, Union @@ -213,7 +214,7 @@ def ansible_doc(self) -> Dict[str, Any]: "description": self.description, "type": str(self.type), "returned": self.returned, - "sample": self.sample, + "sample": json.loads("".join(self.sample)), } if self.elements is not None: diff --git a/tests/test_cli.py b/tests/test_cli.py index ce4aaca..91edebe 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -163,6 +163,7 @@ def test_docs_file_injection(): assert f'DOCUMENTATION = r"""\n{docs}"""' in output assert f'EXAMPLES = r"""\n{examples}"""' in output assert f'RETURN = r"""\n{returns}"""' in output + assert '{' not in returns @staticmethod def test_docs_file_clear():