question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue generating Clients where the controller have a route parameter, but not used in the method

See original GitHub issue

Not 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: image

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:closed
  • Created 5 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
RicoSutercommented, Aug 2, 2018

@syska does this look good to you? Logic: Treat implicit parameters without type as typeof(string) and not-nullable when they are path params…

0reactions
RicoSutercommented, Aug 3, 2018

v11.18.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why would a laravel route work, passing parameters, when ...
Why would a laravel route work, passing parameters, when used as a link but not when used in a redirect, generating a missing...
Read more >
how to handle when route parameter is not provided
I am looking to handle the following case in my api. Illuminate\Routing\Exceptions\UrlGenerationException: Missing required parameter for [Route: my.route] ...
Read more >
Routing to controller actions in ASP.NET Core
Learn how ASP.NET Core MVC uses Routing Middleware to match URLs of incoming requests and map them to actions.
Read more >
Scala Routing - 2.8.x
Each route consists of an HTTP method and URI pattern, both associated with a call to an Action generator. Let's see what a...
Read more >
Controllers - Laravel 10.x - The PHP Framework For Web ...
This single route declaration creates multiple routes to handle a variety of actions on the resource. The generated controller will already have methods...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found