Summary
Refit's [Query] always emits key=value. There's no way to emit a valueless query flag — a bare ?filter with no = — which some APIs use for presence-style switches.
Prior art: Retrofit @QueryName
Retrofit has @QueryName: the parameter value becomes the query parameter name with no value. A List/array produces multiple bare flags (?a&b&c). encoded=true disables encoding of the name.
Proposal
Add an equivalent — most naturally a small attribute (e.g. [QueryName]) or an option on [Query] — that renders the parameter's string value as a valueless query segment. Collections render as repeated bare names. Honour the existing query encoding/URI-format settings.
Considerations
- Interaction with
UrlResolutionMode and QueryUriFormatAttribute.
- Null handling: omit on null (consistent with
[Query]).
- Must be implemented in both the reflection and source-generator paths.
- Decide attribute-vs-
[Query]-option; a separate attribute reads clearer and matches Retrofit.
Acceptance criteria
- A parameter renders as a bare
?name flag; collections render as repeated names.
- Works in reflection + generated paths.
- TUnit tests for scalar and collection cases; README/docs entry.
Pointers
- Query building:
src/Refit/RequestBuilderImplementation.QueryAndHeaders.cs and .Helpers.cs.
- Attribute examples to mirror:
src/Refit/QueryAttribute.cs.
- Generator:
src/InterfaceStubGenerator.Shared/*.
- Retrofit reference:
~/square/retrofit/retrofit/src/main/java/retrofit2/http/QueryName.java.
Summary
Refit's
[Query]always emitskey=value. There's no way to emit a valueless query flag — a bare?filterwith no=— which some APIs use for presence-style switches.Prior art: Retrofit
@QueryNameRetrofit has
@QueryName: the parameter value becomes the query parameter name with no value. AList/array produces multiple bare flags (?a&b&c).encoded=truedisables encoding of the name.Proposal
Add an equivalent — most naturally a small attribute (e.g.
[QueryName]) or an option on[Query]— that renders the parameter's string value as a valueless query segment. Collections render as repeated bare names. Honour the existing query encoding/URI-format settings.Considerations
UrlResolutionModeandQueryUriFormatAttribute.[Query]).[Query]-option; a separate attribute reads clearer and matches Retrofit.Acceptance criteria
?nameflag; collections render as repeated names.Pointers
src/Refit/RequestBuilderImplementation.QueryAndHeaders.csand.Helpers.cs.src/Refit/QueryAttribute.cs.src/InterfaceStubGenerator.Shared/*.~/square/retrofit/retrofit/src/main/java/retrofit2/http/QueryName.java.