Skip to content

Attribute-Based API Version Neutrality Does Not Support Inheritance #93

Closed
@commonsensesoftware

Description

@commonsensesoftware

Synopsis

API version neutrality is defined by the IApiVersionNeutral marker interface. When this interface is applied by the ApiVersionNeutralAttribute it does not support inheritance. A service cannot be version-neutral in some cases and version-specific in others; therefore, once any implementation of a service is API version-neutral, all implementations are version-neutral. This behavior should be able to be realized through inheritance.

In ASP.NET Core, there is no distinction between a view-only controller and an API-only controller. View-only controllers typically never have API versions defined. Since there is no other way to identify or segregate these types of controllers, marking these types of controllers through inheritance is convenient.

Proposed Solution

Mark the ApiVersionNeutralAttribute as inherited. These will enable the following scenario:

[ApiVersionNeutral]
public abstract class UIController : Controller { }

[Route( "api/[controller]" )]
public class HelpController : UIController
{
  [HttpGet]
  public IActionResult Index() => Ok();
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions