Let's say I have this class defined:
public class Animal
{
public int RegId {get;set;}
public string Name {get;set;}
}
And I need to expose it to an remote part of my system ( a client app in another location, for example ) and I decided to use OpenAPI to make the communication.
The controller code is something like:
[HttpGet("GetLivingCargo")]
public async Task<IEnumerable<Animal>> GetLivingCargo()
{
return await pFacade.GetLivingCargo();
}
Swagger generates the documentation all well. When I generate the API client to use in the remote app, all times I have that class duplicated (so there's my original class and the generated client's exactly equal class).
How I can avoid it, without having to manually write the API client myself to use my original class?
Finally I found a way to make NSwagStudio reuse my Model classes.
Step-by-Step:
For those who do not want an all-or-nothing approach, with Generate DTO Types checked, you can exclude certain types by filling the (comma-separated) list of types to be excluded in Exclude Type Names configuration setting.