WebApi Help Page Description

后端 未结 3 1511
长发绾君心
长发绾君心 2020-12-04 17:36

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

<script

3条回答
  •  囚心锁ツ
    2020-12-04 17:58

    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")));
    

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

    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:

    /// 
    /// Gets some very important data from the server.
    /// 
    public IEnumerable Get()
    {
        return new string[] { "value1", "value2" };
    }
    
    /// 
    /// Looks up some data by ID.
    /// 
    /// The ID of the data.
    public string Get(int id)
    {
        return "value";
    }
    

提交回复
热议问题