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

无人久伴 提交于 2019-12-20 04:24:21

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/45465963/swashbuckle-xmlcomments-work-locally-but-fail-swagger-generation-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!