Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Assign correct endpoint to each resource instance#178

Open
multimeric wants to merge 4 commits intomiLibris:masterfrom
multimeric:resource_view
Open

Assign correct endpoint to each resource instance#178
multimeric wants to merge 4 commits intomiLibris:masterfrom
multimeric:resource_view

Conversation

@multimeric
Copy link
Contributor

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
Copy link

Coverage Status

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

@coveralls
Copy link

coveralls commented Nov 4, 2019

Coverage Status

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants