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

Enhancement: Allow status code categories in route handlers responses #3499

Open
rafalkrupinski opened this issue May 16, 2024 · 0 comments
Open
Labels
Enhancement This is a new feature or request

Comments

@rafalkrupinski
Copy link

rafalkrupinski commented May 16, 2024

Summary

Allow route handlers to declare responses with status code categories, i.e. "2XX", "3XX", etc.

I'm happy to send PR if the feature is desirable.

Basic Example

@get(
    '/push',
     responses={
        '2XX': ResponseSpec(SuccessMessage),
        '4XX': ResponseSpec(RequestError),
    }
)
async def operation(...):...

Drawbacks and Impact

if I understand it correctly, it only affects generated OpenAPI document.
Users could define common response types for entire status code categories (2XX, 3XX, etc) or (optionally) "default".

The responses map type would need to be extended to support int or str (literal).
New constants may be added for the categories in status_codes or elsewhere.

Unresolved questions

No response


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@rafalkrupinski rafalkrupinski added the Enhancement This is a new feature or request label May 16, 2024
@rafalkrupinski rafalkrupinski changed the title Enhancement: Allow status categories in route handlers responses Enhancement: Allow status code categories in route handlers responses May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement This is a new feature or request
Projects
None yet
Development

No branches or pull requests

1 participant