Swashbuckle + XmlComments在本地工作,但无法在服务器上生成摇摇欲坠 [英] Swashbuckle + XmlComments work locally, but fail swagger generation on server

查看:52
本文介绍了Swashbuckle + XmlComments在本地工作,但无法在服务器上生成摇摇欲坠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个webapi项目,并且我正在使用swashbuckle框架来刷新api文档.

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

我已经按照说明使用控制器和DTO来构建文档xml文件,并且在本地都可以很好地工作.

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

但是,生成摇摇欲坠的文档时,会引发500错误.我已经确认是否删除了xml注册行,生成了大张旗鼓的文档,并成功返回了.

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.

这是我的注册热线:

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

更新:我做了一些附加的日志记录,并且在启动时成功运行了IncludeXmlComments的此lne,当我从服务器请求swagger.json文件时,我得到的是 System.IO.FileNotFoundException:找不到文件'D:\ home \ site \ wwwroot \ bin \ Monetary.Scheduling.xml'异常.当我使用Kudu工具查看该目录时,找不到此文件.

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:为什么此文件在本地显示良好,但是当我使用Kudu或Octopus块软件包部署到Azure时,此文件不存在?

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?

推荐答案

问题是XML文件无法以某种方式将其发送到您的服务器...我遇到了一个与Azure部署有关的确切问题,它在我的本地计算机上工作正常,但在天青状态下却不是

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

...这是因为我在发布配置中缺少XML文档

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

这篇关于Swashbuckle + XmlComments在本地工作,但无法在服务器上生成摇摇欲坠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆