[disputewebhooks] Code generation: update services and models#1706
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the DisputeEventNotification and DisputeNotificationRequest models to enhance enum deserialization by providing a fallback cast for raw string values. The review identifies potential issues with casting nullable strings to non-nullable enums, which could trigger compiler warnings, and highlights a risk where a non-nullable property might be assigned a null value during deserialization.
| case "type": | ||
| string? typeRawValue = utf8JsonReader.GetString(); | ||
| type = new Option<DisputeEventNotification.TypeEnum?>(DisputeEventNotification.TypeEnum.FromStringOrDefault(typeRawValue)); | ||
| type = new Option<DisputeEventNotification.TypeEnum?>(DisputeEventNotification.TypeEnum.FromStringOrDefault(typeRawValue) ?? (DisputeEventNotification.TypeEnum)typeRawValue); |
There was a problem hiding this comment.
The cast (DisputeEventNotification.TypeEnum)typeRawValue is to a non-nullable type, which may trigger a compiler warning since typeRawValue can be null. It is safer and more consistent with the Option<TypeEnum?> wrapper to cast to TypeEnum?.
type = new Option<DisputeEventNotification.TypeEnum?>(DisputeEventNotification.TypeEnum.FromStringOrDefault(typeRawValue) ?? (DisputeEventNotification.TypeEnum?)typeRawValue);| case "type": | ||
| string? typeRawValue = utf8JsonReader.GetString(); | ||
| type = new Option<DisputeNotificationRequest.TypeEnum?>(DisputeNotificationRequest.TypeEnum.FromStringOrDefault(typeRawValue)); | ||
| type = new Option<DisputeNotificationRequest.TypeEnum?>(DisputeNotificationRequest.TypeEnum.FromStringOrDefault(typeRawValue) ?? (DisputeNotificationRequest.TypeEnum)typeRawValue); |
There was a problem hiding this comment.
The cast (DisputeNotificationRequest.TypeEnum)typeRawValue is to a non-nullable type, which may trigger a compiler warning since typeRawValue can be null. It is safer and more consistent with the Option<TypeEnum?> wrapper to cast to TypeEnum?.
type = new Option<DisputeNotificationRequest.TypeEnum?>(DisputeNotificationRequest.TypeEnum.FromStringOrDefault(typeRawValue) ?? (DisputeNotificationRequest.TypeEnum?)typeRawValue);| var disputeNotificationRequest = new DisputeNotificationRequest(); | ||
| disputeNotificationRequest.Data = data.Value!; | ||
| disputeNotificationRequest.Type = type.Value!.Value; | ||
| disputeNotificationRequest.Type = type.Value!; |
There was a problem hiding this comment.
The property Type is defined as non-nullable, but type.Value can be null if the JSON contains "type": null. Using the null-forgiving operator ! suppresses the compiler warning but allows an invalid null state for a required property. Consider adding a null check or making the property nullable to ensure robust handling of null values in the JSON payload.
This PR contains the automated changes for the
disputewebhooksservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.