cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
396 stars 132 forks source link

File Upload: Allow to set values like contentType in RequestBuilder.body or options.reportProgress in RequestBuilder.build #259

Open ophirKatz opened 1 year ago

ophirKatz commented 1 year ago

Hi! I'm trying to implement file upload in my application, using the Blob type. Specifically, I have a request body object that contains some normal fields and one File field:

interface FileUploadRequest {
  name: string;
  file: File;
}

I want to use the generated http service in order to send this request, but I need to use FormData to send the file. The RequestBuilder supports Blob types and can create a FormData object with all fields, but only via the rb.body method. But, the service does not expose a parameter to override the body's content type (which controls whether FormData is used or not - 'multipart/form-data'), and the default is 'application/json'. Moreover, I'd like to override the value for reportProgress in the options object passed to rb.build, but again - not possible.

Any ideas is this is possible? Or how it can be done using the generated code?

Thank you!

luisfpg commented 1 year ago

Can you post the OpenAPI descriptor for the operation? Seems like you're not mapping the content type in the requestBody element