• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Swashbuckle + XmlComments 在本地工作,但在服务器上生成招摇失败

用户头像
it1352
帮助1

问题说明

我有一个 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?

正确答案

#1

问题是 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

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfkbbc
系列文章
更多 icon
同类精品
更多 icon
继续加载