Skip to content

Commit

Permalink
Merge branch 'relaxed-data-binding' of https://github.com/SachinAkash…
Browse files Browse the repository at this point in the history
…01/module-ballerina-http into relaxed-data-binding
  • Loading branch information
SachinAkash01 committed Dec 17, 2024
2 parents fcc5791 + 694329d commit 0e7f3a0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/proposals/introducing_relaxed_data_binding.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Proposal: Introduce Relaxed Data Binding to Ballerina HTTP Module

_Owners_: @SachinAkash01
_Owners_: @shafreenAnfar @daneshk @NipunaRanasinghe @lnash94 @TharmiganK @SachinAkash01
_Reviewers_: @lnash94 @TharmiganK @shafreenAnfar
_Created_: 2024/11/13
_Updated_: 2024/11/18
Expand Down Expand Up @@ -50,11 +50,11 @@ Following is the breakdown of the cases we need to reconsider within the context
| Required & non-nullable | `T foo;` | Both null values and absent fields cause runtime failures | Same |
| Required & nullable | `T? foo;` | Absent fields will cause runtime failures | Need relaxed data binding to map absent fields as nil values |
| Optional & non-nullable | `T foo?;` | Null values will cause runtime failures | Need relaxed data binding to map null values as absent fields |
| Optional & nullable | `T? foo?;` | Both nil values and absent fields are allowed | Same |
| Optional & nullable | `T? foo?;` | Both nil values and absent fields are allowed | Same | |

In the `data.jsondata` package, the `Options` configuration already provides support for handling various field types in JSON data binding, accommodating scenarios with both absent fields and null values. The `Options` record allows us to adjust how nullability and optionality are treated, making it a versatile solution for managing the differences between required and optional fields, as well as nullable and non-nullable fields.

The `Options` record in the data.jsondata module is defined as follows:,
The `Options` record in the `data.jsondata` module is defined as follows:,

```ballerina
public type Options record {
Expand All @@ -79,6 +79,8 @@ The approach involves adding a new field, `laxDataBinding`, to the `CommonClient
public type CommonClientConfiguration record {|
boolean laxDataBinding = false;
// Other fields
boolean laxDataBinding = false;
// Other fields
|};
```

Expand All @@ -89,5 +91,7 @@ We can configure the relaxed data binding in the service level by improving the
public type HttpServiceConfig record {|
boolean laxDataBinding = false;
// Other fields
boolean laxDataBinding = false;
// Other fields
|};
```

0 comments on commit 0e7f3a0

Please sign in to comment.