miLibris / flask-rest-jsonapi

Flask extension to build REST APIs around JSONAPI 1.0 specification.
http://flask-rest-jsonapi.readthedocs.io
MIT License
598 stars 153 forks source link

Assign correct endpoint to each resource instance #178

Open multimeric opened 4 years ago

multimeric commented 4 years ago

By default we assign each Resource class with a view/endpoint. However if the same resource is used for multiple routes, the endpoint will be overwritten.

e.g. previously this test would fail:

    api = Api()

    class DummyResource(ResourceDetail):
        def get(self):
            return self.view

    api.route(DummyResource, 'endpoint1', '/url1')
    api.route(DummyResource, 'endpoint2', '/url2')
    api.init_app(app)

    with app.test_client() as client:
        assert client.get('/url1', content_type='application/vnd.api+json').json == 'endpoint1'
        assert client.get('/url2', content_type='application/vnd.api+json').json == 'endpoint2'
coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.06%) to 90.83% when pulling 01d28471e779b0dc4a3e9e4bfa04c83a614695f0 on TMiguelT:resource_view into b44bc08b11213d49fadae873650d3555889052ec on miLibris:master.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.06%) to 90.83% when pulling fbf28cdeb2460959c9ea9349efa04cf476aaf97d on TMiguelT:resource_view into b44bc08b11213d49fadae873650d3555889052ec on miLibris:master.