0

I have a Web project with different API controllers.

When creating the client using NSwag, all methods from all controllers are put in the same API Client.

How could I get one ApiClient per API controller?

Thanks in advance.

tht
  • 1
  • 1

3 Answers3

1

Put this in you nswag configuration under codeGenerators.openApiToCSharpClient -> "operationGenerationMode": "MultipleClientsFromOperationId"

Jorn.Beyers
  • 1,784
  • 2
  • 21
  • 26
0

You need to change the operationGenerationMode in your nswag.json file to have the value MultipleClientsFromOperationId. See here for an example project that generates a client class per API controller, specifically here for the option you need to change

Daniel
  • 150
  • 1
  • 9
0

i know it's too late, but now i encountered a similiar problem so the answer is with typescript client

"openApiToTypeScriptClient": {
      "operationGenerationMode": "MultipleClientsFromPathSegments",

.
}

this line make every controller a class in api

manora
  • 23
  • 7