-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ProducesResponseTypeAttribute is the only direct concrete implementation of IFilterMetadata #5251
Comments
This is correct, which is why it's The intent is that using We actually did design a set of APIs to formalize this notion of policy so that extensibility authors wouldn't have to read between the lines to figure it out. But - there are only so many hours in the day, and it ended up being pretty rocket-sciency. It's often 2 hours of work to do an initial design, and 20 hours of work to implement/test it. We ultimately decided to wait for customer feedback on this one rather than build another set of abstractions for something we already do in our own code. As to your specific feedback - I don't recall exactly why I didn't do this. I reserve my right to change my mind about things, but I agree right now with your suggestion and your rationale.
|
😆
It looks like it may be loosely related to how they are sitting as siblings to other
I understand the purposes of each of these and can see how, when looking at them together, they seem like kind of their own 'thing'.
Cool... I will submit a PR for it and y'all can just do whatever you will! 😸 |
I think I understand all the points made here, and I think I even agree with them. But what does this change benefit? What task becomes easier? Or possible? |
This removes a potential mistake if you wanted to implement your own |
Ah ok, that's a good enough reason. @ajaybhargavb I've assigned #5261 to you to review and merge. |
Thanks @tuespetre |
Another nitpicky issue from your friendly neighborhood nitpicker.
The two following interfaces are not derived from
IFilterMetadata
:IApiRequestMetadataProvider
DefaultApiDescriptionProvider
ConsumesAttribute
IApiResponseMetadataProvider
DefaultApiDescriptionProvider
FormatFilter
ProducesAttribute
ProducesResponseTypeAttribute
Because of this,
ProducesResponseTypeAttribute
is the only direct concrete implementation ofIFilterMetadata
.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
andIApiResponseMetadataProvider
should derive fromIFilterMetadata
in order to:IFilterMetadata
such asProducesResponseTypeAttribute
implementIFilterMetadata
via a more specialized, purposeful interface rather than directly.The text was updated successfully, but these errors were encountered: