We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
json.dumps
swagger_info
If the swagger_info attribute contains a datetime object in an example definition, the default JSON serializer will fail for datetime types.
ex)
TypeError: datetime.datetime(2021, 11, 14, 1, 34, 26, tzinfo=datetime.timezone(datetime.timedelta(0, 720))) is not JSON serializable
https://swagger.io/docs/specification/data-models/data-types/#string
aiohttp-swagger/aiohttp_swagger/__init__.py
Line 75 in ea32115
Proposing a PR to either:
The text was updated successfully, but these errors were encountered:
In my case, changing all the json.dumps calls and adding default=str as an argument solved the issue.
default=str
Since this project seems unmaintained at the moment, I've added the following lines to my Dockerfile to patch the library for this issue:
LIB_FOLDER=$(python -c 'import aiohttp_swagger; print(aiohttp_swagger.__path__[0])') sed -i 's/json.dumps(swagger)/json.dumps(swagger, default=str)/g' $LIB_FOLDER/helpers/builders.py sed -i 's/json.dumps(swagger_info)/json.dumps(swagger_info, default=str)/g' $LIB_FOLDER/__init__.py
Or via monkey patching:
aiohttp_swagger.json.dumps = partial(aiohttp_swagger.json.dumps, default=str) aiohttp_swagger.helpers.builders.json.dumps = partial(aiohttp_swagger.helpers.builders.json.dumps, default=str)
Sorry, something went wrong.
No branches or pull requests
If the
swagger_info
attribute contains a datetime object in an example definition, the default JSON serializer will fail for datetime types.ex)
https://swagger.io/docs/specification/data-models/data-types/#string
aiohttp-swagger/aiohttp_swagger/__init__.py
Line 75 in ea32115
Proposing a PR to either:
The text was updated successfully, but these errors were encountered: