Dynamic QueryParams type is incorrectly shared by GET endpoints with the same method name across different controllers
enhancement
## Description
When using `--multiple-interfaces ByTag` together with `--use-dynamic-querystring-parameters`, GET endpoints from different controllers are assigned the same generated QueryParams type when their generated method names are identical.
For example:
```text
/MachineTool/Page
/Material/Page
/ProductionOrder/Page
```
Using the following command:
```bash
refitter http://localhost:23414/swagger/v1/swagger.json \
--output ../Test.Base/Core/RefitClients \
--multiple-interfaces ByTag \
--namespace Test.Base.Core.RefitClients \
--operation-name-generator MultipleClientsFromPathSegments \
--operation-name-template "{operationName}Async" \
--multiple-files \
--use-dynamic-querystring-parameters
```
All three endpoints generate a method named:
```csharp
PageAsync(...)
```
Having the same method name is valid because each method is located in a different generated interface.
However, Refitter also generates the QueryParams type name only from the method name:
```csharp
PageAsyncQueryParams
```
As a result, all interfaces reference the same QueryParams class:
```csharp
public interface IMachineToolApi
{
[Get("/MachineTool/Page")]
Task<MachineToolVOPageResultApiResult> PageAsync(
[Query] PageAsyncQueryParams queryParams);
}
public interface IMaterialApi
{
[Get("/Material/Page")]
Task<MaterialVOPageResultApiResult> PageAsync(
[Query] PageAsyncQueryParams queryParams);
}
public interface IProductionOrderApi
{
[Get("/ProductionOrder/Page")]
Task<ProductionOrderVOPageResultApiResult> PageAsync(
[Query] PageAsyncQueryParams queryParams);
}
```
This does not necessarily cause a compilation error because only one `PageAsyncQueryParams` type may be generated or reused.
The problem is that these endpoints can have different query parameters, but they are all forced to use the same generated parameter type. This can result in an incorrect method signature and an incorrect set of available query parameters for one or more endpoints.
## Expected behavior
Each endpoint should receive its own QueryParams type, even when the generated method names are identical.
For example:
```csharp
public interface IMachineToolApi
{
Task<MachineToolVOPageResultApiResult> PageAsync(
[Query] MachineToolPageAsyncQueryParams queryParams);
}
public interface IMaterialApi
{
Task<MaterialVOPageResultApiResult> PageAsync(
[Query] MaterialPageAsyncQueryParams queryParams);
}
public interface IProductionOrderApi
{
Task<ProductionOrderVOPageResultApiResult> PageAsync(
[Query] ProductionOrderPageAsyncQueryParams queryParams);
}
```
A possible naming pattern would be:
```text
{interfaceName}{methodName}QueryParams
```
or:
```text
{tag}{methodName}QueryParams
```
关闭于 2026-07-23 2 条评论