0
michaelhilgers created
Hi,
I created a service with an whose has got a function with a class as input.
public async Task<ListResultDto<ArbeitszeitListDto>> GetArbeitszeitenAsync(ArbeitszeitenInputDto input)
{
}
The input class "ArbeitszeitenInputDto" looks like
public class ArbeitszeitenInputDto
{
public int? MitarbeiterId { get; set; }
public int? MaschineId { get; set; }
public string Filter { get; set; }
[Required]
public DateTime StartDatum { get; set; }
[Required]
public DateTime EndDatum { get; set; }
}
But only for this class, nswag doesn't gernerate a class. For all the other classes I created it worked fine.
=> Angular2 => service-proxies.ts generated code:
/**
* @return Success
*/
getArbeitszeitenAsync(mitarbeiterId: number, maschineId: number, filter: string, startDatum: moment.Moment, endDatum: moment.Moment): Observable<ListResultDtoOfArbeitszeitListDto> {
let url_ = this.baseUrl + "/api/services/app/Arbeitszeit/GetArbeitszeitenAsync?";
if (mitarbeiterId !== undefined)
url_ += "MitarbeiterId=" + encodeURIComponent("" + mitarbeiterId) + "&";
if (maschineId !== undefined)
url_ += "MaschineId=" + encodeURIComponent("" + maschineId) + "&";
if (filter !== undefined)
url_ += "Filter=" + encodeURIComponent("" + filter) + "&";
if (startDatum !== undefined)
url_ += "StartDatum=" + encodeURIComponent("" + startDatum.toJSON()) + "&";
if (endDatum !== undefined)
url_ += "EndDatum=" + encodeURIComponent("" + endDatum.toJSON()) + "&";
const content_ = "";
return this.http.request(url_, {
body: content_,
method: "get",
headers: new Headers({
"Content-Type": "application/json; charset=UTF-8",
"Accept": "application/json; charset=UTF-8"
})
}).map((response) => {
return this.processGetArbeitszeitenAsync(response);
}).catch((response: any, caught: any) => {
if (response instanceof Response) {
try {
return Observable.of(this.processGetArbeitszeitenAsync(response));
} catch (e) {
return <Observable<ListResultDtoOfArbeitszeitListDto>><any>Observable.throw(e);
}
} else
return <Observable<ListResultDtoOfArbeitszeitListDto>><any>Observable.throw(response);
});
}
Is there somewhere a mistake or why didn't the nswag generate a class from it ?
Greatings,
1 Answer(s)
-
0
Hi,
NSwag does not generate input classes for the methods called with Http GET. The paremeters are added to query string in that case.
So, this is the expected behaviour.