[RFC] Make code argument first positional in @response
See original GitHub issueI opened #193 2 months ago but didn’t get much feedback so I figured I’d open an RFC issue for more visibility.
Currently, status code defaults to 200, which is also Flask default.
def response(
self, schema=None, *, code=200, description=None,
example=None, examples=None, headers=None
):
The proposal is to make code mandatory and first positional arg.
def response(
self, code, schema=None, *, description=None,
example=None, examples=None, headers=None
):
The first motivation for this was to make the signature coherent with the long-awaited upcoming alt_response
decorator (#159).
Obviously, this change breaks everyone’s code, but it is at worst a tedious find’n replace, no feature broken.
Pros
- In line with alt_response decorator.
- Nicer visually to have all the codes and schemas aligned.
- No real reason to have 200 as default, apart from alignment with Flask. In my typical REST API resource, only 3 endpoints out of 5 return a 200.
- Make it explicit to the user that a code will be added to the response and which one.
Cons
- Need to specify 200 more than half of the time while it could be the default.
- Need to change existing codebases.
I’m leaning towards moving on with this, but I can allow a little bit more time for feedback before I do so. It is not so much about counting 👍 and 👎 than letting users express specific concerns I might have overlooked.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
RFC# 691 - IETF
The list of reply codes is also slightly different to reflect the four lists in RFCs ... Servers which do not implement any...
Read more >rfcs/1951-expand-impl-trait.md at master · rust-lang/rfcs - GitHub
This RFC proposes to stabilize the impl Trait feature with its current syntax, while also expanding it to encompass argument position. That means,...
Read more >Pre-RFC: Named arguments - language design - Rust Internals
Summary. This RFC introduces named arguments for Rust. Named arguments are the ability to call a function , method or closure while precising ......
Read more >[RFC] First-class callable syntax - externals.io
I'd like to present an RFC for a first-class callable syntax, which is intended as a simpler alternative to the partial function application...
Read more >API — Flask Documentation (2.2.x)
The idea of the first parameter is to give Flask an idea of what belongs to your application. ... Run setup code when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, that was my instinct. In which case my vote is to just go ahead with this and
@alt_response
. The change is breaking, but minimal effort to fix, and I would greatly appreciate the ability to properly document all responses.Done.