I'm using this Result abstraction to send an appropriate message with my data. For example, I'm using the following code to return the JWT together with a welcome message:
public async Task<Result<TokenResponse>> GetTokenAsync(TokenRequest request)
{
...
return await Result<TokenResponse>.SuccessAsync(response, "Welcome Message");
}
I'm using the following endpoint to send the token to client:
[HttpPost("token")]
public async Task<ActionResult<TokenResponse>> GetTokenAsync(TokenRequest tokenRequest)
{
var token = await _identityService.GetTokenAsync(tokenRequest);
if (token.HasError)
return NotFound(token);
return Ok(token);
}
It is working correctly but when I want to generate the typeScript client proxy using NSwagStudio the generated TypeScript file doesn't contain the Result type so, I cannot have the message in client. It is generated as below:
getToken(tokenRequest: TokenRequest): Observable<TokenResponse> {
let url_ = this.baseUrl + "/api/identity/token";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(tokenRequest);
let options_ : any = {
body: content_,
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Content-Type": "application/json",
"Accept": "application/json"
})
};
return this.http.request("post", url_, options_).pipe(_observableMergeMap((response_ : any) => {
return this.processGetToken(response_);
})).pipe(_observableCatch((response_: any) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.processGetToken(response_ as any);
} catch (e) {
return _observableThrow(e) as any as Observable<TokenResponse>;
}
} else
return _observableThrow(response_) as any as Observable<TokenResponse>;
}));
}
You can see that there is nothing about Result class in the above code. Have I forgotten something? Any suggestion?