juhaku / utoipa

Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust
Apache License 2.0
2.48k stars 194 forks source link

Document may not be right #1054

Closed ipconfiger closed 3 weeks ago

ipconfiger commented 2 months ago

in : Doc

It is possible to specify the title of each variant to help generators create named structures.

#[derive(ToSchema)]
enum ErrorResponse {
    #[schema(title = "InvalidCredentials")]
    InvalidCredentials,
    #[schema(title = "NotFound")]
    NotFound(String),
}

but build will fault:

   --> src/response.rs:133:14
    |
133 |     #[schema(title="Token String")]
    |              ^^^^^

Cargo.toml

utoipa = { version = "4.2.3", features = ["axum_extras"] }
utoipa-rapidoc = { version = "4", features = ["axum"] }

What i miss?

juhaku commented 1 month ago

@ipconfiger Indeed the docs might be incorrect, and in 4.x.x version there are lot of inconsistencies in enum schema processing. This is being fixed in PR #1059. Yet if you have only a plain enum having only unit variants, then title is not supported, see more details here: https://github.com/juhaku/utoipa/issues/954

juhaku commented 3 weeks ago

@ipconfiger I belive this has been solved with the 5.0.0 release. If you encounter more issues this can of course be reopened but for now closing.