Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

470
Views
Using NSwag to generate a C# client incorrectly creates 2x partial classes with the same name, in the same file

I'm trying to generate an NSwag C# Client, from an OpenAPI json file.

When I do this, I do get a client file generated, but it doesn't compile. It has created 2x partial classes in the same .cs file.

enter image description here

Now, if I change one of these class names to anything else, the file can now compile:

enter image description here

No errors - compiles OK.

So my question is: why is this doing it?

Here's a picture of my Swagger UI (this was generated with Swashbuckle, not NSwag):

enter image description here

So this means I have 2x controllers in the project:

  • HomeController
  • DocumentsController

Is there some trick to fixing this?

I used the following command line, to generate the client:

dotnet-openapi --updateProject .\MyProject.csproj http://localhost:5100/swagger/v1/swagger.json

Dotnet-openapi is using NSwag CSharpClientGenerator "under the hood", as far as I believe.

I'm happy to use any other tool to generate a C# client.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!