ASP.NET Core, Web API RouteAttribute with query string as template
I figured out an easier and more straightforward solution. I am simply using the FromQuery
attribute and leaving the template simple. I check for the presence of the id
variable and handle it accordingly.
[HttpGet, Route("api/symbols")]
public Task<IEnumerable<Symbol>> Symbols(
[FromQuery] Guid id,
[FromServices] ISymbolService symbolService) =>
id == default
? symbolService.GetSymbolsAsync()
: symbolService.GetValidChildrenAsync(id);