-
Notifications
You must be signed in to change notification settings - Fork 37
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
Abstract / Derived Class Deserialization #200
Comments
It doesn't really seem to fit very nicely in the JSON api spec to do such a thing. Especially since the public class MyResource : ApiResource
{
public MyResource()
{
Attribute("$type");
}
} then in your payload: {
"data": {
"type": "my-type",
"attributes": {
"$type": "MyApp.Api.ConcreteType"
}
}
} I suppose the "recommended" way to do it using JSON API is to set different types for the different subclasses under the data hash. |
I came here to ask something very similliar. Right now iirc the "type" parameter sent by the client is not interpreted at all in the deserialization. It would be great if we had a way to do this. ALSO it would be great to be allowed to return multiple APIResources that are derived from each other from a webapi action. ~Cheers |
Just came back to tell @aariabov that he probably can make use of the Default settings for the used Newtonsoft serializer. I just added these lines:
and was able to use derived classed in nested attributes. To use derived classes in top level (ApiResources) would probably require a lot of work on Saule and should be really thought about as it seems to go against the RESTful philosphy and actually would be better suited for RPC. ~Cheers |
Hello. I have model binding problem, like this. Can I make such binding with json api and saule?
The text was updated successfully, but these errors were encountered: