【问题标题】:Swagger Swashbuckle routes blockingSwagger Swashbuckle 路线阻塞
【发布时间】:2019-11-16 16:07:24
【问题描述】:

所以我从这里创建了研讨会应用程序:

(the link redirects to problematic part)

我开始在 ASP.Net Core 3.0 应用程序中配置 swashbuckle。 UI 本身可以工作,但是

我无法访问我在控制器中定义的路由并在 URL 中获取它们,因为尽管路由是在 https://localhost:5001/swagger/v1/swagger.json 中定义的,但所有内容都重定向到 https://localhost:5001/swagger/index.html

所以我无法访问例如:https://localhost:5001/api/Speakers 或任何其他路由,因为所有内容都重定向到 https://localhost:5001/swagger/index.html,并且这些路由在没有大摇大摆的情况下工作正常。

只有https://localhost:5001/swagger/v1/swagger.json 有效且索引

如何让每个 url 都可以访问?

我的swashbuckle配置和链接里的一模一样

我的数据包:Swashbuckle.AspNetCore version 5.0.0-rc4
另外,该指南适用于 net.core 2.2,我使用的是 3.0,但在招摇之前一切正常

【问题讨论】:

    标签: c# asp.net swagger swashbuckle asp.net-core-3.0


    【解决方案1】:

    好的,我只需将方法app.UseSwaggerUIapp.UseSwaggerapp.Run 分别放在Startup.Configure 方法的末尾即可解决。

    这也解决了在/swagger/index.html 中执行 HTTP 请求的另一个问题 - 无法执行诸如通过 POST 将对象输入数据库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-04
      • 2014-10-03
      • 2016-01-27
      • 1970-01-01
      相关资源
      最近更新 更多