You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support non-string round-tripping parameters #2046
Repository is a record struct that has a string in the some/repo format, that is with a / that I do not want to be url encoded.
Describe the solution you'd like
I can see three solutions (maybe there are more).
Simply allow any type to by round-tripping, and call ToString() on it.
Allow to somehow register the type Repository in RefitSettings and have an explicit formatter associated with it.
Make it possible using the current IUrlParameterFormatter to return the raw string somehow. Currently the IUrlParameterFormatter is not invoked when the parameter is part of the path.
Describe alternatives you've considered
None
Describe suggestions on how to achieve the feature
Resolved on main by the reflection-free request-building refactor (#2210), so closing as fixed.
Round-tripping path parameters now accept any type, not just string. The value is rendered with IUrlParameterFormatter / ToString() and the / separators in the result are preserved segment-by-segment.
This works identically in both the reflection path and the source-generated path.
Verified by RestServiceExceptions.RoundTripParameterNotStringFormatsAndPreservesSlashes, which uses the exact reported shape (a readonly record struct RepoPath("some/repo") producing /repos/some/repo/contents), plus RoundTripNotStringGeneratedMatchesReflection asserting the generated output matches the reflection output.
The earlier premise that IUrlParameterFormatter is not invoked for path values is also no longer true; the formatter is now called for path parameters, object-property fragments, and round-trip segments.
If you specifically want a per-type formatter registry configured on RefitSettings (rather than a custom IUrlParameterFormatter that switches on the value type), that is a separate enhancement - please open a new issue for it.
Opened #2219 to track the optional follow-up: a per-type IUrlParameterFormatter registry on RefitSettings, so custom URL formatting for a specific type does not require a hand-rolled type switch in a custom formatter.
Type-safe REST API clients for .NET, generated from annotated interfaces with build-time source generation, direct request construction, System.Text.Json defaults, and support for trimming and AOT.
Activity
glennawatson commentedon Jul 14, 2026
Resolved on
mainby the reflection-free request-building refactor (#2210), so closing as fixed.string. The value is rendered withIUrlParameterFormatter/ToString()and the/separators in the result are preserved segment-by-segment.RestServiceExceptions.RoundTripParameterNotStringFormatsAndPreservesSlashes, which uses the exact reported shape (areadonly record struct RepoPath("some/repo")producing/repos/some/repo/contents), plusRoundTripNotStringGeneratedMatchesReflectionasserting the generated output matches the reflection output.IUrlParameterFormatteris not invoked for path values is also no longer true; the formatter is now called for path parameters, object-property fragments, and round-trip segments.If you specifically want a per-type formatter registry configured on
RefitSettings(rather than a customIUrlParameterFormatterthat switches on the value type), that is a separate enhancement - please open a new issue for it.glennawatson commentedon Jul 14, 2026
Opened #2219 to track the optional follow-up: a per-type IUrlParameterFormatter registry on RefitSettings, so custom URL formatting for a specific type does not require a hand-rolled type switch in a custom formatter.
glennawatson commentedon Jul 15, 2026
This is addressed in the Refit 14 beta, now available on NuGet: https://www.nuget.org/packages/Refit/14.0.0-beta.1
Please give it a try - feedback ahead of the stable 14.0.0 release is very welcome.
rmja commentedon Jul 20, 2026
This seems to works just fine, thank you!
github-actions commentedon Aug 4, 2026
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.