tamasfe / aide

An API documentation library
Apache License 2.0
418 stars 70 forks source link

Return Json error with status code #71

Closed IgnisDa closed 1 year ago

IgnisDa commented 1 year ago

Thanks for this awesome project! The examples are a bit lacking on how to work with returning errors and status code.

For example I have a handler:

#[axum::debug_handler]
pub async fn create_user(
    State(pool): State<PgPool>,
    Json(user): Json<CreateUserInput>,
) -> Result<(StatusCode, Json<CreateUserOutput>), (StatusCode, Json<CreateUserOutputError>)> {
}

This raises errors. I could be doing something wrong and would be glad if someone could guide me.

Wicpar commented 1 year ago

Can you provide the error? It's likely that your struct does not derive JsonSchema

IgnisDa commented 1 year ago

I got this working in a different way, thanks for responding.