swagger-typescript-api
swagger-typescript-api copied to clipboard
Added processing of array of properties
Added processing of array of properties, for adding to formData sequentially, element by element
I Have the problem
my backend contract is
/// <summary>
/// Новые фотографии автосервиса
/// </summary>
[MaxFileSize(ImageValidationConstants.MaxFileSize)]
[AllowedExtensions([".png", ".jpg", ".jpeg", ".heic"])]
public IFormFile[]? NewPhotos { get; set; }
/// <summary>
/// Фотографии, которые надо удалить
/// </summary>
public int[]? PhotoDeletionIds { get; set; }
when i send request from front
export interface UpdateCarServicePhotosPayload {
/** Новые фотографии автосервиса */
newPhotos?: File[];
/** Фотографии, которые надо удалить */
photoDeletionIds?: number[];
}
newPhotos is array of File. But in client.ts by swaggergen I get an attempt to add the entire array under one key as a single blob object
the code below doesn't work good with array of objects
formData.append(
key,
property instanceof Blob
? property
: typeof property === "object" && property !== null
? JSON.stringify(property)
: `${property}`
);