Skip to content

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

Description

@sawa-ko

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"] }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions