-
Greetings. Firstly, I want to apologize for hasty created topic in issues section. Here it is, it can be deleted. That's my first time in discussions/issues. Currently I have two problems and I'll try to describe it as full as I can.
(Tried to use struct here, but I think there is solution that uses axum::extract::Multipart, cause it's doesnt allow me to upload concrete file from swagger) #[derive(ToSchema)]
struct TestForm {
#[schema(content_media_type = "application/octet-stream")]
file_bytes: Vec<u8>
}
#[utoipa::path(
tag = "USER",
post,
path = "/create",
responses(
(status = 200, description = "Done")
),
request_body(content = TestForm, content_type = "multipart/form-data")
)]
#[debug_handler]
async fn user_post(data: TestForm) -> impl IntoResponse {
return StatusCode::OK
} and now I have this: #[utoipa::path(
tag = USER,
path = "/create",
post,
responses(
(status = 200, description = "User created successfully!"),
(status = 400, description = "Unsupported entity"),
(status = 401, description = "Server token doesn't provided!")
),
security(
("server_token" = [])
),
//request_body(content="multipart/form-data", content-type = Multipart?)
)]
async fn post_user(db: State<Arc<Pool>>, mut data: Multipart) -> impl IntoResponse {
...
}
//main.rs
let (router, api) = (...).nest("/user", user_routes)
//user_handler.rs
pub fn user_routes() -> OpenApiRouter {
OpenApiRouter::new().routes(routes!(
user_post_1, //errors
user_post_2 //errors
))
} Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
So, after a week of mind pain, I have found out this: ...
OpenApiRouter::new().routes(routes!(get_first)).routes(routes!(get_second))...
... Idk why, but I also created a topic on stackoverflow. There u can see raw axum example where nesting routes.. Working. Idk why, but it seems like and issue that utoipa can't see my paths attributes differences and started yelling at that after compilation.. So, I hope this will be fixed, because it's not cool. (Like, in other frameworks this works fine, and here too, but.. I want to make documentation.. ) |
Beta Was this translation helpful? Give feedback.
I just added couple of examples on how to define multipart form uploads. https://github.com/juhaku/utoipa/tree/master/examples/axum-multipart https://github.com/juhaku/utoipa/tree/master/examples/actix-web-multipart
For what comes to 2. problem, it is same issue as here: #1183 (comment). In short the
routes!
macro call is single axumMethodRouter
which allows only single handler per http method.Hope these will get you forward.