Open aparamon opened 5 years ago
Currently, Content-Type is selected from all global mediatype representations, regardless of per-route annotations.
Content-Type
To reproduce:
from flask import Flask, make_response from flask_restplus import Resource, Api app = Flask(__name__) api = Api(app) ns = api.namespace('test') @api.representation('text/html') def html(data, code, headers=None): html = ''' <!doctype html> <head> <title>Hello, world!</title> </head> ''' response = make_response(html, code) response.headers.extend(headers or {}) return response @ns.route('/hello') @ns.produces('application/json') class HelloWorld(Resource): def get(self): return {'hello': 'world'} if __name__ == '__main__': app.run(debug=True)
>curl localhost:5000/test/hello -H "Accept: text/html" <!doctype html> <head> <title>Hello, world!</title> </head>
Expected output is though:
{ "hello": "world" }
OpenAPI 3.0 only has per-route, not global mediatypes: https://swagger.io/docs/specification/media-types
Currently,
Content-Type
is selected from all global mediatype representations, regardless of per-route annotations.To reproduce:
Expected output is though: