Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nesteddict2yaml not to fumble empty dict values #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aiohttp_swagger/helpers/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def generate_doc_from_each_end_point(
def nesteddict2yaml(d, indent=10, result=""):
for key, value in d.items():
result += " " * indent + str(key) + ':'
if isinstance(value, dict):
if isinstance(value, dict) and value:
result = nesteddict2yaml(value, indent + 2, result + "\n")
elif isinstance(value, str):
result += " \"" + str(value) + "\"\n"
Expand Down
5 changes: 5 additions & 0 deletions tests/data/example_data_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
"type": "string",
"description": "User's permission parameter",
"default": "some_perm"
},
"permission_param_3": {
"type": "object",
"description": "User's permission parameter",
"default": {}
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions tests/test_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ async def test_data_defs(aiohttp_client, loop):
assert 'User' in result['components']['schemas']
assert 'Permission' in result['components']['schemas']
assert result['components']['schemas']['User']['properties']['permissions']['items']['$ref'] is not None
assert result['components']['schemas']['Permission']['properties']['permission_param_3']['default'] is not None


async def test_sub_app(aiohttp_client, loop):
Expand Down
1 change: 1 addition & 0 deletions tests/test_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ async def test_data_defs(aiohttp_client, loop):
assert 'User' in result['definitions']
assert 'Permission' in result['definitions']
assert result['definitions']['User']['properties']['permissions']['items']['$ref'] is not None
assert result['definitions']['Permission']['properties']['permission_param_3']['default'] is not None


async def test_sub_app(aiohttp_client, loop):
Expand Down