Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

ProducesResponseTypeAttribute is the only direct concrete implementation of IFilterMetadata #5251

Closed
@tuespetre

Description

@tuespetre

Another nitpicky issue from your friendly neighborhood nitpicker.

The two following interfaces are not derived from IFilterMetadata:

  • IApiRequestMetadataProvider
    • Places that look for it in the action's filters:
      • DefaultApiDescriptionProvider
    • Classes that implement it:
      • ConsumesAttribute
  • IApiResponseMetadataProvider
    • Places that look for it in the action's filters:
      • DefaultApiDescriptionProvider
      • FormatFilter
    • Classes that implement it:
      • ProducesAttribute
      • ProducesResponseTypeAttribute

Because of this, ProducesResponseTypeAttribute is the only direct concrete implementation of IFilterMetadata.

Now it's clear that the concept of 'filters' is overloaded to the effect that a 'filter' doesn't have to do anything, and it can instead just supply some kind of token to influence behavior or provide some kind of metadata. There are several examples of such interfaces deriving from IFilterMetadata:

  • IFormatFilter
    • FormatFilter
  • IAllowAnonymousFilter
    • AllowAnonymousFilter
  • IAntiForgeryPolicy
    • IgnoreAntiForgeryTokenAttribute
    • ValidateAntiForgeryTokenAuthorizationFilter
      • AutoValidateAntiForgeryTokenAuthorizationFilter

Furthermore, we see several out-of-the-box examples demonstrating that implementations of IFilterMetadata do not strictly have to be attributes.

Considering that, I think that IApiRequestMetadataProvider and IApiResponseMetadataProvider should derive from IFilterMetadata in order to:

  1. Be consistent with other interfaces in how they are retrieved from actions' filter collections, and
  2. Have all out-of-the-box implementations of IFilterMetadata such as ProducesResponseTypeAttribute implement IFilterMetadata via a more specialized, purposeful interface rather than directly.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions