Closed wilds closed 2 years ago
好久没见到多文件上传了,可以贴一下生成的样子吗
Multiple files upload
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"obj": {
"$ref": "#/components/schemas/ObjDto"
},
"docs": {
"type": "array",
"items": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
}
produces:
export async function updateObj(
params: API.updateObjParams,
body: {
obj: API.ObjDto;
},
docs?: File[],
options?: { [key: string]: any },
) {
const { id: param0, ...queryParams } = params;
const formData = new FormData();
if (docs) {
docs.forEach((f) => formData.append('docs', f || ''));
}
...
Single file upload
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"obj": {
"$ref": "#/components/schemas/ObjDto"
},
"docs": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
produces:
export async function updateObj(
params: API.updateObjParams,
body: {
obj: API.ObjDto;
},
file?: File,
options?: { [key: string]: any },
) {
const { id: param0, ...queryParams } = params;
const formData = new FormData();
if (file) {
formData.append('file', file);
}
...
"docs": { "type": "array", "items": { "type": "string", "format": "binary" } }