Skip to content

Commit

Permalink
Add support for relaxed data binding for the client generation
Browse files Browse the repository at this point in the history
  • Loading branch information
SachinAkash01 committed Nov 27, 2024
1 parent 2cbf0b5 commit fc886fd
Show file tree
Hide file tree
Showing 34 changed files with 155 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ stdlibJwtVersion=2.13.1-20241113-162400-b59ccfa
stdlibOAuth2Version=2.12.1-20241113-162400-4c6ddfe

# Stdlib Level 05
stdlibHttpVersion=2.13.0-20241114-182900-7e9f66a
stdlibHttpVersion=2.13.0-20241126-143900-9551ecd

# Stdlib Level 06
stdlibGrpcVersion=1.13.0-20241114-195700-5188f60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ public class TestConstants {
" http:ProxyConfig proxy?;\n" +
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
"Enabled by default\n" +
" boolean validation = true; " +
" boolean validation = true;\n" +
" # Enables or disables relaxed data binding on the client side. Disabled by default.\n" +
" # When enabled, the JSON data will be projected to the Ballerina record type and during the " +
"projection, \n" +
" # nil values will be considered as optional fields and absent fields will be considered for " +
"nilable types\n" +
" boolean laxDataBinding = true;\n" +
"|};";

public static final String CLIENT_HTTP1_SETTINGS = "# Provides settings related to HTTP/1.x protocol.\n" +
Expand Down Expand Up @@ -210,6 +216,12 @@ public class TestConstants {
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
"Enabled by default\n" +
" boolean validation = true;\n" +
" # Enables or disables relaxed data binding on the client side. Disabled by default.\n" +
" # When enabled, the JSON data will be projected to the Ballerina record type and during the " +
"projection, \n" +
" # nil values will be considered as optional fields and absent fields will be considered for " +
"nilable types\n" +
" boolean laxDataBinding = true;\n" +
"|};";
public static final String CONNECTION_CONFIG_MIXED_AUTH = "" +
"# Provides a set of configurations for controlling the behaviours when communicating with a " +
Expand Down Expand Up @@ -248,6 +260,12 @@ public class TestConstants {
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
"Enabled by default\n" +
" boolean validation = true;\n" +
" # Enables or disables relaxed data binding on the client side. Disabled by default.\n" +
" # When enabled, the JSON data will be projected to the Ballerina record type and during the " +
"projection, \n" +
" # nil values will be considered as optional fields and absent fields will be considered for " +
"nilable types\n" +
" boolean laxDataBinding = true;\n" +
"|};";

public static final String CONNECTION_CONFIG_HTTP_VERSION_1_1 = "" +
Expand Down Expand Up @@ -284,6 +302,12 @@ public class TestConstants {
" # Enables the inbound payload validation functionality which provided by the constraint package. " +
" Enabled by default\n" +
" boolean validation = true;\n" +
" # Enables or disables relaxed data binding on the client side. Disabled by default.\n" +
" # When enabled, the JSON data will be projected to the Ballerina record type and during the " +
"projection,\n" +
" # nil values will be considered as optional fields and absent fields will be considered for " +
"nilable types\n" +
" boolean laxDataBinding = true;\n" +
"|};";
public static final String OAUTH2_REFRESH_TOKEN_GRANT_CONFIG_RECORD = "#OAuth2ClientCredentialsGrantConfigs" +
"publictypeOAuth2ClientCredentialsGrantConfigrecord{|*http:OAuth2ClientCredentialsGrantConfig;" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};

# Represents the Queries record for the operation: getAlbumsId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};

# Represents the Queries record for the operation: Get_Albums_Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};

# Represents the Queries record for the operation: getAlbumsId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6737,6 +6737,10 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};

# Represents the Queries record for the operation: getNotificationSchemeForProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -1340,10 +1340,11 @@ private List<Node> getClientConfigRecordFields() {
recordFieldNodes.add(validateFieldNode);

// add laxBinding for data binding
MetadataNode laxDataBindingMetadata = getMetadataNode("Enables or disables relaxed data binding on " +
"the client side. Disabled by default. When enabled, the JSON data will be projected to " +
"the Ballerina record type and during the projection, nil values will be considered as optional " +
"fields and absent fields will be considered for nilable types");
String apiComment = "Enables or disables relaxed data binding on the client side. " +
"Disabled by default.\nWhen enabled, the JSON data will be projected to the Ballerina record type" +
" and during the projection, \nnil values will be considered as optional fields and absent fields " +
"will be considered for nilable types";
MetadataNode laxDataBindingMetadata = getMetadataNode(apiComment);
IdentifierToken laxDataBindingFieldName = AbstractNodeFactory.createIdentifierToken("laxDataBinding");
TypeDescriptorNode laxDataBindingFieldType = createSimpleNameReferenceNode(createIdentifierToken(BOOLEAN));
RecordFieldWithDefaultValueNode laxDataBindingFieldNode = NodeFactory.createRecordFieldWithDefaultValueNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};

# Request for the chat completions using extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ public type ConnectionConfig record {|
http:ProxyConfig proxy?;
# Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
boolean validation = true;
# Enables or disables relaxed data binding on the client side. Disabled by default.
# When enabled, the JSON data will be projected to the Ballerina record type and during the projection,
# nil values will be considered as optional fields and absent fields will be considered for nilable types
boolean laxDataBinding = true;
|};
Loading

0 comments on commit fc886fd

Please sign in to comment.