domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.22k stars 1.31k forks source link

Endpoint is missing in swagger when i use WithGroupName in asp net core minimal apis #2260

Closed vabka closed 3 days ago

vabka commented 2 years ago

Swashbuckle.AspNetCore version: 6.2.3 .NET Version: 6.0.100-rc.2.21505.57 My code:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();
app.MapSwagger();
app.UseSwaggerUI();

app.MapGet("/a", () => "Hello world"); // this one exist
app.MapGet("/b", () => "Hello world2").WithGroupName("test"); // this one not 

app.Run();
github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

jgarciadelanoceda commented 2 months ago

@vabka, I have just see the related issue dotnet/aspnetcore#56585. And is the comment that captainsafia makes. It's other groupName, and to see it on Swagger I have just added this:

builder.Services.AddSwaggerGen(c =>
{
    c.EnableAnnotations();
    c.IncludeXmlComments(Assembly.GetExecutingAssembly());
    c.SwaggerDoc("v1", new() { Title = "WebApi V1", Version = "v1" });
    c.SwaggerDoc("test", new() { Title = "WebApi test", Version = "test" });
})

And this:

app.UseSwaggerUI(o =>
{
    o.SwaggerEndpoint("/swagger/v1/swagger.json", "V1 Docs");
    o.SwaggerEndpoint("/swagger/xml/swagger.json", "V2 Docs");
})

It just acts as describing multiple documents

vabka commented 2 months ago

Not expected that i'll get solution after 3 years :) I expected that WithGroupName will group endpoints in single document but not create new document.

What option can be used to group endpoints? (like how Controller does)

jgarciadelanoceda commented 2 months ago

The option is WithTags, see this example https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/test%2FWebSites%2FWebApi%2FEndPoints%2FOpenApiEndpoints.cs#L20-L21

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

github-actions[bot] commented 3 days ago

This issue was closed because it has been inactive for 14 days since being marked as stale.