Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sawa-ko opened this issue Dec 30, 2024 · 0 comments

Comments

@sawa-ko
Copy link

sawa-ko commented Dec 30, 2024

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"] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant