swagger--Failed to load API definition.

Posted Zev_Fung

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swagger--Failed to load API definition.相关的知识,希望对你有一定的参考价值。

 

 

 

 打开

http://localhost:5000/swagger/v1/swagger.json

 

提示错误

An unhandled exception occurred while processing the request.
NotSupportedException: HTTP method "GET" & path "api/Report/ExportUserRegisterData" overloaded by actions - XXX.Application.Report.ReportApplication.ExportUserRegisterData (XXX.Application),XXX.Application.Report.ReportApplication.ExportUserRegisterData (XXX.Application). Actions require unique method/path combination for Swagger 2.0. Use ConflictingActionsResolver as a workaround
Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable<ApiDescription> apiDescriptions, ISchemaRegistry schemaRegistry)

 

原因

有Get类型的重载的接口方法

 

解决方法

options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());

意思是swagger只会取其中一个Action

具体位置

//自动生成Api文档
            services.AddSwaggerGen(options =>
            {
                options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
            });

 

以上是关于swagger--Failed to load API definition.的主要内容,如果未能解决你的问题,请参考以下文章

解决swagger Failed to load API definition 问题

解决swagger Failed to load API definition 问题

解决swagger Failed to load API definition 问题

架构How To Use HAProxy to Set Up MySQL Load Balancing

Unable to load dispatcher.filter.StrutsPrepareAndExecuteFilter

Failed to load JavaHL Library解决方法