-
Notifications
You must be signed in to change notification settings - Fork 65
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
[Phase 02] Support resource functions in OpenAPI Client Generation tool #5158
Comments
Once we are going to check the feasibility of this improvement in the client resource function we encounter this ,
Other than query parameters, object can be send as a path parameter or header according to the OpenAPI 3.0 . Please find more information on related to parameter serialization in OpenAPI 3.0 here. This scenario was handled previously by introducing a util function to generate the path according to the serialization. resourcePath = resourcePath + check getPathForQueryParam(queryParam);
------------
# functions to generate query parameter path
isolated function getPathForQueryParam(map<anydata> queryParam) returns string|error {
string[] param = [];
param[param.length()] = "?";
foreach var [key, value] in queryParam.entries() {
if value is () {
_ = queryParam.remove(key);
} else {
if string:startsWith( key, "'") {
param[param.length()] = string:substring(key, 1, key.length());
} else {
param[param.length()] = key;
}
param[param.length()] = "=";
if value is string {
string updateV = check url:encode(value, "UTF-8");
param[param.length()] = updateV;
} else {
param[param.length()] = value.toString();
}
param[param.length()] = "&";
}
}
_ = param.remove(param.length()-1);
if param.length() == 1 {
_ = param.remove(0);
}
string restOfPath = string:'join("", ...param);
return restOfPath;
} but given the improvement resource method OpportunityObject response = check self.clientEp->/api/v2/opportunities.get(embed); we can't handle the parameter serialization. Therefore we have to move with the current implementation [1] resource isolated function get api/v2/opportunities(string? embed = ()) returns OpportunityObject|error {
string resourcePath = string `/api/v2/opportunities`;
map<anydata> queryParam = {"embed": embed};
resourcePath = resourcePath + check getPathForQueryParam(queryParam);
OpportunityObject response = check self.clientEp->get(resourcePath);
return response;
} |
Due to above mentioned limitation, we will close this issue, once there is a way to capture those details, this will be opened |
Description:
Parent issue: #5366
During this 2nd phase, try to improve the client resource method body with the client resource method call in below way
Current Generated code
With Improvement
The text was updated successfully, but these errors were encountered: