{"id":39,"date":"2017-03-05T13:56:00","date_gmt":"2017-03-05T19:56:00","guid":{"rendered":"https:\/\/www.chrystalsander.com\/blog\/?p=39"},"modified":"2023-07-26T12:56:01","modified_gmt":"2023-07-26T17:56:01","slug":"net-adding-custom-asp-net-webapi-help-page","status":"publish","type":"post","link":"https:\/\/www.chrystalsander.com\/blog\/?p=39","title":{"rendered":".NET :  Adding custom ASP.NET WebApi Help Page"},"content":{"rendered":"<p>\n1. &nbsp;Add annotations to model, controller, etc. using System.ComponentModel.DataAnnotations<br \/>\n2. &nbsp;Navigate to project &#8220;Properties&#8221; &#8211;&gt; &#8220;Build&#8221; &#8211;&gt; Output<br \/>\n3. &nbsp;Check &#8220;XML Documentation file:&#8221;, then type in a name for the help document xml, and save<br \/>\n4. &nbsp;In the solution, navigate to &#8220;Areas&#8221; &#8211;&gt; &#8220;App_Start&#8221; &#8211;&gt; &#8220;HelpPageConfig.cs&#8221;<br \/>\n5. &nbsp;Uncomment the &#8220;config.SetDocumentationProvider&#8230;&#8221; line, add your created name for the help document xml, and save:<br \/>\n<span style=\"white-space: pre;\">  <\/span>config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath(&#8220;~\/App_Data\/DevOpsTaskHelp.XML&#8221;)));<br \/>\n6. &nbsp;Build solution, navigate to help page &#8220;API&#8221;, and your annotations should be present.<\/p>\n<p>\nAdding XML WebApi Comments To Swagger:<br \/>\n1. &nbsp;Install-Package &#8220;Swashbuckle&#8221;<br \/>\n2. &nbsp;Open the &#8220;SwaggerConfig.cs&#8221; file and uncomment the following line:<br \/>\n<span style=\"white-space: pre;\">   <\/span>c.IncludeXmlComments(GetXmlCommentsPath());<br \/>\n3. &nbsp;Generate method for &#8220;GetXmlCommentsPath()&#8221;<br \/>\n<span style=\"white-space: pre;\">  <\/span> private static string GetXmlCommentsPath()<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return System.String.Format(@&#8221;{0}binDevOpsTaskHelp.XML&#8221;, System.AppDomain.CurrentDomain.BaseDirectory);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>\nREFERENCE(S):<br \/>\n<a href=\"https:\/\/docs.microsoft.com\/en-us\/aspnet\/web-api\/overview\/getting-started-with-aspnet-web-api\/creating-api-help-pages\">https:\/\/docs.microsoft.com\/en-us\/aspnet\/web-api\/overview\/getting-started-with-aspnet-web-api\/creating-api-help-pages<\/a><br \/>\n<a href=\"https:\/\/blogs.msdn.microsoft.com\/yaohuang1\/2012\/09\/30\/asp-net-web-api-help-page-part-1-basic-help-page-customizations\/\">https:\/\/blogs.msdn.microsoft.com\/yaohuang1\/2012\/09\/30\/asp-net-web-api-help-page-part-1-basic-help-page-customizations\/<\/a><\/p>\n<div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. &nbsp;Add annotations to model, controller, etc. using System.ComponentModel.DataAnnotations 2. &nbsp;Navigate to project &#8220;Properties&#8221; &#8211;&gt; &#8220;Build&#8221; &#8211;&gt; Output 3. &nbsp;Check &#8220;XML Documentation file:&#8221;, then type in a name for the help document xml, and save 4. &nbsp;In the solution, navigate to &#8220;Areas&#8221; &#8211;&gt; &#8220;App_Start&#8221; &#8211;&gt; &#8220;HelpPageConfig.cs&#8221; 5. &nbsp;Uncomment the &#8220;config.SetDocumentationProvider&#8230;&#8221; line, add your created name &hellip; <a href=\"https:\/\/www.chrystalsander.com\/blog\/?p=39\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;.NET :  Adding custom ASP.NET WebApi Help Page&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,23,17],"tags":[65,77,68],"_links":{"self":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/39"}],"collection":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=39"}],"version-history":[{"count":1,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":213,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions\/213"}],"wp:attachment":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}