2

guys:

I use swagger to make api document. I use ASP.NET WebAPI2 to develop WebAPI. And I met three questions:

First: How could I Add Comments for the WebAPI Controller? I try to add Comment on Controller

namespace IMCAPI.Controllers
{
/// <summary>
/// Value API
/// </summary>
[Authorize]
public class ValuesController : ApiController
{
    // GET api/values
    /// <summary>
    /// Get all Values
    /// </summary>
    /// <returns></returns>
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }

, but not work.

Second:How could I search specific WebAPI in Swagger by brower Url? like this Browser Url Search

For example, if I want to search Value API, I input Value in the red section,I want the search result would just show Value API, I don't want other API appears(like Account). Or how to setting SwaggerConfig.cs that can have the search function?

Third:I want to know whether swagger could just read one xml file? I search the Internet, they demo like this

    private static string GetXmlCommentsPath()
    {
        return String.Format("{0}/App_Data/IMCAPI.XML", AppDomain.CurrentDomain.BaseDirectory);
    }

If I have multiple XML file, how could I integrate in the swagger?

that it. Hope somebody can help me. Thank you!

K.Shuan
  • 21
  • 3

1 Answers1

1

Your first question: The comments are appearing, you've put them on the Get method in your code, they're appearing on the Get method in your screenshot. If what you want is a description of the whole service, the Swagger documentation says to use the Description method.

Your second: You can't it shows all the methods on that API.

Third: The Swagger documentation says you call IncludeXmlComments multiple times with the path to each XML.

Paul
  • 1,188
  • 1
  • 11
  • 21