CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Endpoints Not Visible in EndpointsApiExplorer

johnholliday opened this issue · comments

Declaring minimal API endpoints in a Carter module hides them from the EndpointsApiExplorer.

The problem is not with Carter. The EndpointsApiExplorer cannot recognize paths that are declared with const or static strings. They have to be literal strings. In other words...

This works

public class ActorsModule : ICarterModule
{
  public void AddRoutes(IEndpointRouteBuilder app)
  {
    app.MapGet("/actors", GetAllActors).WithName("GetActors");
  }
}

This does not work. The Api explorer view will be empty.

public class ActorsModule : ICarterModule
{
  public static string ActorsRoute = "/actors";
  public void AddRoutes(IEndpointRouteBuilder app)
  {
    app.MapGet(ActorsRoute, GetAllActors).WithName("GetActors");
  }
}