Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain order in which methods are added to endpoint #189

Merged
merged 2 commits into from Apr 4, 2018

Conversation

@lafrech
Copy link
Member

commented Mar 29, 2018

Similar to #86 and #87.

@lafrech lafrech changed the title Dev endpoint method order Maintain endpoint method order Mar 29, 2018

@lafrech lafrech changed the title Maintain endpoint method order Maintain order in which methods are added to endpoint Mar 29, 2018

@lafrech lafrech force-pushed the Nobatek:dev_endpoint_method_order branch from 4330953 to aefd1cb Apr 4, 2018

@lafrech lafrech changed the title Maintain order in which methods are added to endpoint WIP - Maintain order in which methods are added to endpoint Apr 4, 2018

@lafrech lafrech force-pushed the Nobatek:dev_endpoint_method_order branch from aefd1cb to cf88730 Apr 4, 2018

@lafrech lafrech changed the title WIP - Maintain order in which methods are added to endpoint Maintain order in which methods are added to endpoint Apr 4, 2018

@lafrech

This comment has been minimized.

Copy link
Member Author

commented Apr 4, 2018

Rebasing this on #190 assuming it would be merged as is. If not, I'll rebase again.

This change is useful to me because I'm enforcing the order of the methods for each endpoint in the spec:

['OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'TRACE']

I find it nice to have a consistent method order.

It works because I'm iterating on the methods in my lib, not in apispec.


For people using apispec.ext.flask.path_from_view, it would take another modification in there:

HTTP_METHODS = ['OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'TRACE']

def path_from_view(spec, view, **kwargs):
    [...]
    operations = OrderedDict()
    for method in HTTP_METHODS:
        if method in view.methods and method in rule.methods:
            [...]

Likewise for tornado and the others.

This means hardcoding the method order. The user could mutate the global method list to control the order, though.

I think this can be done in another PR without holding this one.

@sloria

This comment has been minimized.

Copy link
Member

commented Apr 4, 2018

Thanks @lafrech . #190 is merged, but it looks like this needs to be rebased one more time. Also, would you mind opening an issue for the Flask/Tornado issue you mentioned?

@lafrech lafrech force-pushed the Nobatek:dev_endpoint_method_order branch from cf88730 to 6749712 Apr 4, 2018

@lafrech

This comment has been minimized.

Copy link
Member Author

commented Apr 4, 2018

Great. I just rebased and opened #193.

@sloria sloria merged commit ea55ad0 into marshmallow-code:dev Apr 4, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@lafrech lafrech deleted the Nobatek:dev_endpoint_method_order branch Apr 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.