public void Register(HttpConfiguration config)
{
var constraintResolver = new DefaultInlineConstraintResolver
{
ConstraintMap =
{
["apiVersion"] = typeof(ApiVersionRouteConstraint)
}
};
config.MapHttpAttributeRoutes(constraintResolver);
config.AddApiVersioning(o => o.ReportApiVersions = true);
this.restApiConfig.Register(config);
}
Controller route formatting:
[ApiVersion("3.0")]
[RoutePrefix("v3")]
public class SomeController {
[Route("/someRoute")]
public HttpResponseMessage GetStuff(){ }
We have attempted to use the [RoutePrefix(v{version : apiVersion)] attribute, which works with actually making the endpoints function under versioning, but forces Swagger to include a version parameter, which we do not want. We want our paths to be "/v2/controller/action" or "/v3/controller/action".
Happy to use the [RoutePrefix(v{version : apiVersion)] method, as long as we can display the paths properly in Swagger without having to input a version parameter. Otherwise, if we could use the [RoutePrefix("v3")] method without getting ApiVersionUnspecified errors, that would be even better.
VERSION:
Swashbuckle: 5.6.0 AspNet.WebApi.Versioning 2.2.0
STEPS TO REPRODUCE:
Consume any endpoint (postman or swagger)
EXPECTED RESULT:
Hits the actual endpoint
ACTUAL RESULT:
Receive the error: ApiVersionUnspecified or Swagger UI requires a version input.
ADDITIONAL DETAILS
Using Owin with WebAPI. Owin's Setup is blank. Global.asax.cs:
WebApiConfig.cs:
Controller route formatting:
We have attempted to use the [RoutePrefix(v{version : apiVersion)] attribute, which works with actually making the endpoints function under versioning, but forces Swagger to include a
version
parameter, which we do not want. We want our paths to be "/v2/controller/action" or "/v3/controller/action".Happy to use the
[RoutePrefix(v{version : apiVersion)]
method, as long as we can display the paths properly in Swagger without having to input aversion
parameter. Otherwise, if we could use the[RoutePrefix("v3")]
method without gettingApiVersionUnspecified
errors, that would be even better.