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

admin2025-04-16  4

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 .net 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,3712 gold badges13 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:

转载请注明原文地址:http://anycun.com/QandA/1744743241a86984.html