Repository navigation
[SEL-138] Match FSharp.SystemTextJson for per-type options, option elements and skippable option fields - #3
Merged
Conversation
…ements and skippable option fields - Per-type options: apply WithOverrides first, read [<JsonFSharpConverter>] only with AllowOverride, and inherit the global union encoding when the per-type options do not set it (port of FSharp.SystemTextJson's overrideOptions). - option and voption tuple elements, positional union fields and unwrapped single-field cases allow null. - Record and named union fields follow SkippableOptionFields when deciding whether an option field is required. Each new test asserts the serialized JSON next to the schema and failed before the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… unwrap, record options in unwrapped cases - Tuple and positional case items use anyOf: a value can match more than one element type (a field equal to the case tag, two option elements that are null), which oneOf rejected. - An option or voption field decides UnwrapOption from the options for option<_> or voption<_>, so WithOverrides on option<_> applies to tuple elements and positional fields too. - An unwrapped record case uses the record's own options, layered on the union's, like FSharp.SystemTextJson. - Tests check the specific element schema; each new one fails on the previous commit. Docs name WithOverrideMembers and MapFormat as not supported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… options test, drop dead helpers 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.
The OpenAPI schema must describe exactly the JSON FSharp.SystemTextJson writes. This fixes three gaps where it did not; each new test asserts the serialized JSON next to the schema and fails on the previous code.
FsOptions.getEffectiveFsOptions) now follow FSharp.SystemTextJson'soverrideOptions:WithOverridesfirst (type or generic definition),[<JsonFSharpConverter>]only withAllowOverride, and the global union encoding inherited when the per-type options do not set it. Before, the attribute was used as-is (also withoutAllowOverride) andWithOverrideswas ignored. Example:[<JsonFSharpConverter(UnionTagName = "type")>]with internal-tag, named-field global options wrote{"type":"Circle","radius":1}, but the schema described{"type":"Circle","Fields":[...]}.option/voptionin tuple elements, positional union fields and unwrapped single-field cases allownull([null,1]was rejected).UnwrapOptionfor an option field now comes from the options foroption<_>/voption<_>, soWithOverridesonoption<_>applies too. Tuple and positional items useanyOf: a value can match more than one element type (["PosPair","PosPair",2],[null,null]), whichoneOfrejected.SkippableOptionFieldsdecides whether an option field in a record or named union field is required; an unwrapped record case uses the record's own options.Breaking change (before 1.0.0):
TupleSchemaTransformertakesJsonFSharpOptionsagain. Users who relied on the old advice not to useWithOverridescan now use it. Not supported and documented:WithOverrideMembers,MapFormat.Monorepo check on a locally packed package (SelectView, all 7 OpenAPI snapshots regenerated): one change, the Invoice Search tuple of
InvoiceViewColumnitems goes fromoneOftoanyOf; openapi-typescript renders both as the same union.Review: Sol xhigh and Opus high panel; Act-on findings (oneOf regression, unwrapped record options, per-type UnwrapOption) fixed in c6117bb; fresh Opus high fix-round review with no Act-on items; its notes applied. Ticket: SEL-138.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.