【发布时间】:2017-06-22 17:11:06
【问题描述】:
我有带有属性的 Web API 请求模型:
public List<Feature> Features { get; set; }
Feature 是一个抽象类。我会从它派生出很多类:
public abstract class Feature
{
public string Title { get; set; }
}
public class ImageFeature : Feature
{
public string ImageUrl { get; set; }
}
显然 Swashbuckle 仅识别 Feature 属性并相应地生成文档。如何明确声明 Feature 类的可能实现,以便 Swashbuckle 生成正确的文档?是否有一些我可以使用的属性,例如:
[SwaggerResponseType(typeof(ImageFeature))]
[SwaggerResponseType(typeof(AnotherFeature))]
public abstract class Feature
【问题讨论】:
-
可能重复:swagger inheritance
-
我使用这种方法 - stackoverflow.com/questions/34397349/…
标签: c# asp.net-web-api asp.net-core swagger swashbuckle