Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
commonsensesoftware opened this issue Mar 6, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@commonsensesoftware
Copy link
Collaborator

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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant