-
Notifications
You must be signed in to change notification settings - Fork 102
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
Attribute to override rel as convenience for serializing and for disambiguating deserialization #67
Comments
Would using the JsonPropertyAttribute be a reasonable implementation? |
It will not result in the exact same response, but wouldn't a simple solution be to have different resources for the list of posts? I'd imagine you would also want these lists to be accessible through a different uri, ie. ~/posts/recent and ~/posts/popular. You would then set the Rel on the RecentPostsResource and the PopularPostsResource, resulting in:
Again, it will not yield the same output, you will have an extra layer in your embeded resources, but imho it is a cleaner solution. Just my 2 cents ... |
I created an extension method for Representation that will look for a RelAttribute on all properties that are of type Representation and will override the value of the Rel property for that property instance to whatever you set it to in the RelAttribute. Just call the extension method in the override of the CreateHypermedia method. //Example: public class MyRep : Representation
} //Extension Method:
//Custom RelAttribute
//Result: |
closing stale issue |
Let's enhance this project to allow attributing embedded properties with a rel override, such as this:
The net result is to output json like this:
The common thing currently is to just have PostResource hardcode its rel to something. So to accomplish the above json with the current implementation without the Rel override attribute, one would have to set the rel of each of the objects in the RctPost list to one rel and the objects in PopPosts to another.
Also, upon deserializing, without the Rel override attribute, the deserializer would have no idea which list to put the incoming PostResource objects into.
The text was updated successfully, but these errors were encountered: