Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swashbuckle + XmlComments work locally, but fail swagger generation on server

I have a webapi project, and I am utilizing the swashbuckle framework to flush out api documentation.

I have followed the directions to build the documentation xml file with my controller and DTO's, and it all works great locally.

However, when generating the swagger document, a 500 error is thrown. I have confirmed if i remove my xml registration line, the swagger doc is generated and returned successfully.

here is my registration line:

GlobalConfiguration.Configuration.EnableSwagger(c =>
                    { 
...
    c.IncludeXmlComments($"{System.AppDomain.CurrentDomain.BaseDirectory}bin\\Company.MyApp.xml");
...

Update: I did some additional logging, and while this lne for IncludeXmlComments runs through successfully on startup, when I request the swagger.json file from the server, I am getting a System.IO.FileNotFoundException: Could not find file 'D:\home\site\wwwroot\bin\Monetary.Scheduling.xml' exception. when I use the Kudu tools to look into this directory, I cannot find this file.

TL;DR: Why is this file showing up fine locally, but when I deploy to Azure using Kudu or a Octopus nugget package, this file is not there?

like image 887
Nathan Tregillus Avatar asked Nov 27 '22 07:11

Nathan Tregillus


1 Answers

The problem is that somehow the XML file is not making it to your server... I had this exact issue with an Azure deployment it worked fine in my local machine but not in azure

...and it was because I was missing the XML doc in the release config

Debug

Release

like image 99
Helder Sepulveda Avatar answered Dec 10 '22 19:12

Helder Sepulveda