From 003f31265525d591df338c0670409e7635b5ce74 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 22:08:12 +0000 Subject: [PATCH 1/3] =?UTF-8?q?test:=20extend=20DateOnly/TimeOnly=20type-m?= =?UTF-8?q?apping=20coverage=20(+7=20tests,=20317=E2=86=92324)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the tests that were missing after PRs #393 and #394 landed: * required date → DateOnly when useDateOnly=true * optional date → Option when useDateOnly=true * optional time → Option when useDateOnly=true * PreferNullable+useDateOnly: optional DateOnly → Nullable * PreferNullable+useDateOnly: required DateOnly stays unwrapped * PreferNullable+useDateOnly: optional TimeOnly → Nullable * PreferNullable+useDateOnly: required TimeOnly stays unwrapped Also expose compilePropertyTypeWithNullableAndDateOnly helper in Schema.TestHelpers for the PreferNullable×useDateOnly combination. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Schema.TestHelpers.fs | 4 ++ .../Schema.TypeMappingTests.fs | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/tests/SwaggerProvider.Tests/Schema.TestHelpers.fs b/tests/SwaggerProvider.Tests/Schema.TestHelpers.fs index 7bcf327..9c3cf0f 100644 --- a/tests/SwaggerProvider.Tests/Schema.TestHelpers.fs +++ b/tests/SwaggerProvider.Tests/Schema.TestHelpers.fs @@ -101,3 +101,7 @@ let compilePropertyTypeWith (provideNullable: bool) (propYaml: string) (required /// Compile a minimal v3 schema where date/time formats map to DateOnly/TimeOnly types. let compilePropertyTypeWithDateOnly (propYaml: string) (required: bool) : Type = compilePropertyTypeWithOptions false true propYaml required + +/// Compile a minimal v3 schema with both PreferNullable and useDateOnly options enabled. +let compilePropertyTypeWithNullableAndDateOnly (propYaml: string) (required: bool) : Type = + compilePropertyTypeWithOptions true true propYaml required diff --git a/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs b/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs index c979e19..bc83bb0 100644 --- a/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs +++ b/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs @@ -59,6 +59,13 @@ let ``required string date format maps to DateTimeOffset``() = ty |> shouldEqual typeof +[] +let ``required string date format maps to DateOnly when useDateOnly is true``() = + let ty = + compilePropertyTypeWithDateOnly " type: string\n format: date\n" true + + ty |> shouldEqual typeof + [] let ``required string time format falls back to string when useDateOnly is false``() = // The test helper compiles with useDateOnly=false, so TimeOnly is not used @@ -136,6 +143,22 @@ let ``optional DateTimeOffset maps to Option``() = ty |> shouldEqual(typedefof>.MakeGenericType(typeof)) +[] +let ``optional DateOnly maps to Option when useDateOnly is true``() = + let ty = + compilePropertyTypeWithDateOnly " type: string\n format: date\n" false + + ty + |> shouldEqual(typedefof>.MakeGenericType(typeof)) + +[] +let ``optional TimeOnly maps to Option when useDateOnly is true``() = + let ty = + compilePropertyTypeWithDateOnly " type: string\n format: time\n" false + + ty + |> shouldEqual(typedefof>.MakeGenericType(typeof)) + [] let ``optional Guid maps to Option``() = let ty = @@ -444,3 +467,35 @@ let ``PreferNullable: optional binary (base64) stays as plain Stream``() = compilePropertyTypeWith true " type: string\n format: binary\n" false ty |> shouldEqual typeof + +// ── PreferNullable + useDateOnly: value-type date/time formats use Nullable ────────────── +// When both provideNullable=true and useDateOnly=true, optional DateOnly/TimeOnly properties +// should be wrapped in Nullable (not Option), consistent with other value types. + +[] +let ``PreferNullable: optional DateOnly maps to Nullable when useDateOnly is true``() = + let ty = + compilePropertyTypeWithNullableAndDateOnly " type: string\n format: date\n" false + + ty |> shouldEqual typeof> + +[] +let ``PreferNullable: required DateOnly is not wrapped when useDateOnly is true``() = + let ty = + compilePropertyTypeWithNullableAndDateOnly " type: string\n format: date\n" true + + ty |> shouldEqual typeof + +[] +let ``PreferNullable: optional TimeOnly maps to Nullable when useDateOnly is true``() = + let ty = + compilePropertyTypeWithNullableAndDateOnly " type: string\n format: time\n" false + + ty |> shouldEqual typeof> + +[] +let ``PreferNullable: required TimeOnly is not wrapped when useDateOnly is true``() = + let ty = + compilePropertyTypeWithNullableAndDateOnly " type: string\n format: time\n" true + + ty |> shouldEqual typeof From d2c2e350aa6da37d1b9a069d927db2f4b4201325 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 22 Apr 2026 22:08:15 +0000 Subject: [PATCH 2/3] ci: trigger checks From e2e883b695cff18578ae5ef1e8440484bf0fdb0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 05:41:29 +0000 Subject: [PATCH 3/3] test: clarify useDateOnly=false expectation in date format mapping test Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/564a5cd8-95fa-4822-8a43-a8e1132ed123 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com> --- tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs b/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs index bc83bb0..e3c3948 100644 --- a/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs +++ b/tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs @@ -54,7 +54,7 @@ let ``required string date-time format maps to DateTimeOffset``() = ty |> shouldEqual typeof [] -let ``required string date format maps to DateTimeOffset``() = +let ``required string date format maps to DateTimeOffset when useDateOnly is false``() = let ty = compilePropertyType " type: string\n format: date\n" true ty |> shouldEqual typeof