最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net core - How to hide the Links column in the Swagger UI Responses section - Stack Overflow

programmeradmin0浏览0评论

Is there a way to hide the Links column in the Swagger Responses section of the endpoints? We do not use links in the APIs and it just wastes space, so would like to get them gone from all endpoints.

Using ASP.NET Core with 8. I looked around but could not find any articles other than the ones explaining what OpenAPI links are for.

Is there a way to hide the Links column in the Swagger Responses section of the endpoints? We do not use links in the APIs and it just wastes space, so would like to get them gone from all endpoints.

Using ASP.NET Core with 8. I looked around but could not find any articles other than the ones explaining what OpenAPI links are for.

Share Improve this question edited Feb 4 at 15:49 Jeremy Fiel 3,3072 gold badges11 silver badges26 bronze badges asked Feb 4 at 1:31 Alek DavisAlek Davis 10.8k3 gold badges45 silver badges56 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

According to your description, I suggest you could create a custom CSS and inject it to your swagger UI to hide the link tab.

More details, you could refer to below codes:

1.Create a wwwroot folder , a swagger-ui folder and CSS file with below codes:

.swagger-ui .response-col_links {
    min-width: 6em;
    display: none;
}

2.Modify the Program.cs as below:

var app = builder.Build();

app.UseStaticFiles();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI(c =>
    {
        c.InjectStylesheet("/swagger-ui/custom.css");
    });
}
 ....

Result:

发布评论

评论列表(0)

  1. 暂无评论