Skip to content
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

Expanding Properties on Derived Types #70

Open
Norm-Cota opened this issue Nov 19, 2020 · 2 comments
Open

Expanding Properties on Derived Types #70

Norm-Cota opened this issue Nov 19, 2020 · 2 comments

Comments

@Norm-Cota
Copy link

Norm-Cota commented Nov 19, 2020

Hello,

I am using this library via https://github.com/diegomvh/angular-odata and have run into something that isn't currently supported. (I think)

My API has some derived types that I am trying to expand. It seems that odata-query is not able to describe the cast to the derived type in object form and manually entering the cast as a string value is interpreted as a nested expand. I understand the benefit of the string valued shorthand, but it precludes the ability to cast to the derived type.

Here is a contrived scenario:
Namespace: Example
Entities:

  • Shape { ID: number }
  • Circle : Shape { Radius: number }
  • Square : Shape { Size: number, Vertices: Vertex[] }
  • Vertex

Endpoints:

  • /Shapes
  • /Vertices

If I want to query all of the Shapes but expand the Vertices for any Square objects, the query would be:

[root]/Shapes?$expand=Example.Square/Vertices

The object form doesn't have the ability to specify type, which isn't too big a deal since it is a more complex scenario. However, passing the string of "Example.Square/Vertices" to the expand property results in the this query:

[root]/Shapes?$expand=Example.Square($expand=Vertices)

Obviously, the above isn't correct given the model.

I realize that removing or modifying the string shorthand would be a large breaking change for many. Given that, is there a workaround for this scenario? Would it be possible to add this ability within the object form? Other ideas?

Quick Edit: OData v4

@erzet
Copy link

erzet commented Mar 3, 2021

👍 To that, it looks like it's impossible to expand properly using namespace cause '/' is translated to property expansion. Any chance this will get some love?

@Feeedi
Copy link

Feeedi commented May 15, 2023

I would also love this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants