marshmallow-code / marshmallow-code/apispec-webframeworks

RFC: enforce method order for one endpoint in the spec

Open
#15 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement feedback welcome help wanted
Dominant language
Python
Stars
33
Forks
24
Avg merge
5h 38m
Merged PRs (30d)
4

Description

**Issue by [lafrech](https://github.com/lafrech)**
_Wednesday Apr 04, 2018 at 13:39 GMT_
_Originally opened as https://github.com/marshmallow-code/apispec/issues/193_

----

_Although json objects are not ordered, some tools respect the order in the OpanAPI json file to display the spec. Therefore, it makes sense to respect the order desired by the user when writing the spec file. Several PRs are based on this assumption (#86, #87, #189)._

It could be nice to enforce the order of the methods for each endpoint. For instance, always present the methods in this order:

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

The order list being a module variable, it could be mutated by the user if another order is required.

This feature requires modifications in flask, tornado, and perhaps bottle extensions. More details in https://github.com/marshmallow-code/apispec/pull/189.

Edit: I'd remove `'TRACE'` from the list as it is not in [`VALID_METHODS`](https://github.com/marshmallow-code/apispec/blob/ea55ad0463b7fe6039d5e6507254682fd3ffdbb3/apispec/core.py#L13).

Edit again: OpenAPI 3 contains `TRACE` (https://github.com/marshmallow-code/apispec/issues/165#issuecomment-388753808).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apispec/core.py and the Flask, Tornado, and Bottle extensions mentioned in the issue; inspect VALID_METHODS and the ordering behavior discussed in PR #189. Determine how each plugin emits endpoint methods, then verify with the relevant extension tests that the requested method order is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, openapi, python
Domain
api, backend-api-design, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.