【问题标题】:swagger.json link not showing up in swagger pageswagger.json 链接未显示在 swagger 页面中
【发布时间】:2021-08-04 22:46:50
【问题描述】:

通过我的设置,我的 swagger 页面上没有用于检索 swagger.json 文件的链接。出现swagger页面,通过swagger页面可以看到我的API并对其进行调用,但是我没有swagger.json文件链接。在底部的图像中有一个链接(不是我的页面,是别人的)。如何更改我的设置以显示此链接?服务器由WebApp.Start<WebApi>(url); 行启动,下面是我的设置a

    public void Configuration(IAppBuilder app)
    {

        var config = new HttpConfiguration();
        config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
        config.MapHttpAttributeRoutes();
        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        config.EnableSwagger(c =>
        {
            c.SingleApiVersion("v1", "stuff");
        })
            .EnableSwaggerUi(c =>
            {
                c.DocumentTitle("Swagger UI");
            });
        

        app.UseWebApi(config);

        app.UseCors(CorsOptions.AllowAll);
    }

还有我的 UI 截图(注意没有指向 swagger.json 的链接):

【问题讨论】:

  • 你能发一张你的 Swagger UI的截图吗? Swashbuckle for WebAPI 可能使用的是具有不同设计的旧版本。
  • 已添加,有没有更新的版本可以用于 .net 框架?

标签: .net swagger swashbuckle


【解决方案1】:

Swashbuckle for WebAPI 使用旧的 Swagger UI 版本 (2.x),它在标题中显示 API 定义 URL - 在您的示例中为 http://localhost:34330/swagger/docs/v1

【讨论】:

    猜你喜欢
    • 2019-08-04
    • 2022-07-07
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    • 2022-12-26
    • 2013-04-07
    • 1970-01-01
    相关资源
    最近更新 更多