Ale, music and enjoying life.
Decided to take the plunge and update a fairly sizeable WebAPI with OData and Swagger to .Net Core 3.1. Why the hell would you do this you may ask? Well to take advantage of 3.1’s endpoint routing and OData’s recent support for this with OData 7.40. Inspired by Hassan Habib’s blog entry on Microsoft Dev blogs and decided to go for it.
Surely decorating the API method in question with Summary attributes would make it’s way through to the Swagger API documentation? After a bit of head scratching and googling I realised I was just a step away from achieving this. I needed to enable the Build Output “XML Documentation file” in the projects build properties. Give the XML a sensible name i.e bin\WebApiSwagger.XML .
Finally, in the SwaggerConfig.cs create yourself a method:-
protected static string GetXmlCommentsPath()
{
return System.String.Format(@”{0}\bin\WebApiSwagger.XML”, System.AppDomain.CurrentDomain.BaseDirectory);
}