Skip to content

[Automated] Regenerate OpenAPI Connector #18

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,431 changes: 2,661 additions & 2,770 deletions ballerina/client.bal

Large diffs are not rendered by default.

10,090 changes: 6,846 additions & 3,244 deletions ballerina/types.bal

Large diffs are not rendered by default.

64 changes: 22 additions & 42 deletions ballerina/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// specific language governing permissions and limitations
// under the License.

import ballerina/http;
import ballerina/url;

type SimpleBasicType string|boolean|int|float|decimal;
Expand Down Expand Up @@ -74,23 +75,23 @@ isolated function getFormStyleRequest(string parent, record {} anyRecord, boolea
string[] recordArray = [];
if explode {
foreach [string, anydata] [key, value] in anyRecord.entries() {
if (value is SimpleBasicType) {
if value is SimpleBasicType {
recordArray.push(key, "=", getEncodedUri(value.toString()));
} else if (value is SimpleBasicType[]) {
} else if value is SimpleBasicType[] {
recordArray.push(getSerializedArray(key, value, explode = explode));
} else if (value is record {}) {
} else if value is record {} {
recordArray.push(getFormStyleRequest(parent, value, explode));
}
recordArray.push("&");
}
_ = recordArray.pop();
} else {
foreach [string, anydata] [key, value] in anyRecord.entries() {
if (value is SimpleBasicType) {
if value is SimpleBasicType {
recordArray.push(key, ",", getEncodedUri(value.toString()));
} else if (value is SimpleBasicType[]) {
} else if value is SimpleBasicType[] {
recordArray.push(getSerializedArray(key, value, explode = false));
} else if (value is record {}) {
} else if value is record {} {
recordArray.push(getFormStyleRequest(parent, value, explode));
}
recordArray.push(",");
Expand All @@ -110,23 +111,23 @@ isolated function getFormStyleRequest(string parent, record {} anyRecord, boolea
isolated function getSerializedArray(string arrayName, anydata[] anyArray, string style = "form", boolean explode = true) returns string {
string key = arrayName;
string[] arrayValues = [];
if (anyArray.length() > 0) {
if (style == FORM && !explode) {
if anyArray.length() > 0 {
if style == FORM && !explode {
arrayValues.push(key, "=");
foreach anydata i in anyArray {
arrayValues.push(getEncodedUri(i.toString()), ",");
}
} else if (style == SPACEDELIMITED && !explode) {
} else if style == SPACEDELIMITED && !explode {
arrayValues.push(key, "=");
foreach anydata i in anyArray {
arrayValues.push(getEncodedUri(i.toString()), "%20");
}
} else if (style == PIPEDELIMITED && !explode) {
} else if style == PIPEDELIMITED && !explode {
arrayValues.push(key, "=");
foreach anydata i in anyArray {
arrayValues.push(getEncodedUri(i.toString()), "|");
}
} else if (style == DEEPOBJECT) {
} else if style == DEEPOBJECT {
foreach anydata i in anyArray {
arrayValues.push(key, "[]", "=", getEncodedUri(i.toString()), "&");
}
Expand Down Expand Up @@ -156,7 +157,7 @@ isolated function getSerializedRecordArray(string parent, record {}[] value, str
arayIndex = arayIndex + 1;
}
} else {
if (!explode) {
if !explode {
serializedArray.push(parent, "=");
}
foreach var recordItem in value {
Expand All @@ -173,7 +174,7 @@ isolated function getSerializedRecordArray(string parent, record {}[] value, str
# + return - Encoded string
isolated function getEncodedUri(anydata value) returns string {
string|error encoded = url:encode(value.toString(), "UTF8");
if (encoded is string) {
if encoded is string {
return encoded;
} else {
return value.toString();
Expand All @@ -186,21 +187,22 @@ isolated function getEncodedUri(anydata value) returns string {
# + encodingMap - Details on serialization mechanism
# + return - Returns generated Path or error at failure of client initialization
isolated function getPathForQueryParam(map<anydata> queryParam, map<Encoding> encodingMap = {}) returns string|error {
map<anydata> queriesMap = http:getQueryMap(queryParam);
string[] param = [];
if (queryParam.length() > 0) {
if queriesMap.length() > 0 {
param.push("?");
foreach var [key, value] in queryParam.entries() {
foreach var [key, value] in queriesMap.entries() {
if value is () {
_ = queryParam.remove(key);
_ = queriesMap.remove(key);
continue;
}
Encoding encodingData = encodingMap.hasKey(key) ? encodingMap.get(key) : defaultEncoding;
if (value is SimpleBasicType) {
if value is SimpleBasicType {
param.push(key, "=", getEncodedUri(value.toString()));
} else if (value is SimpleBasicType[]) {
} else if value is SimpleBasicType[] {
param.push(getSerializedArray(key, value, encodingData.style, encodingData.explode));
} else if (value is record {}) {
if (encodingData.style == DEEPOBJECT) {
} else if value is record {} {
if encodingData.style == DEEPOBJECT {
param.push(getDeepObjectStyleRequest(key, value));
} else {
param.push(getFormStyleRequest(key, value, encodingData.explode));
Expand All @@ -215,25 +217,3 @@ isolated function getPathForQueryParam(map<anydata> queryParam, map<Encoding> en
string restOfPath = string:'join("", ...param);
return restOfPath;
}

# Generate header map for given header values.
#
# + headerParam - Headers map
# + return - Returns generated map or error at failure of client initialization
isolated function getMapForHeaders(map<any> headerParam) returns map<string|string[]> {
map<string|string[]> headerMap = {};
foreach var [key, value] in headerParam.entries() {
if value is string || value is string[] {
headerMap[key] = value;
} else if value is int[] {
string[] stringArray = [];
foreach int intValue in value {
stringArray.push(intValue.toString());
}
headerMap[key] = stringArray;
} else if value is SimpleBasicType {
headerMap[key] = value.toString();
}
}
return headerMap;
}
Loading
Loading