Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
831 views
in Technique[技术] by (71.8m points)

openapi - NSwag - create one client per API controller

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...