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
Right now, if a service responds with an http status code other than 20x, the reply gets lost, given that the ..Adapter.SendFormDataArray() returns a $$$EnsErrHTTPStatus status, causing the client to abort.
In a case where the openapi specification specified non-20x status codes, this should not happen:
/// http status code = 400 content-type = application/json
///
Property AccessTokenRequestFailedResponse As Nuts.Api.Auth.model.AccessTokenRequestFailedResponse;
/// http status code = 200 content-type = application/json
///
Property AccessTokenResponse As Nuts.Api.Auth.model.AccessTokenResponse;
/// Implement operationId : createAccessToken
/// post /n2n/auth/v1/accesstoken
Method LoadFromResponse(httpResponse As %Net.HttpResponse, caller As %String = "") As %Status
{
Set sc = $$$OK
Do ##super(httpResponse, caller)
If $$$LOWER($Piece(httpResponse.ContentType,";",1))="application/json",httpResponse.StatusCode = "200" {
Set ..AccessTokenResponse = ##class(Nuts.Api.Auth.model.AccessTokenResponse).%New()
Do ..AccessTokenResponse.%JSONImport(httpResponse.Data)
Return sc
}
If $$$LOWER($Piece(httpResponse.ContentType,";",1))="application/json",httpResponse.StatusCode = "400" {
Set ..AccessTokenRequestFailedResponse = ##class(Nuts.Api.Auth.model.AccessTokenRequestFailedResponse).%New()
Do ..AccessTokenRequestFailedResponse.%JSONImport(httpResponse.Data)
Return sc
}
Quit sc
}
Buth the 400-code path is never executed!
To properly handle the non-20x codes, the code generation must be changed for BO
For the BO, I propose the following new code:
/// Create an access token using a JWT as authorization grant
/// Implement operationId : createAccessToken
/// post /n2n/auth/v1/accesstoken
Method createAccessToken(requestMessage As Nuts.Api.Auth.requests.createAccessToken, Output responseMessage As Nuts.Api.Auth.responses.createAccessToken) As %Status
{
set responseMessage = ##class(Nuts.Api.Auth.responses.createAccessToken).%New()
return ..HandleRequest(requestMessage, "createAccessToken", responseMessage)
}
Where handlerequest is a common method that has the following code:
/// Common request handler
Method HandleRequest(requestMessage As Ens.Request, name As %String, responseMessage As Nuts.Api.Common.responses.GenericResponse) As %Status
{
Set sc = $$$OK, pHttpRequestIn = ##class(%Net.HttpRequest).%New()
$$$QuitOnError(requestMessage.LoadHttpRequestObject(pHttpRequestIn))
set sc = ..Adapter.SendFormDataArray(.pHttpResponse, "post", pHttpRequestIn, , , ..Adapter.URL_requestMessage.%URL)
if $$$ISERR(sc) && ($SYSTEM.Status.GetErrorCodes(sc) '= $$$EnsErrHTTPStatus)
{
return sc
}
if $ISOBJECT(pHttpResponse)
{
$$$TRACE(name _" returned " _ pHttpResponse.StatusCode)
$$$QuitOnError(responseMessage.LoadFromResponse(pHttpResponse, name))
}
return sc
}
This is an issue only for the BusinessOperation, the HttpClient works as expected
The text was updated successfully, but these errors were encountered:
Right now, if a service responds with an http status code other than 20x, the reply gets lost, given that the ..Adapter.SendFormDataArray() returns a $$$EnsErrHTTPStatus status, causing the client to abort.
In a case where the openapi specification specified non-20x status codes, this should not happen:
The LoadFromResponse is well-genarated:
Buth the 400-code path is never executed!
To properly handle the non-20x codes, the code generation must be changed for BO
For the BO, I propose the following new code:
Where handlerequest is a common method that has the following code:
This is an issue only for the BusinessOperation, the HttpClient works as expected
The text was updated successfully, but these errors were encountered: