如果您仍然有问题,请参阅以下步骤。
第 1 步 - 在控制器级别添加注释
// GET api/documentation
/// <summary>
/// This is how we create a documentation
/// </summary>
/// <returns></returns>
public IEnumerable<string> Get()
第 2 步 - 构建属性
项目属性页面并设置文档的 xml 输出
第 3 步 - 帮助页面配置
要设置 HelpPageConfig 以使用我们的文档 xml 文件,请转到~\Areas\HelpPage\HelpPageConfig.cs
.
默认情况下,config.SetDocumentationProvider 语句被注释掉。使用该语句,并将 DocumentationProvider 的位置指向我们的 xml 文件:
public static void Register(HttpConfiguration config)
{
// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(
new XmlDocumentationProvider(
HttpContext.Current.Server.MapPath("~/App_Data/Documentation.xml")));
}
编辑:
VS2013新建的Web API 2.2项目中HelpPageConfig的位置是~\Areas\HelpPage\App_Start\HelpPageConfig.cs