-
Notifications
You must be signed in to change notification settings - Fork 475
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
Missing documentation for FilterQueryValidator #1651
Comments
@mloffer Thanks for the feedback. We are working on making the documentation better. For the time being, for aspnetcore, you can use this in your startup.cs to set the DefaultQuerySetting with the parameters you want - If you are using aspnet, then you can use HttpConfiguration extension methods to do the same. |
I don't understand what explicitly setting DefaultQuerySettings does here? Isn't this done automatically behind the scenes? What does this have to do with writing a FilterQueryValidator? |
@mloffer DefaultQuerySetting in the context of FilterQueryValidator simply checks if filter is enabled as a query option or not. It was not clear to me how are you planning on using the FilterQueryValidator; if you want to use your own then simply new a DefaultQuerySetting object with Enable filter property set to true. I believe that the framework should take care of this automatically but it seems like you are trying to achieve something else here. Can you please give me more context about what you are trying to do? |
This is what I was looking to write. It's fairly similar to the way the AspNet guide says to do it. I've provided a new instance of DefaultQuerySetting like you suggested, but I am unclear on what the implications of this are. Am I at risk of having this attribute ignore global query settings I'm configuring elsewhere in the stack? Also, is EnableQueryAttribute the right thing to use here? It's just QueryableAttribute in the AspNet guide, but this class doesn't exist in the AspNetCore implementation. You can see that I would like to throw an error if the ODataQueryOptions.Filter is null, but the ValidateQuery method never gets called if some part of the query isn't provided by the consumer. For instance, I can provide $count=true and I get the error. But simply accessing the route does not enforce this behavior.
|
@mloffer Thanks for the details.
Let me know if you need more help, I can pull in other experts as well. Thanks! |
That makes sense that ODataQueryOption.Filter.Validate wouldn't fire unless a filter were provided. My question is why EnableQueryAttribute.ValidateQuery doesn't fire unless some query option is passed, such as $count? After all, it's not called EnableQueryOptionsAttribute. Is there a better attribute to inherit from for this task? I mean, sure, I could put the null check in every controller action. But that violates DRY principles and makes the code very hard to refactor if that requirement ever changes. |
Hi, I am having issues with invoking the ValidateSingleValuePropertyAccessNode in my FilterQueryValidator. I would like to set specified properties to be used in the filter query and throw validation error if any other properties are specified in the filter query. Anyone please assist. |
WebAPI 2.2 documentation lists very little:
https://docs.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-2.2
OData documentation is out of date:
https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata-security-guidance
A) FilterQueryValidator requires DefaultQuerySettings to be passed to the base. Where should this come from?
B) This article doesn't show how to use MyFilterQueryValidtor.
I have looked through the samples, but there are no relevant projects:
https://github.com/OData/ODataSamples/tree/master/WebApiCore
Questions:
How do I create one?
How should DefaultQuerySettings be passed in?
How do I use it to validate against a controller action?
Sorry to be so basic, but the documentation for this stack is nearly non-existent. It's hard to even know what to ask.
The text was updated successfully, but these errors were encountered: