Skip to content

Fix .NET SDK serialization bugs in SubFormFieldRuleAction.TypeEnum and optional int request fields#523

Open
mwojcik-dropbox wants to merge 2 commits intomainfrom
fix/dotnet-sdk-generator-default-values
Open

Fix .NET SDK serialization bugs in SubFormFieldRuleAction.TypeEnum and optional int request fields#523
mwojcik-dropbox wants to merge 2 commits intomainfrom
fix/dotnet-sdk-generator-default-values

Conversation

@mwojcik-dropbox
Copy link
Copy Markdown

Two targeted post-generation patches in sdks/dotnet/bin/copy-constants.php:

SubFormFieldRuleAction.TypeEnum — swap StringEnumConverter for a dedicated TypeEnumJsonConverter that maps by numeric value. The legacy alias members (FieldVisibility, GroupVisibility) share underlying int values with their canonical counterparts, which caused StringEnumConverter to occasionally emit the raw C# identifier on the wire and get rejected by the API with HTTP 400.

Optional int request fields — sweep model files and flip [DataMember(..., EmitDefaultValue = true)] → false for optional non-nullable ints. openapi-generator was forcing "foo": 0 onto the wire for unset fields, which the API rejected for range-validated properties like font_size ('font_size' must be between 7 and 49). The sweep skips Response files so response-side round-trip fidelity (required by Api.* fixture tests) is preserved. Required fields are untouched (regex requires IsRequired = true, to be absent). Current pattern touches 5 request-side models carrying font_size; new optional ints on request-side models will be picked up automatically on regeneration.

Added SubFormFieldRuleActionTests to pin the TypeEnum wire contract (serialization, deserialization, and rejection of non-wire values).

No public API surface changes to the generated SDK — property signatures, constructor arity, and enum members are all unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant