I have a problem with swagger, it seems that it does not include the xml file of the api when it is published. I have a WebApi2 and when publishing the project in azure the api opens correctly but when trying to enter swagger it shows me the following error:
500 : {"Message":"An error has occurred."} https://api.azurewebsites.net/swagger/docs/v1
The xml file is located in the bin folder and for this in the properties of the api I added the following configuration inside the compilation:
And I have the swagger configuration file inside the App_Start folder, there I have the method to obtain the path as follows:
private static string GetXmlCommentsPath()
{
return Path.Combine(System.Web.HttpRuntime.AppDomainAppPath,"bin","api.xml");
}
Only when I post the api, swagger doesn't work. But when compiling on localhost it works.
If it works for you on localhost, you are probably forgetting to add the
release
xml file to the launch configuration. When you enter the properties of the api you must take into account not onlydebug
but alsorelease
when you are going to publish the api in azure.