Skip to content

Versioning Gets Ambiguous Routes in Core 2.2Β #363

Closed
@shawnwildermuth

Description

@shawnwildermuth

When using the Versioning system with a Core 2.2 Preview project, the routing can't differentiate by version #'s if you use the 2.2 Compatibility Flag (it's not required that you leave Core 2.2, just set the compatibility flag to 2.1):

    public void ConfigureServices(IServiceCollection services)
    {
      services.AddApiVersioning(opt =>
      {
        opt.DefaultApiVersion = new ApiVersion(1, 1);
        opt.ReportApiVersions = true;
        opt.AssumeDefaultVersionWhenUnspecified = true;
      });

      services.AddMvc()
        .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // <--- Works 
        //.SetCompatibilityVersion(CompatibilityVersion.Version_2_2); // <--- Doesn't Work 
    }

I tried both the 2.1 version of the library and the 3.0-beta-1 and got same result.

My controller looks like this:

  [Route("api/[controller]")]
  [ApiController]
  [ApiVersion("1.0")]
  [ApiVersion("1.1")]
  public class ValuesController : ControllerBase
  {
    // GET api/values
    [HttpGet]
    [MapToApiVersion("1.0")]
    public ActionResult<string> Get()  => "1.0";

    [HttpGet]
    public ActionResult<string> Get11() => "1.1";

  }

Here is a minimal repro case for you to try:

ReproVersioning22.zip

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions