Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a DefaultStatusCodeResponse in the http module #6491

Closed
TharmiganK opened this issue May 6, 2024 · 0 comments · Fixed by ballerina-platform/module-ballerina-http#2002
Assignees
Labels
module/http Team/PCM Protocol connector packages related issues Type/Improvement

Comments

@TharmiganK
Copy link
Contributor

Description:

Introduce a status code response record type to map default responses which is described in the OpenAPI specification.

Describe your problem(s)

With the introduction of StatusCodeClient, the response can be mapped to one of the StatusCodeResponse type - This is a union of predefined status code response records.

If there is a response with the status code which is not defined by the user, then that is mapped to an error - ApplicationResponseError and the response body and headers can be found in the details map of this particular error type.

But when we consider the OpenAPI specification, it is common to represent the multiple error response to a default status code response with a defined response body schema. Currently we cannot represent this directly in the client call. Users has to extract the error and get the error details to build the default response.

http:StatusCodeClient clientEP = check new("localhost:9090/api");
OkAlbumArray|error res = clientEP->/albums;

if res is http:ApplicationResponseError {
    http:Detail details = res.detail();
}

Describe your solution(s)

As a solution, we can introduce a new status code response record - DefaultStatusCodeResponse which can be used to map all the other status code responses which are not defined by the user.

http:StatusCodeClient clientEP = check new("localhost:9090/api");
OkAlbumArray|DefaultStatusCodeResponse|error res = clientEP->/albums;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/http Team/PCM Protocol connector packages related issues Type/Improvement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant