I'm using Swashbuckle to document my Web API 2.2 API. When I load the Swagger page, the uri's display with a version placeholder variable instead of the actual version. For example:
/api/v{version}/authentication
Instead of:
/api/v2/authentication
How can I configure my app or Swashbuckle to display the version number instead of the version variable?
Updated code for WebApiConfig:
// Web API configuration and services
var constraintResolver = new System.Web.Http.Routing.DefaultInlineConstraintResolver()
{
ConstraintMap =
{
["apiVersion"] = typeof(Microsoft.Web.Http.Routing.ApiVersionRouteConstraint)
}
};
config.AddVersionedApiExplorer(opt =>
{
opt.SubstituteApiVersionInUrl = true;
});
config.MapHttpAttributeRoutes(constraintResolver);
config.AddApiVersioning();
// Web API routes
//config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Some references Swagger
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With