找不到 XML 注释文件 - Swagger [英] XML comments file could not be found - Swagger

查看:25
本文介绍了找不到 XML 注释文件 - Swagger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这肯定是让你发疯的原因之一.正如标题所示,我只是想做的就是使用 swagger 显示从 xml 文件中提取的注释.

This is certainly one of those that drives you nuts. As the title indicates all I'm simply trying to do is display comments pulled from an xml file using swagger.

我似乎已根据 swagger 文档采取了所有步骤,但无济于事.希望各位好心人能给我指出正确的方向.

I appear to have taken all steps according to the swagger documentation but to no avail. Hopefully you kind folk can point me in the right direction.

采取的步骤:

确保文件存在:

配置的SwaggerConfig.cs

我也尝试过更改路径:@"bin/..xml"

I've tried changing the path too: @"bin/....xml"

似乎没有任何效果.

**错误找不到文件":**

**The Error "Could not find file": **

谁能指出我正确的方向?

Can anyone point me in the right direction please?

问候,

推荐答案

好的,所以我设法通过指向根目录来让它工作.

Ok, So I managed to get it to work by pointing to the root directory.

我仍然不知道为什么它无法检测到 bin 目录中的 xml 文件.这再次通过在根目录中添加一个 xml 文件来实现.

I still have no idea why it cannot detect the xml file in the bin directory. Again this worked by adding an xml file within the root.

代码更改:

var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
                        //var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";
                        var commentsFileName = "Comments" + ".XML";
                        var commentsFile = Path.Combine(baseDirectory, commentsFileName);

                        c.IncludeXmlComments(commentsFile);

这篇关于找不到 XML 注释文件 - Swagger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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