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

查看:19
本文介绍了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.

但是,在生成 swagger 文档时,会抛出 500 错误.我已经确认如果我删除我的 xml 注册行,就会生成并成功返回 swagger 文档.

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:homesitewwwrootinMonetary.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:homesitewwwrootinMonetary.Scheduling.xml' exception. when I use the Kudu tools to look into this directory, I cannot find this file.

TL;DR:为什么这个文件在本地显示很好,但是当我使用 Kudu 或 Octopus nugget 包部署到 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 部署中遇到了这个确切的问题,它在我的本地机器上运行良好,但在 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天全站免登陆