AllowedQueryOptions confusion
@Nthemba is already working on this.
Since Aug 23, 2022.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
When using AspNetCore.OData 8.x I got a bit confused on how the different query options are supposed to work. And since there is no documentation for 8.x I thought I'd ask it here.
The confusion came when I tried out the AspNet.Api.Versioning to generate the api documentation and I have an issue there as well: dotnet/aspnet-api-versioning#853.
When configuring OData in the Startup.cs/Program.cs, you can set the (what I presume) default settings for supported the query options, which apply to all endpoints:
.AddOData(options => options.Count().Select().OrderBy())
Then on the controller you can also set the AllowedQueryOptions on the [EnableQuery]:
[EnableQuery( MaxTop = 100, AllowedQueryOptions = Select | Top | Skip | Count | Filter )]
When using the $orderby I get a 400 Bad Request with the message: " Query option 'OrderBy' is not allowed". I kind of understand that, since it is not configured on the EnableQuery.
When using the $filter I get an error with the message: "The property 'customer' cannot be used in the $filter query option.". The $filter only works when I enabled it in the Startup.cs/Program.cs, although I would expect it to work since I explicitly enable it on the controller.
So my question is how does this supposed to work?
- What do you configure in the Startup.cs/Program.cs
- How does the
AllowedQueryOptionson[EnableQuery]affect the configured values in the Startup.cs/Program.cs?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.