Open trafreider opened 2 years ago
Welcome to a pr to help us deal with more boundary situations. Or provide a full JSON
Thanks for welcoming me.
Unfortunately, I cannot create a PR due to missing permissions. Attached find a patch in my OneDrive that solves my problem https://1drv.ms/u/s!AlOH0S0Al0lig59hIbSwkJNVHXEoVA?e=AR8uQI
The output of the generator looks as follows:
export async function updateUser(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.updateUserParams,
body: {
userData: API.UserWithPasswordData;
},
files?: File[],
options?: { [key: string]: any },
) {
const { username: param0, ...queryParams } = params;
const formData = new FormData();
if (files) {
formData.append('profilePicture', files[0] || '');
}
Object.keys(body).forEach((ele) => {
const item = (body as any)[ele];
if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
formData.append(ele, new Blob([JSON.stringify(item)], { type: 'application/json' }));
} else {
formData.append(ele, item);
}
}
});
return request<API.UserResponseData>(`/api/admin/user/${param0}`, {
method: 'PUT',
headers: {
'Content-Type': 'multipart/form-data',
},
params: { ...queryParams },
data: formData,
requestType: 'form',
...(options || {}),
});
Hi,
I having a Spring Boot application where I have a REST endpoint that consumes "multipart/form-data". The endpoint expects two file parts, the userData of type "application/json" and a profile picture of type image. Unfortunately, the openapi generator ignores the encoding of userData which leads to a HTTP 415 error in Spring. I would expect that the generator produces something like
Here's a snipptet of my swagger defintion.