python-restx/flask-restx

A way to use custom HTTP methods

sergeyepimakhov opened this issue · 2 comments

Ask a question
Is there a way to use a custom HTTP method i.e. LIST among standard ones GET, POST etc.?

class MyClass(Resource):

    def list(self):
        return 'ok', 200

Currently we are getting back:

AttributeError: 'FlaskClient' object has no attribute 'list'

Additional context
Flask overrides did't help: https://flask.palletsprojects.com/en/2.3.x/patterns/methodoverrides/

flask-restx is designed to implement RESTful type APIs, so custom HTTP methods are not supported. There are also compatibility issues, because Swagger 2.0 that is currently used to generate the docs doesn't support custom methods either to my knowledge.

You shouldn't need a list function in a truly RESTful api, because GET on a resource with no identifier should return a list. For example:
GET /products - Should return a list of all products.
GET /products/ - Should return a specific product or 404 if not found.

Thank you for clarification!