Using v11.20.1 & aspnet core 2.1 in a controller marked with [ApiController], I have the following:
C#
```c#
[HttpPost, Route("save")]
public ActionResult
{
}
Swagger generated from the Swagger spec method
```json
"/api/Venue/save": {
"post": {
"tags": [
"Venue"
],
"operationId": "Venue_SaveVenue",
"consumes": [
"multipart/form-data"
],
"produces": [
"text/plain",
"application/json",
"text/json"
],
"parameters": [
{
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SaveVenueRequest"
},
"x-nullable": false
},
{
"type": "file",
"name": "logo",
"in": "formData",
"x-nullable": true
}
],
"responses": {
"200": {
"x-nullable": true,
"description": "",
"schema": {
"$ref": "#/definitions/SaveVenueResponse"
}
}
}
}
},
Which generates this in TS:
saveVenue(request: SaveVenueRequest, logo: FileParameter | null | undefined): Observable<SaveVenueResponse | null> {
let url_ = this.baseUrl + "/api/Venue/save";
url_ = url_.replace(/[?&]$/, "");
const content_ = new FormData();
if (logo !== null && logo !== undefined)
content_.append("logo", logo.data, logo.fileName ? logo.fileName : "logo");
let options_ : any = {
body: content_,
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Content-Type": "multipart/form-data",
"Accept": "application/json"
})
};
return this.http.request("post", url_, options_).pipe(_observableMergeMap((response_ : any) => {
return this.processSaveVenue(response_);
})).pipe(_observableCatch((response_: any) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.processSaveVenue(<any>response_);
} catch (e) {
return <Observable<SaveVenueResponse | null>><any>_observableThrow(e);
}
} else
return <Observable<SaveVenueResponse | null>><any>_observableThrow(response_);
}));
}
Issues:
SaveVenueRequest is not being added into content_ by the generated code.multipart/form-data content-type header (500 status code). What I have tried:
content_.append('request', JSON.stringify(request));
[FromForm] to prevent a 400 status code:c#
[HttpPost, Route("save")]
public ActionResult<SaveVenueResponse> SaveVenue([FromForm]SaveVenueRequest request, IFormFile logo)
Expectations:
Is there something that I am missing?
Looks like a bug/or not yet implemented feature...
Closing this issue.
```c#
[HttpPost, Route("branding")]
public ActionResult
{
And then inside the class have something like:
```c#
public class SaveVenueBranding {
public List<IFormFile> Files { get; set; }
public int VenueId { get; set; }
}
Typescript code is generated properly.
Nswag version: 12.0.4