-
-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
Issue: Empty dict values in the definitions are rendered not to {}
but to null
incorrectly.
PoC code:
from json import loads
from aiohttp import web
from aiohttp_swagger.helpers import generate_doc_from_each_end_point
app = web.Application()
definitions = dict(
test={
"type": "object",
"properties": {"prop": {"type": "object", "default": dict()}},
}
)
doc = generate_doc_from_each_end_point(app, definitions=definitions)
print(doc)
test1 = definitions["test"]
test2 = loads(doc)["definitions"]["test"]
print(test1)
print(test2)
assert test1 == test2
Expectation:
- The generated doc shall show
"default": {}
. test2
extracted from the generated doc shall be equal totest1
from the original definitions.
{"swagger": "2.0", "info": {"description": "Swagger API definition\n", "version": "1.0.0", "title": "Swagger API"}, "basePath": "/", "schemes": ["http", "https"], "definitions": {"test": {"type": "object", "properties": {"prop": {"type": "object", "default": {}}}}}, "paths": {}}
{'type': 'object', 'properties': {'prop': {'type': 'object', 'default': {}}}}
{'type': 'object', 'properties': {'prop': {'type': 'object', 'default': {}}}}
Observation:
- The generated doc shows
"default": null
. test2
extracted from the generated doc isn't equal totest1
from the original definitions.
{"swagger": "2.0", "info": {"description": "Swagger API definition\n", "version": "1.0.0", "title": "Swagger API"}, "basePath": "/", "schemes": ["http", "https"], "definitions": {"test": {"type": "object", "properties": {"prop": {"type": "object", "default": null}}}}, "paths": {}}
{'type': 'object', 'properties': {'prop': {'type': 'object', 'default': {}}}}
{'type': 'object', 'properties': {'prop': {'type': 'object', 'default': None}}}
Traceback (most recent call last):
File "C:\Users\YouheiSakurai\Desktop\poc.py", line 20, in <module>
assert test1 == test2
^^^^^^^^^^^^^^
AssertionError
Environment
- Python 3.12.7
- aiohttp-swagger 1.0.16
Metadata
Metadata
Assignees
Labels
No labels