RicoSuter/NSwag

Versioning does not work properly when the same action implements more than one version

開放

#1,283 建立於 2018年4月19日

 (2 則留言) (3 個反應) (0 位負責人)C# (1,356 個分叉)batch import
help wantedtype: enhancement

倉庫指標

星標
 (7,358 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南