Open cheoalfredo opened 3 years ago
Yes, because NSwag relies on the ASP.NET Core API Explorer which need to reflect on operations... you're setting up a procedural route handler which is not picked up by API Explorer (ie this probably only works with controllers).
@RicoSuter I have tried your example with minimal API support from https://github.com/RicoSuter/NSwag/issues/3560#issuecomment-965630171. It works (but doesn't show method names, of course).
Is there any option to document the methods within minimal API handlers (or however these "controllers" can be called) if we don't use anonymous methods but a class with static methods?
E.g.
app.MapGet("/", (r) => Test.Something());
public class Test
{
/// <summary>I am documented now.</summary>
public static Task Something()
{
Task.FromResult("Hello there.");
}
}
instead of
app.MapGet("/", (r) => Task.FromResult("Hello world!"));
Or is the only option to document the methods to use the known controller annotations like
[Route("api/nodes")]
[ApiController]
[OpenApiTag("Nodes", Description = "Node management.")]
and so on?
@SeppPenner Isnt there an extension method WithName() to provide the operation name?
@cheoalfredo btw, you're using Swashbuckle and not NSwag for spec generation (so issue is in the wrong repo or you switch to use NSwag)
@SeppPenner Isnt there an extension method WithName() to provide the operation name?
Yeah, sorry. I found your example project in the samples... In my case, the issue was / is a bit more complex as I'm mixing HTTP1 ("The old controllers") and HTTP2 calls (GRPC services) on the same endpoint while also having another endpoint where only certain calls should be possible (I wanted to use the minimal API here, but I don't beleive that it's working like that in the concrete scenario). But the issue has nothing to do with NSwag directly right now 😄
Hi, i'm creating a minimal api with https://dotnetthoughts.net/minimal-api-in-aspnet-core-mvc6/, i'm setting up nswag with :
when i launch the api, i get the usual swagger page with the message "No operations defined in spec!" do i have to do anything else in order to get the openapi documentation generated ?