Skip to content

[Repo Assist] eng: add TimeOnly support for format:time schemas (+11 tests, 295→306)#394

Open
github-actions[bot] wants to merge 5 commits intomasterfrom
repo-assist/eng-timeonly-format-time-20260420-4666c2310c7d4df2
Open

[Repo Assist] eng: add TimeOnly support for format:time schemas (+11 tests, 295→306)#394
github-actions[bot] wants to merge 5 commits intomasterfrom
repo-assist/eng-timeonly-format-time-20260420-4666c2310c7d4df2

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

OpenAPI format: time fields were previously silently treated as string. On .NET 6+ (when useDateOnly=true), they now map to System.TimeOnly — the natural .NET counterpart, exactly parallel to the existing DateOnly handling for format: date.

Root cause

DefinitionCompiler.compileBySchema handled format: date and format: date-time but had no explicit case for format: time, so it fell through to the catch-all string mapping. RuntimeHelpers.toParam and toQueryParams had no TimeOnly handling either.

Changes

  • DefinitionCompiler.fs: add "time" format case → System.TimeOnly when useDateOnly=true, with string fallback on older runtimes (same runtime-version guard as DateOnly)
  • RuntimeHelpers.fs:
    • Extract tryFormatViaMethods helper shared by DateOnly and TimeOnly (removes duplication)
    • Add tryFormatTimeOnly (formats with "HH:mm:ss.FFFFFFF", trailing zeros stripped)
    • Extend toQueryParams array detection to also match TimeOnly and Option<TimeOnly> arrays
  • Tests: 9 RuntimeHelpersTests covering toParam/toQueryParams for TimeOnly; 2 Schema.TypeMappingTests for the new format: time mapping

Test Status

dotnet build — succeeded (0 errors)
dotnet tests/SwaggerProvider.Tests/... — 306 passed, 0 failed (1 skipped pre-existing)
dotnet fake build -t CheckFormat — no formatting issues

Trade-offs

  • useDateOnly flag already implies .NET 6+, so it correctly gates TimeOnly (same as DateOnly)
  • "HH:mm:ss.FFFFFFF" uses Fantomas's FFFFFFF specifier (trailing zeros omitted), matching the ISO 8601 partial-time format expected by most OpenAPI servers
  • The netstandard2.0 target continues to receive string as a safe fallback

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@96b9d4c39aa22359c0b38265927eadb31dcf4e2a

OpenAPI `format: time` fields were previously silently treated as strings.
On .NET 6+ (when useDateOnly=true), they now map to System.TimeOnly — the
natural .NET counterpart, parallel to the existing DateOnly handling for
format:date.

Changes:
- DefinitionCompiler: add 'time' format case → TimeOnly when useDateOnly=true,
  falling back to string on older runtimes (same guard as DateOnly)
- RuntimeHelpers: add tryFormatViaMethods helper shared by DateOnly and TimeOnly;
  add tryFormatTimeOnly (format HH:mm:ss.FFFFFFF); extend toQueryParams array
  detection to also match TimeOnly and Option<TimeOnly> arrays
- Add 9 RuntimeHelpers unit tests covering toParam/toQueryParams for TimeOnly
- Add 2 Schema.TypeMappingTests covering the new format:time mapping

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergey-tihon sergey-tihon marked this pull request as ready for review April 21, 2026 07:03
Copilot AI review requested due to automatic review settings April 21, 2026 07:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds System.TimeOnly support across schema type-mapping and runtime parameter formatting so OpenAPI format: time values are no longer silently treated as string when useDateOnly=true (parallel to existing DateOnly behavior for format: date).

Changes:

  • Add format: time mapping in DefinitionCompiler to System.TimeOnly when useDateOnly=true (with string fallback).
  • Extend RuntimeHelpers.toParam / toQueryParams to format TimeOnly and TimeOnly-typed arrays/options.
  • Add runtime tests for TimeOnly formatting and query-param expansion; add a schema type-mapping fallback test.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/SwaggerProvider.DesignTime/DefinitionCompiler.fs Adds schema mapping for string + format: time to TimeOnly behind useDateOnly.
src/SwaggerProvider.Runtime/RuntimeHelpers.fs Adds TimeOnly formatting support and expands array detection to include TimeOnly/Option<TimeOnly>.
tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs Adds TimeOnly coverage for toParam and toQueryParams (scalar, option, array, option-array).
tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs Adds a format: time test for the useDateOnly=false fallback path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs
Comment thread tests/SwaggerProvider.Tests/Schema.TypeMappingTests.fs
@sergey-tihon
Copy link
Copy Markdown
Member

@copilot address inline comments and ensure that tests properly cover new feature

Copilot AI and others added 2 commits April 21, 2026 08:08
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

@copilot address inline comments and ensure that tests properly cover new feature

Addressed in 18f7695 (plus supporting test commit 69a810b). I added explicit schema coverage for format: time mapping to TimeOnly when useDateOnly=true, kept the existing fallback test for useDateOnly=false, and refactored test helpers to make DateOnly/TimeOnly-enabled compilation explicit and reusable. Targeted unit tests and format checks pass (307 tests, 0 failed).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/SwaggerProvider.Tests/Schema.TestHelpers.fs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants