Versioning does not work properly when the same action implements more than one version
#1283 aperta il 19 apr 2018
Metriche repository
- Star
- (7358 stelle)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
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.