[binlookup] Code generation: update services and models#1697
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the SDK generation log and modifies the deserialization logic for ShopperInteractionEnum, ContractEnum, and TokenServiceEnum to include a fallback mechanism. Feedback suggests replacing the manual deserialization logic with JsonSerializer.Deserialize to leverage existing converters and avoid potential nullability warnings.
| string? shopperInteractionRawValue = utf8JsonReader.GetString(); | ||
| shopperInteraction = new Option<CostEstimateRequest.ShopperInteractionEnum?>(CostEstimateRequest.ShopperInteractionEnum.FromStringOrDefault(shopperInteractionRawValue)); | ||
| shopperInteraction = new Option<CostEstimateRequest.ShopperInteractionEnum?>(CostEstimateRequest.ShopperInteractionEnum.FromStringOrDefault(shopperInteractionRawValue) ?? (CostEstimateRequest.ShopperInteractionEnum)shopperInteractionRawValue); |
There was a problem hiding this comment.
The manual deserialization logic for shopperInteraction is redundant and potentially problematic. ShopperInteractionEnum already has a dedicated JsonConverter (ShopperInteractionEnumJsonConverter) that handles the mapping and forward compatibility correctly.
Furthermore, passing shopperInteractionRawValue (which is a string?) directly to FromStringOrDefault (which expects a non-nullable string) can trigger a compiler warning (CS8625) when the value is null.
Using JsonSerializer.Deserialize is more idiomatic, leverages the existing converter, and avoids these issues.
shopperInteraction = new Option<CostEstimateRequest.ShopperInteractionEnum?>(JsonSerializer.Deserialize<CostEstimateRequest.ShopperInteractionEnum>(ref utf8JsonReader, jsonSerializerOptions)!);| string? contractRawValue = utf8JsonReader.GetString(); | ||
| contract = new Option<Recurring.ContractEnum?>(Recurring.ContractEnum.FromStringOrDefault(contractRawValue)); | ||
| contract = new Option<Recurring.ContractEnum?>(Recurring.ContractEnum.FromStringOrDefault(contractRawValue) ?? (Recurring.ContractEnum)contractRawValue); |
There was a problem hiding this comment.
The manual deserialization logic for contract is redundant because ContractEnum already has a dedicated JsonConverter. Additionally, passing a nullable string to FromStringOrDefault may cause compiler warnings. It is better to use JsonSerializer.Deserialize to leverage the existing converter logic.
contract = new Option<Recurring.ContractEnum?>(JsonSerializer.Deserialize<Recurring.ContractEnum>(ref utf8JsonReader, jsonSerializerOptions)!);| string? tokenServiceRawValue = utf8JsonReader.GetString(); | ||
| tokenService = new Option<Recurring.TokenServiceEnum?>(Recurring.TokenServiceEnum.FromStringOrDefault(tokenServiceRawValue)); | ||
| tokenService = new Option<Recurring.TokenServiceEnum?>(Recurring.TokenServiceEnum.FromStringOrDefault(tokenServiceRawValue) ?? (Recurring.TokenServiceEnum)tokenServiceRawValue); |
There was a problem hiding this comment.
Similar to the contract property, the manual deserialization for tokenService should be replaced with JsonSerializer.Deserialize to maintain consistency and reuse the logic defined in TokenServiceEnumJsonConverter.
tokenService = new Option<Recurring.TokenServiceEnum?>(JsonSerializer.Deserialize<Recurring.TokenServiceEnum>(ref utf8JsonReader, jsonSerializerOptions)!);
This PR contains the automated changes for the
binlookupservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.