luolingchun / flask-openapi3

Generate REST API and OpenAPI documentation for your Flask project.
https://luolingchun.github.io/flask-openapi3/
MIT License
203 stars 33 forks source link

APIBlueprint route methods are processed by the Blueprint base class, not APIScaffold #170

Closed dodumosu closed 2 months ago

dodumosu commented 2 months ago

Environment:

simple example:

from http import HTTPStatus

from flask_openapi3 import APIBlueprint

blueprint = APIBlueprint('api', __name__, url_prefix='/api/v1')

@blueprint.route('/login', methods=['POST', 'PUT'], responses={HTTPStatus.OK: MyResponseClass})
def login(body: MyCredentialsClass):

I don't know if it's because I'm trying to add flask_openapi3 to an existing Flask application, but I replaced my Flask instance with an OpenAPI instance and the rest of the app was working fine, but when I tried to add the responses to the view (for documentation purposes), I kept getting this error.

error: TypeError: Rule.__init__() got an unexpected keyword argument 'responses'

Is there any other way to add the responses to the generated documentation?

dodumosu commented 2 months ago

since APIBlueprint inherits from both flask.Blueprint and APIScaffold, my guess is that the route() method is being handled by flask.Blueprint, not APIScaffold

dodumosu commented 2 months ago

:facepalm:

i should have used post() or any other HTTP verb specific method, rather than route()