[management] Code generation: update services and models#1716
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates numerous model classes within the Adyen Management namespace to refine enum handling and JSON deserialization logic. Key changes include implementing a fallback cast for unknown enum values and simplifying property assignments. Feedback from the reviewer identifies several high-severity issues: the modification of enum serialization to return value.Value instead of null creates a risk of NullReferenceException across many files. Furthermore, the updated logic in ScheduleTerminalActionsRequestActionDetails.cs is noted to break forward compatibility by restricting polymorphic deserialization to only predefined action types.
| return "pos"; | ||
|
|
||
| return null; | ||
| return value.Value; |
There was a problem hiding this comment.
The change from return null; to return value.Value; introduces a potential NullReferenceException when value is null. This method is used during serialization, and if the corresponding property is null, this will cause a crash. Use the null-conditional operator to safely return the underlying string value or null.
return value?.Value;| } | ||
|
|
||
| if (forceRebootDetails?.Type != null) | ||
| if (forceRebootDetails?.Type != null && ForceRebootDetails.TypeEnum.FromStringOrDefault((string?)forceRebootDetails.Type) != null) |
There was a problem hiding this comment.
This change restricts polymorphic deserialization to only known action types. Previously, any non-null Type would allow the action to be returned. With this change, unknown action types (which are now supported by the TypeEnum class via the ?? (TypeEnum)rawValue pattern) will cause this check to fail and eventually lead to a JsonException. This breaks forward compatibility for new action types added to the API. This issue also occurs on lines 238, 241, 244, 247, and 250.
if (forceRebootDetails?.Type != null)| return "deductFromOneBalanceAccount"; | ||
|
|
||
| return null; | ||
| return value.Value; |
There was a problem hiding this comment.
The change to return value.Value; will throw a NullReferenceException if value is null. Since this is a conversion method used during serialization, it should handle null values gracefully by returning null, as it did previously. This pattern is repeated throughout this file and others in this PR.
return value?.Value;| return "soap"; | ||
|
|
||
| return null; | ||
| return value.Value; |
This PR contains the automated changes for the
managementservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.