You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The ODataEnumSerializer and ODataEnumDeserializer fails to convert multi-value Flag enums to LowerCamelCase as specified in EnumMember attribute. However, this works with single-value Flag enums.
With the default ODataEnumSerializer, a single-value Flag enum like ExampleEnum.FirstValue is correctly converted to ("firstValue"). However, a multi-value Flag enum like ExampleEnum.FirstValue | ExampleEnum.SecondValue is not converted to ("firstValue, secondValue") as expected. Instead, it remains in its original form as "FirstValue, SecondValue"
Find the ODataWebApiApplication15.http and execute the following requests:
GET /odata/Customers:
Note that the customerType for customer id=1 is "regular" but the customerType for customer id=2 is "Premium, VIP" instead of "premium, vip" in lower camel case
Expected behavior
Expected lower camel case for multi-value Flag enum to work the same way as for single-value. For example, firstValue, secondValue should work the same way firstValue.
The text was updated successfully, but these errors were encountered:
WanjohiSammy
changed the title
Default ODataEnumSerializer Fails to Convert Multi-Value Flag Enum to Lower Camel Case
Default ODataEnumSerializer and ODataEnumDeserializer Fails to Convert Multi-Value Flag Enum to Lower Camel Case
Dec 4, 2024
Assemblies affected
8.x
Describe the bug
The
ODataEnumSerializer
andODataEnumDeserializer
fails to convert multi-value Flag enums toLowerCamelCase
as specified inEnumMember attribute
. However, this works with single-value Flag enums.Example:
Consider the following Flag enum:
With the default ODataEnumSerializer, a
single-value
Flag enum likeExampleEnum.FirstValue
is correctly converted to ("firstValue
"). However, amulti-value
Flag enum likeExampleEnum.FirstValue | ExampleEnum.SecondValue
is not converted to ("firstValue, secondValue
") as expected. Instead, it remains in its original form as"FirstValue, SecondValue"
Reproduce steps
Clone the repo
Build and run the application
Find the
ODataWebApiApplication15.http
and execute the following requests:GET /odata/Customers
:Note that the
customerType
for customerid=1
is "regular" but thecustomerType
for customerid=2
is "Premium, VIP" instead of "premium, vip" inlower camel case
POST /odata/Customers
With
"customerType": "Regular, Premium"
- a new record is created successfullyWith lower camel case
"customerType": "regular, premium"
- request is nullWith lower camel case single-value
"customerType": "regular"
- works as expectedPATCH /odata/Customers(2)
"customerType": "Regular, VIP"
- the record is updated successfully"customerType": "regular, premium"
- delta is null"customerType": "regular"
- works as expectedData Model
EDM (CSDL) Model
Request/Response
Expected behavior
Expected
lower camel case
formulti-value
Flag enum to work the same way as forsingle-value
. For example,firstValue, secondValue
should work the same wayfirstValue
.The text was updated successfully, but these errors were encountered: