Retrieving the actual URL of an route with API versions prefilled

I have a controller with some routes that looks like this. As you can see I use annotations to configure the controller routes.

 * @Route("/sales-channel-api/v{version}/foo/bar", defaults={"auth_enabled"=true},
 *     name="", methods={"POST"})
 * @param Request $request
 * @param SalesChannelContext $salesChannelContext

In another part of my code I need this URL. Instead of making it a .env. variable or something I ask the router to retrieve the URL by name. But is just returns that exact value of the route as shown in the annotation block including the {version} placeholder.

Is possible to programmatically retrieve this route by name and let it replace the version placeholder for me automatically based on the context or so?

Code for retrieving the route.

        $callbackUrlPath    = $this->router->getRouteCollection()->get( '')->getPath();
       // Actual output: /sales-channel-api/v%7Bversion%7D/foo/bar
      // Wanted output: /sales-channel-api/v3/foo/bar prefill the version based on a Context object or something

I’m using shopware 6.3