RicoSuter / NSwag

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

nswag openapi2csclient generates class twice - compilation error #4845

Open srad opened 3 months ago

srad commented 3 months ago

I just updated from 13.19.0 to 14.0.7 and it seems that the swagger2csclient has been removed. I switched to openapi2csclient now, but the generated code is vaulty. It generates the client class twice into the same file and hence causes an compilation error.

The command I ran: .\nswag\Net80\dotnet-nswag.exe openapi2csclient /input:http://somewhere:1234/swagger/v1/swagger.json /classname:MyApiClient /namespace:SomeWhere.Clients /output:.\Somewhere\Clients\MyApiClient.cs

here is the generated code. I collapsed everything except of the classes and the entire code is inserted twice:

openapi2csclient_client_generated_twice_2

j-hap commented 2 months ago

When you define a single class name, but there are multiple endpoints in the openapi description with overlapping names, those are generated inside the same class, which yields duplicate code, see https://github.com/RicoSuter/NSwag/issues/2660