[sessionauthentication] Code generation: update services and models#1711
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors ProductType and ResourceType from standard enums to class-based enums to improve round-trip safety for unknown values. The changes include updating JSON converters and serialization logic across multiple models. Feedback identifies a significant logic error in the Resource constructor where this.GetType().Name results in a string mismatch with defined ResourceType constants. Additionally, several instances of dead code were found in the Read methods of various resource models where the type variable is assigned but not used.
| public Resource() | ||
| { | ||
| Type = (ResourceType)Enum.Parse(typeof(ResourceType), this.GetType().Name); | ||
| Type = (ResourceType)this.GetType().Name; |
There was a problem hiding this comment.
The initialization of Type using this.GetType().Name sets the value to the class name (e.g., "AccountHolderResource"). However, the static constants in ResourceType use different values (e.g., "accountHolder"). Even with the case-insensitive equality operator defined in ResourceType, "AccountHolderResource" will not match "accountHolder". This mismatch breaks logic that compares resource.Type with these constants and may lead to incorrect serialization if the API expects the enum values.
| string? typeRawValue = utf8JsonReader.GetString(); | ||
| if (typeRawValue != null) | ||
| type = new Option<ResourceType?>(ResourceTypeValueConverter.FromStringOrDefault(typeRawValue)); | ||
| type = new Option<ResourceType?>(ResourceType.FromStringOrDefault(typeRawValue) ?? (ResourceType)typeRawValue); |
| string? typeRawValue = utf8JsonReader.GetString(); | ||
| if (typeRawValue != null) | ||
| type = new Option<ResourceType?>(ResourceTypeValueConverter.FromStringOrDefault(typeRawValue)); | ||
| type = new Option<ResourceType?>(ResourceType.FromStringOrDefault(typeRawValue) ?? (ResourceType)typeRawValue); |
| string? typeRawValue = utf8JsonReader.GetString(); | ||
| if (typeRawValue != null) | ||
| type = new Option<ResourceType?>(ResourceTypeValueConverter.FromStringOrDefault(typeRawValue)); | ||
| type = new Option<ResourceType?>(ResourceType.FromStringOrDefault(typeRawValue) ?? (ResourceType)typeRawValue); |
| string? typeRawValue = utf8JsonReader.GetString(); | ||
| if (typeRawValue != null) | ||
| type = new Option<ResourceType?>(ResourceTypeValueConverter.FromStringOrDefault(typeRawValue)); | ||
| type = new Option<ResourceType?>(ResourceType.FromStringOrDefault(typeRawValue) ?? (ResourceType)typeRawValue); |
This PR contains the automated changes for the
sessionauthenticationservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.