我已经使用Microsoft.AspNet.WebApi.HelpPage和C#XML注释为我的Web API项目生成Web API文档,但是想要为每个方法添加JSON示例,并且无法弄清楚如何。
这是我方法的XML评论:
/// <summary>
/// Gets data values for a given data key.
/// </summary>
/// <param name="masterAgencyID">The MasterAgencyDivisionID for the desired values.</param>
/// <param name="masterClientID">The MasterClientID for the desired values.</param>
/// <param name="dataKeyCode">The DataKey's code for which values are to be returned.</param>
/// <returns>An object containing two lists: IncludedValues and ExcludedValues.</returns>
/// <example>
/// {
/// "IncludedValues": [
/// {
/// "DataValueID": 644,
/// "DataValueCode": "1000X500",
/// "DataValueShortDescr": "1000X500",
/// "excluded": false
/// },
/// ...
/// ],
/// "ExcludedValues": [
/// {
/// "DataValueID": 644,
/// "DataValueCode": "1000X500",
/// "DataValueShortDescr": "1000X500",
/// "excluded": true
/// },
/// ...
/// ]
/// </example>
如您所见,在“示例:”下,页面显示“示例不可用”。
显然不是从XML标签中读取。如何在API文档中包含示例?