【问题标题】:documentation of the swagger this returning this error 500大摇大摆的文档返回此错误 500
【发布时间】:2017-10-17 16:42:58
【问题描述】:

InvalidOperationException:冲突的 schemaIds:检测到类型 BTBTems.DataModel.Ticket.ChamadoDM 和 BTBTems.DataModel.Chamado.ChamadoDM 的相同 schemaIds。请参阅配置设置 - “UseFullTypeNameInSchemaIds”或“CustomSchemaIds”以了解解决方法

【问题讨论】:

  • 启动 public void ConfigureServices(IServiceCollection services) { services.AddSwaggerGen(c => c.SwaggerDoc("v1", new Info { Title = "Core Api", Description = "Swagger Core Api" } )); } 公共无效配置(IApplicationBuilder 应用程序,IHostingEnvironment 环境,ILoggerFactory loggerFactory){ app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Core Api"); }); }

标签: c# asp.net-web-api2 swagger swagger-ui


【解决方案1】:

更新您的 swagger 配置文件 (..\AppStart\SwaggerConfig.cs) 以调用 c.UseFullTypeNameInSchemaIds():

         GlobalConfiguration.Configuration 
            .EnableSwagger(c =>
                {
                    //....
                    c.UseFullTypeNameInSchemaIds();  // <-- add this
                    //....
                })
            .EnableSwaggerUi(c =>
                {

                });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 2018-11-29
    • 2014-07-19
    • 2015-12-14
    • 1970-01-01
    • 2018-12-21
    • 1970-01-01
    相关资源
    最近更新 更多