I am using NSwag to generate C# rest client for my asp.net core web API.
At the moment, I just need to generate the client interfaces and not the classes themselves.
I tried the following settings to generate 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);
}
This does not look intuitive but I managed to get just interfaces with following configuration.
var settings = new TypeScriptClientGeneratorSettings
{
GenerateClientClasses = false,
GenerateDtoTypes = true,
GenerateClientInterfaces = true,
TypeScriptGeneratorSettings =
{
TypeStyle = NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeStyle.Interface
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With