我正在使用NSwag为我的C#核心web生成asp.net rest客户端。目前,我只需要生成客户端接口,而不是类本身。我尝试了以下设置以仅生成C#客户端接口,但它既不生成也不生成类,也不生成接口。
GenerateClientClasses = false
GenerateClientInterfaces = true
我的设置有什么问题吗?
此外,是否有任何方法可以扩展或更改客户端接口的生成代码。例如,我如何使用一些自定义属性来注释客户端接口方法?例如:
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);
}
发布于 2021-10-08 05:05:31
这看起来并不直观,但我设法只使用以下配置获得了接口。
var settings = new TypeScriptClientGeneratorSettings
{
GenerateClientClasses = false,
GenerateDtoTypes = true,
GenerateClientInterfaces = true,
TypeScriptGeneratorSettings =
{
TypeStyle = NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeStyle.Interface
}
};
https://stackoverflow.com/questions/63973105
复制相似问题