inveniosoftware / flask-resources

REST APIs for Flask
https://flask-resources.readthedocs.io
MIT License
3 stars 21 forks source link

Don't implement MethodView methods for missing Resource methods #54

Open fenekku opened 4 years ago

fenekku commented 4 years ago

Problem: because we implement MethodView methods by default even if no corresponding Resource methods were implemented, Flask routes to our default implementation and then the ordering of errors breaks. Where one should get a 405 (because that was also the default return value), one can get a 406 or 415 first because content-type is negotiated on an endpoint that ultimately should not exist in the first place.

Solution: We probably need to use metaprogramming and do like: https://github.com/pallets/flask/blob/024f0d384cf5bb65c76ac59f8ddce464b2dc2ca1/src/flask/views.py#L100 to determine the missing methods in Resource and not register them in the blueprint. See https://github.com/inveniosoftware/flask-resources/issues/36#issuecomment-648428486 for further context.