Swashbuckle does a great job of extracting C# XML comments to make Swagger API documentation. And Swagger supports documenting query string parameters. But if there's a way to document query string parameters in XML so Swashbuckle will export them, I haven't found it.
I have something like:
/// <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();
And search does not show up in the output. I tried removing the ? and that didn't help. I suspect that the XML comments just don't support this directly. If that's true, I'm looking for a Best Practice work around. I'm considering adding a couple of bullets in a <remarks> block. Any better ideas?
searchparameter to theListUsersmethod?ListUsers()method that could work but I'm relatively new to C#.Net and don't know (how) to do that.public IHttpActionResult ListUsers(string search)should do the trick. It will be set from the query string.