Repository navigation
[SEL-138] Allow null for voption record fields - #2
Merged
Merged
Conversation
FSharp.SystemTextJson writes ValueNone in a record field as null, but the schema showed only the inner type. Unwrapped voption now takes the same path as unwrapped option: record fields get the inner schema plus null, top-level values keep the inner schema only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed transformers The record and union transformers build field schemas themselves and only matched option, so voption fields still lacked null with the transformer set that AddOpenApiForSystemTextJson registers. Both now share one option-or-voption pattern. The option tests run the shipped set and assert the serialized JSON next to the schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… parent's override FSharp.SystemTextJson encodes a nested option or voption field with the global options, even when the parent record or union overrides UnwrapOption with [<JsonFSharpConverter>]. The record and union transformers used the parent's options, so they described a wrapped ValueNone as string or null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
UnwrapOption(the default), a record field of type'T voptionwas described as the inner schema only. FSharp.SystemTextJson writesValueNoneasnull, so the JSON could hold anullthat the schema did not allow.Runtime proof with the test options:
{ MaybeV = ValueNone }{"maybeV":null}{ MaybeV = ValueSome "x" }{"maybeV":"x"}ValueNonenullChange:
voptionrecord or union field gets the inner schema plusnull, likeoption. A top-level value keeps the inner schema only (unchanged, same as top-leveloption). The Option transformer's unwrappedvoptionbranch now takes theoptionpath too.UnwrapOptionwith[<JsonFSharpConverter>](runtime: globalfalse+ parenttruewrites{"MaybeV":{"Case":"ValueNone"},"Maybe":null}). The record and union transformers now read the field encoding from the global options. Foroptionfields this was already wrong on main in the same way.AddOpenApiForSystemTextJsonregisters and assert the serialized JSON next to the schema. Therecord-with-voptiontest locked in the wrong shape before. New cases:voptionunion field, per-type override.Release plan:
v0.1.1-preview.1first, verified against the SelectView monorepo OpenAPI snapshots, thenv0.1.1on the same commit.Review of record: SelectView Review contract panel, non-mechanical tier. Round 1: Sol xhigh + Opus high (two Act-on items, both fixed above). Fix round: fresh Opus high on
08a4274..ca32cc3, no Act-on items.Non-blocking follow-ups (reproduced, unchanged from main):
option/voptionget nonull:{ T: int * string voption }with(1, ValueNone)writes{"T":[1,null]}, but the item schema has nonull.[<JsonFSharpConverter>]override replaces all options in the schema, while the runtime does not apply it that way, so the union shape can differ from the JSON.🤖 Generated with Claude Code