RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.72k stars 1.29k forks source link

Flux in client method naming for c# client. #4827

Open pbnobly opened 6 months ago

pbnobly commented 6 months ago

Thanks for a great tool, except:

When using SingleClientFromPathSegments , client methods are susceptible to change since NSwag will only include the HTTP method in client method names when there is a name conflict, e.g., if there is a GET and a POST method with the same signature.
So, if there is no signature conflict for a method and another endpoint is added with the same signature but a different HTTP method, the original client method name will change, i.e., it will subsequently include the HTTP method in its name.
E.g. if only a GET method exists for the endpoint Document, this would generate a DocumentAsync client method, but if a POST method were added, the DocumentAsync client method name would change to DocumentGetAsync.
This means that method signatures in a newly generated client always need to be compared to the ones in an existing client to detect whether any client method signatures should have changed.
Changed method signatures will then need to be modified accordingly in any consuming code, resulting in a bit of a maintenance nightmare.

This could be fixed by adding a setting, e.g., AlwaysIncludeHttpMethodInClientMethodNames.