You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be related to issue #205 but I cannot really tell.
We have a Swagger file with an endpoint for uploading a file. Our previous service that we wrote manually worked fine. We would put the uploaded file into FormData along with some other key/value pairs.
constfiles=this.invoiceFile?.filesconstfile=files[0]constformData=newFormData()formData.append('invoice',file,file.name)constformGroupValue=this.benefitBoxFormGroup.valueconstrequestFields:BenefitRequestFields={otherKey: 'otherValue',(...)}formData.append('requestFields',JSON.stringify(requestFields))this.benefitsService.postBenefitRequest(formDataasunknownasBenefitRequestFields)(...)// method from own service:publicpostBenefitRequest(body: BenefitRequestFields): Observable<SpaProfessionalsApiResponse>{returnthis.httpClient.post<GenericResponse>(`${this.baseUrl}/benefitrequest`,body)}
When generating services with ng-swagger-gen everything worked perfectly except the upload. It looked as though there was no request payload.
When inspecting the generated code l came upon this weird bit:
Although this would not explain the empty payload, it does simply overwrite __body with the second param.
Here is an excerpt from the yaml file:
paths:
/benefits/benefitrequest:
post:
tags:
- Benefits summary: creates a benefit request for a specific goal operationId: postBenefitRequest consumes:
- multipart/form-data security:
- JwtBearerAuthentication: [ ] parameters:
- name: requestFields in: body required: trueschema:
$ref: '#/definitions/BenefitRequestFields'
- name: invoice in: body required: trueschema:
$ref: '#/definitions/BenefitRequestInvoice'
From other issue responses I gather a lack of time for support, but I'll file the issue anyway for others.
I will try to fix it myself and create a PR if I succeed. It might take a while because for now we have a workaround to the old service for this endpoint (but we will have other uploads in the future).
The text was updated successfully, but these errors were encountered:
This might be related to issue #205 but I cannot really tell.
We have a Swagger file with an endpoint for uploading a file. Our previous service that we wrote manually worked fine. We would put the uploaded file into
FormData
along with some other key/value pairs.When generating services with
ng-swagger-gen
everything worked perfectly except the upload. It looked as though there was no request payload.When inspecting the generated code l came upon this weird bit:
Although this would not explain the empty payload, it does simply overwrite
__body
with the second param.Here is an excerpt from the yaml file:
From other issue responses I gather a lack of time for support, but I'll file the issue anyway for others.
I will try to fix it myself and create a PR if I succeed. It might take a while because for now we have a workaround to the old service for this endpoint (but we will have other uploads in the future).
The text was updated successfully, but these errors were encountered: