Posts

Showing posts from December, 2019

ASP.NET Web API configuration with Swagger

Set XML file path:                         var xmlFile = $"bin/{Assembly.GetExecutingAssembly().GetName().Name}.xml";                         var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);                         c.IncludeXmlComments(xmlPath); References: https://www.c-sharpcorner.com/article/implement-swagger-ui-with-web-api/ https://stackoverflow.com/questions/37724666/how-to-redirect-from-root-url-to-swagger-ui-index public class WebApiConfig { public static void Configure ( IAppBuilder app ) { var httpConfig = new HttpConfiguration (); // Attribute routing config . MapHttpAttributeRoutes (); // Redirect root to Swagger UI config . Routes . MapHttpRoute ( name : "Swagger UI" , routeTemplate : "" , defaults : null , constraints : null , handler : new RedirectHandler ( SwaggerDocsCo