Skip to content

Feature ask: Need the have ability to set custom query validator into SelectExpandQueryValidator #767

Open

Description

@SamGuoMsft

Assemblies affected
Which assemblies and versions are known to be affected e.g.: ASP.NET Core OData 8.x

Describe the bug
@xuzhg, based on our discussion, I am just listing three issues which I hope we can improve:

  1. Can't set custom query validator into SelectExpandQueryValidator, e.g.: The construct directly create the FilterQueryValidator, rather than expose as parameter, so customer can use DI or explicitly set it. Source code link.
  2. Even SelectExpandQueryValidator allow us pass custom FilterQueryValidator via constructor, it will still not work due to the current code does some kind of hack) to create an internal virtual method to allow SelectExpandQueryValidator to set local properties like defaultValidationSetting. So even I create my custom filter query validator, I still can't set these fields and it will cause null reference issue eventually.
  3. In the current FilterQueryValidator, if customer doesn't register EDM model, the validation will not honor the model bound filter attribute due to we don't set property and structured type if no ODataPath, source code is [here](https://github.com/OData/AspNetCoreOData/blob/3db5e5fb94df2968b1b354bc37a47907b89892be/src/Microsoft.AspNetCore.OData/Query/Validator/FilterQueryValidator.cs#:~:text=if%20(filterQueryOption.,%7D), but if people use filter under expand clause, then the model bound filter attribute start working due to it invoke the hacky internal method which I mentioned in 2nd issue, and the internal method will set the property and structured type based on navigation property. So, it is not consistent.

Reproduce steps
The simplest set of steps to reproduce the issue. If possible, reference a commit that demonstrates the issue.

Data Model
Please share your Data model, for example, your C# class.

EDM (CSDL) Model
Please share your Edm model, for example, CSDL file.
You can send $metadata to get a CSDL XML content.

Request/Response
Please share your request Uri, head or the request body
Please share your response head, body.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Please share your call stack or any error message
Add any other context about the problem here.

Activity

  1. added
    bug
    on Dec 13, 2022
  2. self-assigned this
    on Dec 13, 2022
  3. reopened this on Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions