-
Notifications
You must be signed in to change notification settings - Fork 711
Add odata metadata properties to ODataValue #513
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
When you say that you "tried creating a class for it myself...", do you mean that you extended ODataValue<T> or you provided your own stand-in class? These particular attributes are called annotations; specifically instance annotations. The Your request isn't without merit, but there are some interesting challenges to supporting it. These particular annotations are driven by the media type parameter odata.metadata, which can have a value of To complicate things further, the possible annotations can depend on supported query options. For example, if It's worth taking a look at this more in-depth, but I wanted to provide some context with regard to the complexities involved. Subclassing ODataValue<T> should be the bridge for this capability in the meantime. Thanks. |
I provided my own stand-in class, I'll extend ODataValue and see how I get on. I had a feeling it wouldn't be simple with the number of OData options! Thanks for responding so quick 😃 |
I extended ODataValue but got the same output, with only $select and $expand listed a parameters. I've had a look through the code and found that it is treating it as a "single result" because is sees that the generic type definition is not The check could be changed to look at the base type as well if it doesn't match, that way extending |
Extending ODataValue also affects the response model, it ignores changes to the entity type configuration so something like |
You're not by chance trying to actually return ODataValue<T> in your responses are you? If you are, you shouldn't be. ODataValue<T> is purely a stand-in type to respresent OData's output. The API Explorer and Swagger generators work off of the Reflection API. OData writes a protocol-specific output that is not formally captured as a type. This makes it impossible for Swagger generators to document the output without formal knowledge of OData. By using ODataValue<T> in the Ultimately, to get the correct output, the API Explorer unwraps T in ODataValue<T>, performs any required substituations according to the EDM, and then wraps it back up into the original ODataValue<T> as a new type. That should work even with a custom or extended implementation (but I honestly have not ever tried it). If you can share what your extended type looks like and how you've applied it to an action, I can see if I can't reproduce the behavior and/or come up with some other recommendations. |
No, I'm returning
And this is how swagger looks: |
@commonsensesoftware Have you got everything you need on this or can I help further? |
Everything you have is correct. The issue that the IsODataValue extension method isn't correct. As written, it will only allow types of ODataValue<T> (no inheritance), but that wasn't the intent. This is a pretty straight forward change. The fix will go out in the next patch. Stay tuned. |
Can metadata be added to ODataValue to support using count?
When using the following attribute parameters
[ProducesResponseType( typeof( ODataValue<IEnumerable<Color>> ), Status200OK )]
It currently produces this as the model:
Instead of what is really returned:
I have tried creating a class for it myself, however, the swagger docs produced then don't have most of the odata parameters like $filter, $orderby etc.
The text was updated successfully, but these errors were encountered: