RicoSuter / NSwag

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

Is it possible to generate C# client interfaces and annotate their methods with some custom attributes? #3066

Open jsayari opened 3 years ago

jsayari commented 3 years ago

Hi there, I tried the following setting for generating just C# client interfaces but it does not generate nor classes neither interfaces .

    GenerateClientClasses = false 
    GenerateClientInterfaces = true

Is there anything wrong with my settings?

Also, Is there any way to extend or change the generated code of the client interfaces. For example how I can annotate the client interface methods with some custom attributes? For example:

public partial interface IGetEmployeeByIdClient
{
    // How to add the following custom attributes to the generated client interface method
    [MyCustomerAttribute("/api/v1/GetEmployeeById/{id}"] )
    System.Threading.Tasks.Task<GetEmployeeByIdQueryResult> GetEmployeeByIdAsync(string id);  
}
RicoSuter commented 3 years ago

You should be able to overwrite/enhance the templates with your custom attributes: https://github.com/RicoSuter/NSwag/wiki/Templates