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

Allow option to $expand on PUT/POST/PATCH #61

Closed
jonest opened this issue Jul 26, 2018 · 3 comments
Closed

Allow option to $expand on PUT/POST/PATCH #61

jonest opened this issue Jul 26, 2018 · 3 comments

Comments

@jonest
Copy link
Contributor

jonest commented Jul 26, 2018

OData allows the ability to do something like a POST with an $expand which then returns an object with an expanded property, e.g.:

Request

POST http://localhost/SomeService/v1/SomeResource?$expand=NestedObjects
Accept: application/json
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9

{
  "Name": "Dummy Object",
  "NestedObjects": [
    {
      "Name": "Dummy Nested Object"
    }
  ]
}

Response

HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
Location: http://localhost/SomeService/v1/SomeResource?$expand=NestedObjects
OData-Version: 4.0

{
  "@odata.context": "http://localhost/SomeService/v1/$metadata#SomeResource/$entity",
  "Id": 1234,
  "Name": "Dummy Object",
  "NestedObjects": [
    {
      "Id": 4321,
      "Name": "Dummy Nested Object"
    }
  ]
}

In a specific use case that I'm using, we PUT an object with a nested object to update both the parent and the children in the database. When we get a response, it'll just return the top level object by default unless we include the $expand operator

@jonest
Copy link
Contributor Author

jonest commented Jul 26, 2018

I'm happy to work on adding this, but I'd like to hear some thoughts/get some guidance on how best to tackle this :)

@jonest
Copy link
Contributor Author

jonest commented Aug 15, 2018

I started taking a peek through the code to configure this similar to the Get( ... ) operation that currently exists and saw that there are PostOperation<T>, PutOperation<T>, and PatchOperation<T> that have been commented out with a comment //ToDo: Check ODataV4. I'm not entirely sure what problem exists where this was left like this.

Would you mind elaborating at all on this @StefH ?

Thanks!

@StefH
Copy link
Owner

StefH commented Aug 16, 2018

Actually I don't know the full details on this code part. I think I copied this from the older project.
And I never got the chance to analyze and implement this functions.

If you have time, you can add this (if possible including unit-tests)

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

2 participants