-
Notifications
You must be signed in to change notification settings - Fork 73
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
how to infer error responses? #145
Comments
@xblurx how do u resolve it, could u show me the code..? thanks! |
No idea about inferring error responses, but I usually explicitly add my errors to documentation by just adding ApiRouter::new()
.api_route("/whatever", get_with(whatever_handler, whatever_handler_docs))
// etc.
fn whatever_handler_docs(op: TransformOperation) -> TransformOperation {
op.summary("This endpoint does whatever")
.response::<200, Json<SomeResponse>>()
.response_with::<404, Json<ApiErrorResponse>, _>(|res| {
res.description("Whatever you're doing, it's not there")
.example(ApiError::NotFound)
})
.response_with::<500, Json<ApiErrorResponse>, _>(|res| {
res.description("Internal server error")
.example(ApiError::internal_error())
})
} where |
@netthier yeah i know it, but I was just curious about what xblurx said about "custom schema processing".
But what you say is of course helpful, and these will depend on how error handling is done in the project. |
@2vg here is the code that i used for implementing this, in other words I implemented
|
@xblurx thanks, that was i wanted! |
Hi there and thank you for this awesome tool!
In one of the projects that is using
aide
I saw that their generated json schema contained not only 200 response but all of the error responses too, however I could not achieve similar results (I am kind of new to this)I implemented
IntoResponse
from myError
enum and all of my handlers share the same behaviour. Here's a short presentation of my current setup:I'd like to see this json schema generated:
and i only have responses 200 in my case. Any help would be greatly appreciated!
EDIT:
turned out, guys from the project I was referring to implemented some custom schema processing, when those error responses were added
This can be closed, but if there is something similar in functionality in
aide
out of the box, I'll be glad to find out!The text was updated successfully, but these errors were encountered: