Skip to content

Commit

Permalink
Merge pull request #5354 from dilanSachi/fix-openapi
Browse files Browse the repository at this point in the history
Update dependency versions and update openapi test case
  • Loading branch information
SasinduDilshara committed Apr 20, 2024
2 parents 9c06a54 + 371e1cf commit 89b4aae
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 49 deletions.
43 changes: 20 additions & 23 deletions ballerina-test/src/test/resources/openapi/expected/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ type Encoding record {
};

enum EncodingStyle {
DEEPOBJECT,
FORM,
SPACEDELIMITED,
PIPEDELIMITED
DEEPOBJECT, FORM, SPACEDELIMITED, PIPEDELIMITED
}

final Encoding & readonly defaultEncoding = {};
Expand All @@ -31,7 +28,7 @@ final Encoding & readonly defaultEncoding = {};
# + encodingMap - Includes the information about the encoding mechanism
# + anyRecord - Record to be serialized
# + return - Serialized request body or query parameter as a string
isolated function createFormURLEncodedRequestBody(record {|anydata...; |} anyRecord, map<Encoding> encodingMap = {}) returns string {
isolated function createFormURLEncodedRequestBody(record {|anydata...;|} anyRecord, map<Encoding> encodingMap = {}) returns string {
string[] payload = [];
foreach [string, anydata] [key, value] in anyRecord.entries() {
Encoding encodingData = encodingMap.hasKey(key) ? encodingMap.get(key) : defaultEncoding;
Expand Down Expand Up @@ -89,23 +86,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 @@ -125,23 +122,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 @@ -171,7 +168,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 @@ -188,7 +185,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 @@ -202,20 +199,20 @@ isolated function getEncodedUri(anydata value) returns string {
# + return - Returns generated Path or error at failure of client initialization
isolated function getPathForQueryParam(map<anydata> queryParam, map<Encoding> encodingMap = {}) returns string|error {
string[] param = [];
if (queryParam.length() > 0) {
if queryParam.length() > 0 {
param.push("?");
foreach var [key, value] in queryParam.entries() {
if value is () {
_ = queryParam.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 Down
52 changes: 26 additions & 26 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ group=org.ballerinalang
version=2201.9.0-SNAPSHOT
codeName=swan-lake

ballerinaLangVersion=2201.9.0-20240410-095500-2653a74d
ballerinaLangVersion=2201.9.0-20240419-152500-bd530dd2
ballerinaJreVersion=2.0.0
dependencyJREVersion=jdk-17.0.7+7-jre
specVersion=2023R1
Expand All @@ -23,14 +23,14 @@ stdlibMathVectorVersion=1.0.2


# Stdlib Level 02
stdlibAvroVersion=0.1.1
stdlibAvroVersion=0.1.2-20240419-195200-316bb81
stdlibConstraintVersion=1.5.0
stdlibCryptoVersion=2.7.0-20240410-140300-72e9adb
stdlibCryptoVersion=2.7.0-20240419-184200-7bc2693
stdlibDataXmldataVersion=0.1.0-20240409-100100-f7b8da6
stdlibLogVersion=2.9.0
stdlibOsVersion=1.8.0
stdlibProtobufVersion=1.6.0
stdlibPersistVersion=1.3.0-20240409-100100-594c874
stdlibPersistVersion=1.3.0-20240419-184000-8f2bc69
stdlibRandomVersion=1.5.0
stdlibTaskVersion=2.5.0
stdlibXsltVersion=2.6.0
Expand All @@ -41,56 +41,56 @@ stdlibCacheVersion=3.8.0-20240409-101100-e2d7f4e
stdlibFileVersion=1.9.0
stdlibFtpVersion=2.9.1
stdlibMimeVersion=2.9.0
stdlibTcpVersion=1.10.0-20240410-152800-5c1e336
stdlibTcpVersion=1.10.0-20240419-212300-bbbdd7a
stdlibUdpVersion=1.9.2-20240409-135000-f17730b
stdlibUuidVersion=1.8.0-20240410-145100-af1ecf4
stdlibUuidVersion=1.8.0-20240419-205800-699c1b6

# Stdlib Level 04
stdlibAuthVersion=2.11.0-20240410-152000-921da1b
stdlibDataJsondataVersion=0.1.0-20240410-220600-4b50095
stdlibAuthVersion=2.11.0-20240419-212200-83c312b
stdlibDataJsondataVersion=0.1.0-20240419-214600-d9ba31c
stdlibEdiVersion=1.2.0
stdlibEmailVersion=2.9.0
stdlibJwtVersion=2.11.0-20240410-151900-e59bad3
stdlibMqttVersion=1.1.0-20240410-153100-4c795ac
stdlibOAuth2Version=2.11.0-20240410-152000-5b650e4
stdlibJwtVersion=2.11.0-20240419-212200-853ba89
stdlibMqttVersion=1.1.0-20240419-212100-ad02e34
stdlibOAuth2Version=2.11.0-20240419-212300-79a26ae
stdlibTomlVersion=0.5.1
stdlibYamlVersion=0.5.3

# Stdlib Level 05
stdlibHttpVersion=2.11.0-20240410-161700-e275cb8
stdlibHttpVersion=2.11.0-20240419-221600-aa2f91a

# Stdlib Level 06
stdlibGrpcVersion=1.11.0-20240410-172500-b48998b
stdlibSoapVersion=0.11.0-20240410-203700-68f4107
stdlibTransactionVersion=1.9.0-20240410-194000-a082909
stdlibWebsocketVersion=2.11.0-20240410-173300-a8abbdf
stdlibWebsubVersion=2.11.0-20240410-194100-a032df4
stdlibWebsubhubVersion=1.11.0-20240410-194000-a9c543b
stdlibGrpcVersion=1.11.0-20240419-232400-1d637b4
stdlibSoapVersion=0.11.0-20240419-232200-c950703
stdlibTransactionVersion=1.9.0-20240420-020300-e5fd3f0
stdlibWebsocketVersion=2.11.0-20240419-233300-6085b97
stdlibWebsubVersion=2.11.0-20240420-020300-5c5c52e
stdlibWebsubhubVersion=1.11.0-20240420-020200-060dc9f

# Stdlib Level 07
stdlibGraphqlVersion=1.12.0-20240415-181000-9ebb287
stdlibSqlVersion=1.13.0-20240410-205900-22f19c6
stdlibGraphqlVersion=1.12.0-20240420-061500-c53712e
stdlibSqlVersion=1.13.0-20240420-061500-e8afd44

# Persist Tool
persistToolVersion=1.3.0-20240417-111300-eb2b36a
persistToolVersion=1.3.0-20240420-100200-586e893

# Dev Tools
devToolsVersion=1.4.0-20240415-182300-76be9c5
devToolsVersion=1.4.0-20240420-103500-d850d74
ballerinaCommandVersion=1.4.2

# GraphQL Tool
graphqlToolVersion=0.10.0-20240415-183000-e62693e
graphqlToolVersion=0.10.0-20240420-075700-8ced225

# Protoc Tool
protocToolVersion=0.2.0

# OpenAPI Module
openapiToolVersion=1.9.0-20240410-215000-47b4b8a
openapiToolVersion=1.9.0-20240420-173200-f304d88

# AsyncAPI Module
asyncapiToolVersion=0.8.0-20240410-162000-91c4290
asyncapiToolVersion=0.8.0-20240420-021200-49b7489

c2cVersion=3.0.0-20240410-214400-0e03d41
c2cVersion=3.0.0-20240420-075600-2035b0e

dataMapperVersion=2.2.1-20230831-150600-0e37f32

Expand Down

0 comments on commit 89b4aae

Please sign in to comment.