paperclip
paperclip copied to clipboard
Description of status codes
As @wafflespeanut described in https://github.com/wafflespeanut/paperclip/pull/243#issuecomment-704763049, we can support the following format to be able to add a description for each status code:
#[api_v2_operation(
status(
code = 200, description = "OK",
code = 202, description = "I accept",
)
)]
fn my_handler () -> Foo { /* */ }
I have an additional suggestion to be able to overwrite the description of the error messages too. Like:
#[api_v2_operation(
status(
code = 200, description = "OK",
code = 202, description = "I accept",
code = 418, description = "I'm a teapot 🫖",
)
)]
fn my_handler () -> Foo { /* */ }
@wafflespeanut @platy any idea/suggestion?
You can define error codes with better reusability and convenience via api_v2_errors macros on Error type.
There is good example in docs https://paperclip.waffles.space/actix-plugin.html
Thanks @dunnock.
I'm using that, but it needs to be customized. For example, generally, 404 means Not Found... but for users, it can mean, "The user is inactive or does not exist", for roles it can mean "The role does not exist" and ...
Is there any way of customizing this error per state?
I think we can still have per-handler overrides for error codes, just like how we have it for 2xx or other codes. It will then override the default implementation implemented through #[api_v2_errors] macro.