-
Notifications
You must be signed in to change notification settings - Fork 25
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
Open APi spec file upload #80
Comments
Considering that the file data comes from a Would an addition of a #[post("/v1/resource/{id}/version/{version}")]
#[openapi(request(content = "image/png", schema = "Binary<String>"))]
pub async fn upload(
id: String,
version: String,
#[filter = "multipart"] file_info: FileInfo) {
...
}``` |
On the other side, a more "rweb-y" way to do it would be to Something like this: impl FromRequest for FileInfo {
type Filter = BoxedFilter<(FileInfo,)>;
fn is_body() -> bool {
true
}
fn content_type() -> &'static str {
"image/png"
}
fn new() -> Self::Filter {
rweb::header::<Mime>("content-type")
.and(rweb::body::stream())
.and_then(get_file_from_form)
.recover(handle_rejection)
.unify().boxed()
}
}
#[post("/v1/resource/{id}/version/{version}")]
#[openapi(
id = "resource.upload",
description = "Uploads a resource",
summary = "Uploads a resource"
)]
pub async fn upload(
id: String,
version: String,
file_info: FileInfo) {
...
} |
Seems like a good idea to me. i'm using rweb in work, and I'll see if it works well. |
Since |
I have a multipart upload working just fine using a
#[filter = "function"]
on a request. Is there a way to add the open api spec for a file upload?id
andversion
are documented just fine. The code looks roughly like this...The text was updated successfully, but these errors were encountered: