Swagger.NET MVC API 异常

Swagger.NET MVC Api Exception(Swagger.NET MVC API 异常)
本文介绍了Swagger.NET MVC API 异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找提供自动生成的 API 文档的不同选项,而 Swagger 似乎就在那里.

I've been looking at different options for providing auto generated API Documentation and Swagger seems to be up there.

但是,当我第一次尝试这个时,我在启动时遇到异常.

However when trying this out for the first time I'm getting exceptions on start up.

运行 Visual Studio 2013.
创建新的 Web API 项目.
使用包管理器,运行:

Running Visual Studio 2013.
Create new Web API project.
Using Package Manager, run:

Install-Package Swagger.Net & Install-Packager Swagger.Net.UI

确保我们已启用 XML 文档,但我们会收到此异常:

Making sure we've enable the XML documentation we get this exception:

Method 'GetDocumentation' in type 'Swagger.Net.XmlCommentDocumentationProvider' 
from assembly 'Swagger.Net, Version=0.5.1.0, Culture=neutral, PublicKeyToken=null' 
does not have an implementation.

还有其他人知道我们缺少的步骤吗?我们发现 &跟着这个:
https://github.com/Swagger-Net/Swagger.Net/wiki
https://github.com/Swagger-Net/Swagger.net/blob/master/README.md

Does anyone else know of a step we are missing? We found & followed this:
https://github.com/Swagger-Net/Swagger.Net/wiki
https://github.com/Swagger-Net/Swagger.Net/blob/master/README.md

推荐答案

Swagger 不支持 .NET 4.5 - 必须从 git 中获取源代码并修改它以使用 4.5.

Swagger doesn't support .NET 4.5 - Had to get the source code out from git and modify it to work with 4.5.

右键单击项目并在其中设置目标框架

Right click the project and set the target framework in there

这篇关于Swagger.NET MVC API 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)