WebApi 帮助页面说明 [英] WebApi Help Page Description

查看:27
本文介绍了WebApi 帮助页面说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在帮助页面和介绍段落上填充 Webapi 方法的描述是什么?

What populates the Webapi method's description on the helper page and the introduction paragraph?

推荐答案

根据这个 文章 您可以使用 XML 文档注释来创建文档.要启用此功能,请打开文件 Areas/HelpPage/App_Start/HelpPageConfig.cs 并取消注释以下行:

According to this article you can use XML documentation comments to create the documentation. To enable this feature, open the file Areas/HelpPage/App_Start/HelpPageConfig.cs and uncomment the following line:

config.SetDocumentationProvider(new XmlDocumentationProvider(
    HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

现在启用 XML 文档.在解决方案资源管理器中,右键单击项目并选择属性.选择构建页面.

Now enable XML documentation. In Solution Explorer, right-click the project and select Properties. Select the Build page.

在输出下,检查 XML 文档文件.在编辑框中,输入App_Data/XmlDocument.xml".

Under Output, check XML documentation file. In the edit box, type "App_Data/XmlDocument.xml".

向控制器方法添加一些文档注释.例如:

Add some documentation comments to the controller methods. For example:

/// <summary>
/// Gets some very important data from the server.
/// </summary>
public IEnumerable<string> Get()
{
    return new string[] { "value1", "value2" };
}

/// <summary>
/// Looks up some data by ID.
/// </summary>
/// <param name="id">The ID of the data.</param>
public string Get(int id)
{
    return "value";
}

这篇关于WebApi 帮助页面说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆