okapi icon indicating copy to clipboard operation
okapi copied to clipboard

The trait bound `rocket::fs::TempFile<'_>: rocket_okapi::JsonSchema` is not satisfied [E0277]

Open sawa-ko opened this issue 1 year ago • 0 comments

I am trying to make an endpoint that receives a file in a multipart formdata, but when I try to put the type for the argument in the function I get the following error:

Error

the trait bound `rocket::fs::TempFile<'_>: rocket_okapi::JsonSchema` is not satisfied [E0277] the trait `rocket_okapi::JsonSchema` is not implemented for `rocket::fs::TempFile<'_>`, which is required by `rocket::form::Form<rocket::fs::TempFile<'_>>: rocket_okapi::request::OpenApiFromData<'_>` Help: the following other types implement trait `rocket_okapi::JsonSchema`: &'a T &'a mut T () (T0, T1) (T0, T1, T2) (T0, T1, T2, T3) (T0, T1, T2, T3, T4) (T0, T1, T2, T3, T4, T5) and 164 others Note: required for `rocket::form::Form<rocket::fs::TempFile<'_>>` to implement `rocket_okapi::request::OpenApiFromData<'_>`

Code

#[openapi(tag = "User")]
#[patch("/change-profile-picture", data = "<file>")]
pub async fn change_profile_picture(
    conn: Connection<'_, Db>, jwt_guard: JwtGuard, file: Form<TempFile<'_>>, minio: &State<MinioStorage>,
) -> Result<Status, Error> {
    // Rust code...
}
rocket = { version = "0.5.1", features = ["serde_json", "secrets", "json"] }
schemars = { version = "0.8.21", features = ["uuid1", "impl_json_schema", "chrono", "derive_json_schema", "derive"] }
rocket_okapi = { version = "0.9.0", features = ["secrets", "rapidoc", "rocket_db_pools", "uuid"] }

sawa-ko avatar Dec 30 '24 19:12 sawa-ko