[Repo Assist] fix: handle DateOnly in toParam and toQueryParams#393
Conversation
DateOnly (generated for format:date fields on .NET 6+) was missing from
RuntimeHelpers.toParam and toQueryParams. Without explicit handling, the
code falls through to obj.ToString() which uses the current culture's
short-date format (e.g. "4/19/2026" in en-US) instead of the ISO 8601
"yyyy-MM-dd" required by OpenAPI.
Changes:
- toParam: add | :? DateOnly as d -> d.ToString("O") branch
- toQueryParams: add cases for DateOnly, DateOnly[], Option<DateOnly>,
Option<DateOnly>[] (using new toStrArrayDateOnly / toStrDateOnlyOpt
private helpers, mirroring the existing DateTime/DateTimeOffset pattern)
- Add 8 unit tests covering all new code paths
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot finish pr and fix build error |
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/67dc7d66-ec2a-47b3-a474-3c0180e94db9 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/67dc7d66-ec2a-47b3-a474-3c0180e94db9 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/67dc7d66-ec2a-47b3-a474-3c0180e94db9 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/67dc7d66-ec2a-47b3-a474-3c0180e94db9 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Fixed — the CI build error was caused by direct |
There was a problem hiding this comment.
Pull request overview
This PR fixes culture-dependent serialization of System.DateOnly values (used for OpenAPI format: date on .NET 6+) in the runtime parameter formatting helpers, ensuring ISO-8601 date strings are emitted.
Changes:
- Extend
RuntimeHelpers.toParamto formatDateOnlyvalues deterministically (ISOyyyy-MM-dd) instead of falling back to culture-dependentToString(). - Extend
RuntimeHelpers.toQueryParamsto supportDateOnlyvalues and arrays (includingoption-wrapped shapes) via reflection-based detection. - Add unit tests covering the newly supported
DateOnlypaths for bothtoParamandtoQueryParams.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/SwaggerProvider.Runtime/RuntimeHelpers.fs |
Adds reflection-based detection/formatting for System.DateOnly in toParam/toQueryParams. |
tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs |
Adds new tests asserting DateOnly is serialized as yyyy-MM-dd for params and query params. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Problem
DateOnly(generated forformat: datefields on .NET 6+) was not handled explicitly inRuntimeHelpers.toParamorRuntimeHelpers.toQueryParams. Without a specific branch, both functions fall through toobj.ToString(), which produces a culture-dependent short-date string (e.g."4/19/2026"in en-US) instead of the ISO 8601"yyyy-MM-dd"format required by OpenAPI.This affects any endpoint that accepts a
format: dateparameter — the generated client would send the wrong string on non-English locales.Root Cause
toParamhad explicit branches forDateTimeandDateTimeOffsetbut not forDateOnly: