Versioning does not work properly when the same action implements more than one version
#1,283 opened on Apr 19, 2018
Repository metrics
- Stars
- (6,291 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
If you have a controller or action with more than one ApiVersion attribute or MapToApiVersion attribute the spec only selects the first one.
For example, we should have versions 1.0 and 2.0 for every action in this controller:
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[ApiVersion("2.0")]
public class CityController : ControllerBase
And in this case, GET should have versions 2.0 and 3.0:
[HttpGet]
[MapToApiVersion("2.0")]
[MapToApiVersion("3.0")]
public async Task<ActionResult<IEnumerable<City>>> Get()
But only the first one shows up on the swagger docs.
This is important because sometimes you roll your service forward, but some operations are not updated, but you still want to roll their version forward with the others.
Right now the workaround would be creating a method that calls the other one and attribute it. This is less than ideal.