Issue generating Clients where the controller have a route parameter, but not used in the method
See original GitHub issueNot sure if this is an issue … using the API Explorer in nswag.
The route looks like this:
/api/{language}/baskets/{basketId}
language
is used by aspnetcore to set the Culture
The controller looks like this:
[Route("api/{language}/baskets")]
public class BasketController : ApiControllerBase
{
private readonly IMediator _mediator;
public BasketController(IMediator mediator)
{
_mediator = mediator;
}
[HttpGet("{basketId:guid}")]
[ProducesResponseType(typeof(Basket), 200)]
[ProducesResponseType(typeof(ValidationMessage[]), 400)]
[ProducesResponseType(typeof(ForbiddenMessage), 403)]
public async Task<IActionResult> GetBasket([FromRoute] Guid basketId)
{
var basket = await _mediator.Send(new GetBasket.Query(basketId));
var newBasket = await _mediator.Send(new SaveBasket.Command(basket));
return Json(newBasket);
}
}
The swagger file from swashbuckle looks like this:
The client generated from with the API Explorer just removed the {language}
parameter … so the url ends up looking like /api/baskets/{basketId}
… and ofcause it can’t hit the URL cause its missing the {language}
part …
This works if we put the {language} parameter in the method signature … is this by design? If it is … and I can kind a understand why … is there any way to overcome this somehow? We need this to set the Culture … but with a MiddlewareFilter injected on all method before route action is performed …
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (8 by maintainers)
@syska does this look good to you? Logic: Treat implicit parameters without type as typeof(string) and not-nullable when they are path params…
v11.18.1