Search code examples
asp.net-coreopenapiswashbuckleswashbuckle.aspnetcore

ApiExplorerSettings(IgnoreApi=true) doesn't hide mapping routes from document


I expect this couple routes to be hidden because of ApiExplorerSettings(IgnoreApi=true)

app.MapPost("/login", [ApiExplorerSettings(IgnoreApi=true)] async (string returnUrl, HttpContext context, [FromServices] SignInManager<LiteDbUser> signInManager) =>
{
    var form = context.Request.Form;
    var result = await signInManager.PasswordSignInAsync(form["username"], form["password"], false, false);
    return result.Succeeded ? Results.Redirect(returnUrl ?? "/health") : Results.Redirect("/login");
});

app.MapGet("/logout", [ApiExplorerSettings(IgnoreApi=true)] async ([FromServices] SignInManager<LiteDbUser> signInManager) =>
{
    await signInManager.SignOutAsync();
    return Results.Redirect("/login");
});

but it seems there is no effect

image

Is this a bug or feature?


Solution

  • It seems there's not way to use attributes in minimal API. But you could try add.ExcludeFromDescription() to hide an API.

    app.MapGet("/test", string () => { return "test success"; }
    
    ).ExcludeFromDescription();
    

    Then it will be hide from swagger but still work when call.
    enter image description here