-
Notifications
You must be signed in to change notification settings - Fork 711
OData OpenAPI AllowedQueryOptions is not generated correctly #853
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
Comments
Matching the OData query options via the various ways you can configure them has been a bit of a moving target and the rules don't feel to be very documented IMHO. I can tell you that in the first case, the reason that you get Your second case highlights exactly what I'm talking about. You've allowed the Right or wrong, my understanding of the query option rules are:
Hopefully, you see the crux of the problem. If It's been really hard to verify my interpretation of the rules versus misconfiguration of OData. It's easy to get in a situation where all the query options show up as expected, but it doesn't work because something else is misconfigured for OData. This makes it difficult to tell the difference between an actual bug and simple configuration. The OData documentation mentions how to use each method of configuration, but doesn't discuss what happens when you use multiple methods together. This issue will likely require some more research to make sure the corrective action goes in the right direction. Thanks for reporting it. |
I think you are mostly right here, but I think there are a few nuances in how you should think about it:"
|
Do you have links to documentation, code, or tests that highlight this? What I can remember seeing documented or from looking at code outlines each method. I don't recall a clear call out of mixing and matching options nor their precedence. Dialing that in is critical to making sure any change does what people expect. |
I can't find any specific rules, code, or tests that documents what the precedence of operation is. There are plenty of tests for individual scenarios, but I can't find anything that combines multiple scenarios together. As an example, I found that if you enable I'm going to proceed with the discussion from here. #702 calls out a strange, but related case. I can't find any Model Bound specific way to enable My preliminary results show this seems to be what you (and others) are asking for. I didn't uncover any regressions in the test suite - yet, so I think things are good to move forward. These changes will be in |
Great to hear 😀 I am looking forward to try it out as soon as possible 😀 |
Using .NET 6, OData 8 and the preview version of the library, I have some problems with generating correct swagger documentation for the
AllowedQueryOptions
.All the code is based on the ODataOpenApiExample in the main branch.
Given the following:
options in Program.cs:
On top of the OrdersController Get method:
I get not 4, but 5 fields in the swagger documentation:

I wouldn't expect the "OrderBy" field and when I use it I get a 400 Bad Request with the message: " Query option 'OrderBy' is not allowed".
When I add:
I do get the filter field, but I can't use it because I get the message: "The property 'customer' cannot be used in the $filter query option." (Although this might be more of a OData issue)
The text was updated successfully, but these errors were encountered: