Skip to content

Using class-based views with Flask 2.2 causes TypeError: view() takes 0 positional arguments but 1 was given #341

@NimaQu

Description

@NimaQu

Error when using class-based views for compliance documentation

from flask.views import MethodView
from apiflask import APIFlask

app = APIFlask(__name__)


@app.route('/pets/<int:pet_id>', endpoint='pet')
class Pet(MethodView):

    def get(self, pet_id):
        return {'message': 'OK'}

    def delete(self, pet_id):
        return '', 204

app.run(debug=True)

Environment:

  • Python version: 3.10
  • Flask version: 2.2.2
  • APIFlask version: 1.1.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions