У меня есть необходимость реализации версий в URI web-api, имеющего следующий формат:
<major>.<minor>.<patch>
Например,
api/v1.1.2/document-provider/documents/documentId
Я настроил конфигурацию следующим образом
var apiExplorer = GlobalConfiguration.Configuration.AddVersionedApiExplorer(
options =>
{
options.GroupNameFormat = "'v'VVV";
// note: this option is only necessary when versioning by url segment. the SubstitutionFormat
// can also be used to control the format of the API version in route templates
options.SubstituteApiVersionInUrl = true;
});
Итак, когда я попробую код ниже,
[Microsoft.Web.Http.ApiVersion("1.1.3")]
[RoutePrefix("api/v{version:apiVersion}/document-provider")]
public class DocumentProviderController : ApiController
{
/// <summary>
/// Retrieves the document
/// </summary>
/// <param name="claimId">Number of temporary claim</param>
/// <param name="documentId">Identifier of the document</param>
/// <returns></returns>
[Route("documents/{documentId}")]
[HttpGet]
[Swashbuckle.Swagger.Annotations.SwaggerResponse(HttpStatusCode.OK, Type = typeof(GetDocumentResponse))]
public IHttpActionResult Document_Get(int documentId)
{
try
{
_log.Info($"Start call action-method {nameof(Documents_Get)}");
.,.
Я получаю эту ошибку ниже во время выполнения:
Указанный статус версии API '3' недопустим.
info =>
{
foreach (var group in apiExplorer.ApiDescriptions)
{
info.Version(group.Name, $"Business API {group.ApiVersion}");
Кажется, что 3-й уровень информации о версии (часть 'patch') не поддерживается.Я не нашел в сети ничего, что могло бы помочь мне с этой проблемой.
Есть кто-нибудь с некоторыми советами для меня?
Спасибо