Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AV0003: Invalid API version status

Value
Rule IDAV0003
CategoryUsage
Fix isBreaking

Cause

The specific API version status is invalid.

Rule Description

An API version status must start with a letter and may contain letters, digits, and periods. The status not end with a period.

Consider the following code:

[ApiController]
[ApiVersion(2.0, "preview-1")]
[Route("[controller]")]
public class ExampleController : ControllerBase
{
    [HttpGet]
    public IActionResult Get() => Ok();
}

The text "preview-1" is not a valid API version status. This would not detected until runtime.

How to Fix Violations

Update the API version status to be well-formed.

[ApiController]
[ApiVersion(2.0, "preview.1")]
[Route("[controller]")]
public class ExampleController : ControllerBase
{
    [HttpGet]
    public IActionResult Get() => Ok();
}

When to Suppress Warnings

It is never safe to suppress this rule because a runtime exception will be thrown when the text is parsed.