Web API Adventures – Part 1 – Swagger

One thing not immediately obvious with the Swagger API documentation was how to generate metadata particularly for any parameters required as part of an API call.

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 .

swagger out

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

and uncomment the following line:



That’s it you’re good to go.  Took a bit of digging and thinking as this approach isn’t wildly documented.

Leave a Reply

%d bloggers like this: