[Repo Assist] feat: add WrapNullableStrings static parameter to OpenApiClientProvider#357
Draft
github-actions[bot] wants to merge 2 commits intomasterfrom
Draft
Conversation
…er (closes #122) When WrapNullableStrings=true, optional/nullable string fields are wrapped as Option<string> instead of plain string, matching the treatment of other optional value types (bool, int, float, etc.). Defaults to false to preserve backwards compatibility. - Add WrapNullableStrings static parameter to DefinitionCompiler (optional arg) - Pass parameter through Provider.OpenApiClient.fs to DefinitionCompiler - Include WrapNullableStrings in the type-generation cache key - Add compilePropertyTypeWith helper in test helpers - Add 5 tests covering WrapNullableStrings=false/true/required scenarios Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
11 tasks
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #122
Root Cause
DefinitionCompilerwraps non-required value types (e.g.,bool option,int option) inOption<T>, but skips reference types entirely because they're already nullable by the CLR. This meansnullable: truestring fields come through as plainstringeven though the user might want the F# type system to reflect the optional/absent distinction.Fix
Add a
WrapNullableStringsstatic parameter (defaultfalse) toOpenApiClientProvider. When set totrue, optional/nullable string fields are wrapped inOption<string>, consistent with howFSharp.Data.SqlClientmapsvarchar NULL→string option.The default is
falseto preserve full backwards compatibility — existing users who read nullable strings asstringare unaffected unless they opt in.Changes
src/SwaggerProvider.DesignTime/v3/DefinitionCompiler.fs?wrapNullableStrings: booloptional parameter; applyOption<string>wrapping when enabledsrc/SwaggerProvider.DesignTime/Provider.OpenApiClient.fsWrapNullableStringsstatic parameter, thread it through toDefinitionCompiler, include in cache keytests/SwaggerProvider.Tests/v3/Schema.TestHelpers.fscompilePropertyTypeWithhelper that acceptsprovideNullableandwrapNullableStringstests/SwaggerProvider.Tests/v3/Schema.TypeMappingTests.fsTest Status
✅ Build: succeeded (0 errors, warnings are pre-existing)
✅ Unit tests: 268 passed, 0 failed, 2 skipped (same as baseline)
✅ New WrapNullableStrings tests: all 5 pass
✅ Format check:
fantomasapplied and re-verified cleanIntegration/provider tests require a running Swashbuckle test server and were not run; the new parameter does not touch HTTP or serialization logic.