-
-
Notifications
You must be signed in to change notification settings - Fork 780
Description
Description
I wish to return data through a swagger endpoint that is not json serialised (text/plain); the documents suggest that this could be accomplished by initialising and returning a ConnexionResponse instance.
The purpose of this is to return metrics information for prometheus without adding additional middleware or a separate process to handle it.
Expected behaviour
The connexion documentation (https://connexion.readthedocs.io/en/latest/response.html) states that:
One way is to return a Response object that will be used unchanged.
def get_healthcheck()
return ConnexionResponse(content_type='text/plain', body=b'hello-world')
Should return hello-world
Actual behaviour
TypeError: Object of type bytes is not JSON serializable
This occurs because cls._jsonify_data is applied regardless of the parameterisation of ConnexionResponse.
In connexion/apis/flask_api.py:182..184
if data is not None and data is not NoContent:
data = cls._jsonify_data(data, mimetype)
flask_response.set_data(data)
Steps to reproduce
See expected behaviour for an endpoint that based on the documentation should be return without error.
Additional info:
Output of the commands:
python --version
Python 3.7.4pip show connexion | grep "^Version\:"
Version: 2.3.0