Skip to content

Commit 5bd7366

Browse files
committed
fix openapi spec
1 parent 8162bf7 commit 5bd7366

4 files changed

Lines changed: 59 additions & 59 deletions

File tree

openapi.json

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "",
88
"identifier": "MIT"
99
},
10-
"version": "0.8"
10+
"version": "0.9"
1111
},
1212
"paths": {
1313
"/api/v1/template": {
@@ -314,7 +314,7 @@
314314
"/api/v1/upload": {
315315
"post": {
316316
"tags": [
317-
"upload::routes"
317+
"upload::routes::streamupload"
318318
],
319319
"operationId": "upload",
320320
"parameters": [
@@ -395,7 +395,7 @@
395395
"/api/v1/upload/download": {
396396
"get": {
397397
"tags": [
398-
"upload::routes"
398+
"upload::routes::fetch-by-id"
399399
],
400400
"operationId": "download",
401401
"parameters": [
@@ -427,9 +427,9 @@
427427
"/api/v1/upload/download-bulk": {
428428
"post": {
429429
"tags": [
430-
"upload::routes"
430+
"upload::routes::download-bulk"
431431
],
432-
"operationId": "download_bulk",
432+
"operationId": "download-bulk",
433433
"requestBody": {
434434
"content": {
435435
"application/json": {
@@ -459,9 +459,9 @@
459459
"/api/v1/upload/find-all": {
460460
"get": {
461461
"tags": [
462-
"upload::routes"
462+
"upload::routes::fetch-all"
463463
],
464-
"operationId": "find_all_uploads",
464+
"operationId": "find-all",
465465
"parameters": [
466466
{
467467
"name": "correlationId",
@@ -495,7 +495,7 @@
495495
"/api/v1/upload/metadata": {
496496
"get": {
497497
"tags": [
498-
"upload::routes"
498+
"upload::routes::metadata"
499499
],
500500
"operationId": "metadata",
501501
"parameters": [
@@ -525,7 +525,7 @@
525525
"/api/v1/upload/ping": {
526526
"get": {
527527
"tags": [
528-
"upload::routes"
528+
"upload::routes::ping"
529529
],
530530
"operationId": "ping",
531531
"responses": {
@@ -538,9 +538,9 @@
538538
"/api/v1/upload/{id}": {
539539
"delete": {
540540
"tags": [
541-
"upload::routes"
541+
"upload::routes::upl-delete"
542542
],
543-
"operationId": "delete_by_id",
543+
"operationId": "delete",
544544
"parameters": [
545545
{
546546
"name": "id",
@@ -561,9 +561,9 @@
561561
"/api/v1/upload/{id}/make-thumb": {
562562
"post": {
563563
"tags": [
564-
"upload::routes"
564+
"upload::routes::make-thumb"
565565
],
566-
"operationId": "make_thumb",
566+
"operationId": "make-thumb",
567567
"parameters": [
568568
{
569569
"name": "id",
@@ -598,43 +598,10 @@
598598
"/api/v1/upload/{id}/update": {
599599
"post": {
600600
"tags": [
601-
"upload::routes"
601+
"upload::routes::upload-update"
602602
],
603603
"operationId": "upload_update",
604604
"parameters": [
605-
{
606-
"name": "correlation_id",
607-
"in": "path",
608-
"required": true,
609-
"schema": {
610-
"type": [
611-
"string",
612-
"null"
613-
]
614-
}
615-
},
616-
{
617-
"name": "is_public",
618-
"in": "path",
619-
"required": true,
620-
"schema": {
621-
"type": [
622-
"boolean",
623-
"null"
624-
]
625-
}
626-
},
627-
{
628-
"name": "without_thumbnail",
629-
"in": "path",
630-
"required": true,
631-
"schema": {
632-
"type": [
633-
"boolean",
634-
"null"
635-
]
636-
}
637-
},
638605
{
639606
"name": "id",
640607
"in": "path",
@@ -654,11 +621,8 @@
654621
],
655622
"properties": {
656623
"files": {
657-
"type": "array",
658-
"items": {
659-
"type": "string",
660-
"format": "binary"
661-
},
624+
"type": "string",
625+
"format": "binary",
662626
"contentMediaType": "application/octet-stream"
663627
}
664628
}
@@ -819,6 +783,19 @@
819783
"format": "binary",
820784
"contentMediaType": "*/*"
821785
},
786+
"OpenApiDocUploadFormSimpleFile": {
787+
"type": "object",
788+
"required": [
789+
"files"
790+
],
791+
"properties": {
792+
"files": {
793+
"type": "string",
794+
"format": "binary",
795+
"contentMediaType": "application/octet-stream"
796+
}
797+
}
798+
},
822799
"RenderRequest": {
823800
"type": "object",
824801
"required": [

src/common/util.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ pub struct OpenApiDocUploadForm {
1818
#[schema(content_media_type = "application/octet-stream", format = "binary", value_type = Vec<String>)]
1919
pub files: Vec<String>,
2020
}
21-
21+
#[derive(utoipa::ToSchema)]
22+
#[allow(unused)]
23+
pub struct OpenApiDocUploadFormSimpleFile {
24+
#[schema(content_media_type = "application/octet-stream", format = "binary", value_type = String)]
25+
pub files: String,
26+
}
2227
pub fn setup_tracing() -> Result<(), Box<dyn Error>> {
2328
let offset_hours = {
2429
let now = Local::now();

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use upload::domain::{
2020
use utoipa::{Modify, OpenApi};
2121
use utoipa_swagger_ui::SwaggerUi;
2222

23-
use crate::{template::render, upload::domain::DownloadBulkRequestUriParams};
23+
use crate::{common::util::OpenApiDocUploadFormSimpleFile, template::render, upload::domain::DownloadBulkRequestUriParams};
2424

2525
mod common;
2626
mod store;
@@ -49,8 +49,8 @@ impl FromRef<AppState> for TemplRouterState {
4949
}
5050
#[derive(OpenApi)]
5151
#[openapi(
52-
info(description = "File Api V1", title="FileApi",version="0.8", license(identifier="MIT")),
53-
components(schemas(TemplateType,OpenApiBinaryResponse, FileUploadV2,FindAllQueryParams, TemplateV2,UploadFileRequestUriParams, DownloadBulkRequestUriParams,DownloadFileRequestUriParams, Context,TemplateUpsert)),
52+
info(description = "File Api V1", title="FileApi",version="0.9", license(identifier="MIT")),
53+
components(schemas(TemplateType,OpenApiBinaryResponse,OpenApiDocUploadFormSimpleFile, FileUploadV2,FindAllQueryParams, TemplateV2,UploadFileRequestUriParams, DownloadBulkRequestUriParams,DownloadFileRequestUriParams, Context,TemplateUpsert)),
5454
paths(
5555
upload::routes::metadata,
5656
upload::routes::make_thumb,

src/upload/routes.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tokio_util::io::ReaderStream;
1818
use crate::common::constant::{DEFAULT_TENANT, FILE_SERVICE_COLLECTION_NAME, TMP_FS_PATH};
1919
use crate::common::domain::ServiceError;
2020
use crate::common::util::{
21-
IdGenerator, OpenApiBinaryResponse, OpenApiDocUploadForm, StoreCollection,
21+
IdGenerator, OpenApiBinaryResponse, OpenApiDocUploadForm, OpenApiDocUploadFormSimpleFile, StoreCollection
2222
};
2323
use crate::store::{Repository, StoreClient, StoreRepository};
2424
use crate::upload::domain::{DownloadBulkRequestUriParams, FindAllQueryParams};
@@ -39,6 +39,8 @@ pub async fn make_state(client: StoreClient) -> Result<FileRouterState, Box<dyn
3939
#[utoipa::path(
4040
get,
4141
path = "/api/v1/upload/metadata",
42+
tags = ["upload::routes::metadata"],
43+
operation_id = "metadata",
4244
params(DownloadFileRequestUriParams),
4345
responses(
4446
(status = 200, description = "Get upload metadata", body=FileUploadV2)
@@ -64,6 +66,8 @@ pub async fn metadata(
6466
#[utoipa::path(
6567
post,
6668
path = "/api/v1/upload/download-bulk",
69+
tags = ["upload::routes::download-bulk"],
70+
operation_id = "download-bulk",
6771
request_body=DownloadBulkRequestUriParams,
6872
responses(
6973
(status = 200, description = "Download multiple files as a zip",content_type = "*/*",body=inline(OpenApiBinaryResponse))
@@ -114,6 +118,8 @@ pub async fn download_bulk(
114118
#[utoipa::path(
115119
get,
116120
path = "/api/v1/upload/download",
121+
tags = ["upload::routes::fetch-by-id"],
122+
operation_id = "download",
117123
params(DownloadFileRequestUriParams),
118124
responses(
119125
(status = 200, description = "Download file",content_type = "*/*",body=inline(OpenApiBinaryResponse))
@@ -165,6 +171,8 @@ pub async fn download(
165171
#[utoipa::path(
166172
get,
167173
path = "/api/v1/upload/find-all",
174+
tags = ["upload::routes::fetch-all"],
175+
operation_id = "find-all",
168176
params(FindAllQueryParams),
169177
responses(
170178
(status = 200, description = "Find all upload", body=Vec<FileUploadV2>)
@@ -197,6 +205,8 @@ pub async fn find_all_uploads(
197205
#[utoipa::path(
198206
delete,
199207
path = "/api/v1/upload/{id}",
208+
tags = ["upload::routes::upl-delete"],
209+
operation_id = "delete",
200210
responses(
201211
(status = 200, description = "Delete a file by id")
202212
),
@@ -234,6 +244,8 @@ pub async fn delete_by_id(
234244
#[utoipa::path(
235245
get,
236246
path = "/api/v1/upload/ping",
247+
tags = ["upload::routes::ping"],
248+
operation_id = "ping",
237249
responses(
238250
(status = 200, description = "Ping")
239251
),
@@ -245,6 +257,8 @@ pub async fn ping() -> impl IntoResponse {
245257
#[utoipa::path(
246258
post,
247259
path = "/api/v1/upload/{id}/make-thumb",
260+
tags = ["upload::routes::make-thumb"],
261+
operation_id = "make-thumb",
248262
responses(
249263
(status = 200, description = "Make thumbnail", body=Option<FileUploadV2>)
250264
),
@@ -295,8 +309,10 @@ pub async fn make_thumb(
295309
#[utoipa::path(
296310
post,
297311
path = "/api/v1/upload/{id}/update",
298-
params(UploadFileRequestUriParams),
299-
request_body(content = inline(OpenApiDocUploadForm), content_type = "multipart/form-data"),
312+
tags = ["upload::routes::upload-update"],
313+
operation_id = "update",
314+
operation_id = "upload_update",
315+
request_body(content = inline(OpenApiDocUploadFormSimpleFile), content_type = "multipart/form-data"),
300316
responses(
301317
(status = 200, description = "Upload a file", body=FileUploadV2)
302318
),
@@ -368,6 +384,8 @@ pub async fn upload_update(
368384
#[utoipa::path(
369385
post,
370386
path = "/api/v1/upload",
387+
tags = ["upload::routes::streamupload"],
388+
operation_id = "upload",
371389
params(UploadFileRequestUriParams),
372390
request_body(content = inline(OpenApiDocUploadForm), content_type = "multipart/form-data"),
373391
responses(

0 commit comments

Comments
 (0)