Open LLCcom opened 6 years ago
Did you find a solution to this? I have the same type of issue.
I've found that using "@api.representation" (see https://flask-restful.readthedocs.io/en/0.3.5/extending.html#content-negotiation) add new entries to the response content type dropdown menu.
The Swagger Response content type can be set with the produces
decorator on a view method. Here's an example from my own code which sets the response content type to "image/png":
@images_ns.response(HTTPStatus.NOT_FOUND, "Image content not found", problem_details_model)
@images_ns.response(HTTPStatus.OK, "Image content found")
@images_ns.produces(["image/png"])
def get(self, id):
"""Returns the image binary."""
image_meta = persistent.Image.query.get_or_404(id)
image = extract_image_data(image_meta)
response = make_response(image.as_bytes())
response.headers.set("Content-Type", "image/png")
return response
This gives:
Hi, I am trying to export a pdf file but when I add @api.produces(["application/pdf"]) I got error "AttributeError: 'Namespace' object has no attribute 'produces'".
flask-restplus==0.10.1
Do you know about this error? Thanks.
I have a [GET] route, which I wish to return a response with content-type="application/pdf". But looks like in swagger UI generated from flask-restplus we only have one response content type( which is json). Is there a way to change that in flask restplus and allow us to test that endpoint in swagger?