-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support to format examples as YAML or JSON (#20)
* Added support to format examples as yaml or json * fix: Fix format examples tests. * chore: Add examples to README.md. --------- Co-authored-by: Elisiário Couto <elisiario@couto.io>
- Loading branch information
1 parent
f416c31
commit bde2e0a
Showing
5 changed files
with
148 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
|
||
from jsonschema_markdown.converter.markdown import _format_example | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"example, format_type, expected_md", | ||
[ | ||
({"key": "value"}, "yaml", "```yaml\nkey: value\n\n```"), | ||
("example string", "yaml", "```yaml\nexample string\n```"), | ||
({"key": "value"}, "json", '```json\n{\n "key": "value"\n}\n```'), | ||
("example string", "json", "```json\nexample string\n```"), | ||
({"key": "value"}, "text", "```\n{'key': 'value'}\n```"), | ||
({"key": "value"}, "invalid_format", "```\n{'key': 'value'}\n```"), | ||
], | ||
) | ||
def test_generate_examples_format(example, format_type, expected_md): | ||
formatted = _format_example(example, format_type) | ||
assert formatted == expected_md |