-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal APIs #3560
Comments
Alright. I've been looking through the source code and I understand now this generator only supports ControllerActionDescriptor's and the Endpoint API Explorer exposes ActionDescriptor's. |
Wouldnt it be quite simple to add support for this? |
I guess so. Just not sure where to start |
Thanks for directing me to this issue @RicoSuter. I'll link to it from an existing issue the team has where we're tracking many of the OpenAPI issues we want to remember to work on throughout the minimal APIs work. Here's code i worked up to try to test NSwag: var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddOpenApiDocument(settings =>
{
settings.Title = "Minimal API";
settings.Version = "v1";
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseOpenApi();
app.UseSwaggerUi3();
}
app.MapGet("/", () => "Hello World!");
app.Run(); When I run this, I get an OpenAPI doc, but it lacks all operations. I presume this is due to NSwag's reliance on |
I've created a simple PR, needs tests and also there is one big TODO - how to get the operation ID when there is no method name? /cc @captainsafia Currently trying to get NSwag solution to run in VS2022, but a lot of older .NET Framworks are not supported anymore, etc. |
We took a stab at a strategy for setting the endpoint name automatically using the method group name in dotnet/aspnetcore#35439 but ended up reverting it because it wasn't super reliable for names that might conflict across namespaces and it relied on some hacky assumptions about the way generated type names would be produced. Would it be possible to reuse the same semantic currently used for controllers? AKA a combination of the |
I think this is the best option now... however it would be nice if there would be some way to define the operation name on |
So i created a minimal API like
With this csproj:
However API explorer does not report anything (IApiDescriptionGroupCollectionProvider.Items is empty)? /cc @captainsafia |
Minimal APIs are now working my PR: #3678 |
First experimental version will be released with v13.14.0 |
ASP.NET Core 6 Preview 6 introduces OpenAPI support for minimal APIs. It does this by exposing an API Explorer from Endpoint metadata
builder.Services.AddEndpointsApiExplorer()
. This works correctly with Swashbuckle but doesn't with NSwag. NSwag loads without errors but the swagger.json doesn't contain any paths. Got some sample code bellow. (Working) Swashbuckle code has been commented out:The text was updated successfully, but these errors were encountered: