juhaku / utoipa

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

todo-axum example, do not work for query parameters #728

Open mygitcsv opened 1 year ago

mygitcsv commented 1 year ago

TODO example for axum does not work. The generated page for Query parameters is not correct. utoipa = "3.4.4" utoipa-swagger-ui = { version = "3.1.5", features = ["axum"] } L{XABJE)O7ULFUA2H6DKC6H

GunnarMorrigan commented 1 week ago

I am also running into this issue. Not sure how it can be solved if at all.

@juhaku

edit: Add the following to the struct #[into_params(parameter_in = Query)]

juhaku commented 1 week ago

@GunnarMorrigan that is the solution. However I believe that you have axum_extras feature flag enabled from utoipa and handler that looks like this:

#[derive(IntoParams)]
struct Params {...}

async fn handler(query: Query<Params>) {...}

You should be see those parameters in query parameters by default. But if not the adding #[into_params(parameter_in = Query)] fill set those fields as query parameters.