We have implemented api versioning as mentioned here https://referbruv.com/blog/integrating-aspnet-core-api-versions-with-swagger-ui/
But why are we getting this api-version fields when it should know that it is version 2?
I have decorated the endpoint with the following yet it still displays this api-version field?
[HttpGet("summary/all")]
[MapToApiVersion("1.0")]
I have also done the same for the v2 endpoint but change to 2.0
Adding the ApiVersionReader seemed to correct this:
services.AddApiVersioning(setup =>
{
setup.AssumeDefaultVersionWhenUnspecified = true;
setup.DefaultApiVersion = new ApiVersion(1, 0);
setup.ReportApiVersions = true;
setup.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
new HeaderApiVersionReader("x-api-version"),
new MediaTypeApiVersionReader("x-api-version"));
});
A full example of what works for me can be found as the answer in this question Replacing app.UseMvc() with app.UserRouting() gives us error `The request matched multiple endpoints`