如何使用Swashbuckle记录查询字符串参数?

时间:2017-12-18 14:03:00

标签: c# xml documentation query-string swashbuckle

Swashbuckle在提取C#XML注释以制作Swagger API文档方面做得很好。 Swagger支持记录查询字符串参数。但是,如果有一种方法可以用XML记录查询字符串参数,那么Swashbuckle会将它们导出,我还没有找到它。

我有类似的东西:

    /// <summary>
    /// List all users
    /// </summary>
    /// <param name="?search">String to search for in user IDs and names</param>
    /// <returns>An array of users</returns>
    /// <response code="200">OK</response>
    [ResponseType(typeof(IEnumerable<User>))]
    [Route("")]
    [HttpGet]
    public IHttpActionResult ListUsers()
    {
        IEnumerable<User> users;

        // "?search=<substring>" in the URI searches for users
        // Adapted from https://stackoverflow.com/questions/10656841
        var searchString = Request.GetQueryNameValuePairs()
            .Where(nv => nv.Key == "search")
            .Select(nv => nv.Value)
            .DefaultIfEmpty("")
            .FirstOrDefault();

并且search未显示在输出中。我尝试删除?,但没有帮助。我怀疑XML评论不直接支持这一点。如果这是真的,我正在寻找最佳实践工作。我考虑在<remarks>块中添加几个子弹。有更好的想法吗?

1 个答案:

答案 0 :(得分:1)

@jps指出了我正确的方向。谢谢!

我最终得到了:

ggplot() +
  geom_rect(
    aes(xmin = start
        , xmax = end
        , fill = label
        , ymin = 0
        , ymax = 4)
    , move_one
  ) +
  geom_hline(aes(yintercept = ind)
             , move_two) +
  geom_rect(
    aes(xmin = start
        , xmax = end
        , fill = label
        , ymin = ind - 1/3
        , ymax = ind + 1/3)
    , move_two
  ) +
  xlab("Time (milliseconds)") +
  ylab("Area")
相关问题