Closed
Description
Description
The changes in #6454 introduced setting the request content-type from the consumes
property.
if (consumes != null && consumes.length > 0) {
headers.set('Content-Type', consumes.filter(item => this.isJsonMime(item)).join(";"));
}
However, the content type is limited to json
-like mime types. Therefore the content-type is set to an empty string if we e.g. upload a file and have
let consumes: string[] = [
'multipart/form-data'
];
and since multipart/form-data
is not a json mime-type, this results in setting and empty string value.
This in turn, results in an invalid content-type header being set, as explained e.g. here: angular/angular#11819
Content-Length: 315
Content-Type: , multipart/form-data; boundary=----WebKitFormBoundarys7BwSTvRA7Nf3WwQ
Host: petstore.swagger.io
This breaks e.g. the PetStore.uploadFile() API in the petStore example:
Swagger-codegen version
2.3.0
Swagger declaration file content or url
See the petstore example
Command line used for generation
Steps to reproduce
Related issues/PRs
Maybe this is resolved with #6080
Suggest a fix/enhancement
Do not restrict the conten-type to json mime types.
Let angular detect the content-type automatically from the data.