-
-
Notifications
You must be signed in to change notification settings - Fork 158
Bug: custom serializer settings are ignored #687
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
Thanks for your involvement and looking into this. In v3 it was possible to configure serialization through The reason for the removal was that, in short, with changes (even small ones!) in The rework introduced -- |
More elaborative answer: we can't really rely on There's a few examples in which configuring From this bit in the spec
it is implied that the following partial is invalid "relationships": {
"author": { }, <--- this line is not valid
"reviewer": { "data": { "id": 1, "type": "people" } }
} This will occur if the to-one relationship Another way to look at the problem is to recognise that a violation of SRP has been introduced: the responsibility for constructing json:api resource objects is within the |
Actually, it does. The reason is because the enum value is stored as
I agree with your point that null value handling is complicated and needs to be special-cased, in order to be compliant with the json:api spec. That is exactly why I introduced the scope class: it prevents outsiders to override null-value handling in cases when JADNC knows better. Me not knowing all the internals, I may have missed some spots that are not covered by tests.
However, there is a lot more in I believe you are trying to abstract away the actual serialization implementation by introducing If, in the future, the underlying serialization library becomes pluggable, that would be a good time to remove explicit dependencies on Newtonsoft.Json and wrap its settings. Either way, we should add tests for uncovered cases. Can you identify these? |
Update: After discussion, we decided to keep the Newtonsoft.Json setting and remove |
To clarify: The work that needs to be done here, in additional to the changes in #688, is to remove the |
When setting custom serialization settings on
JsonApiOptions
, they are not used. In our scenario we have a few enums exposed as attributes and we want them to serialize into their text representation instead of numeric.Example:
Putting
[JsonConverter(typeof(StringEnumConverter))]
on ScreenOrientation works, but the global setting does not.Using the global setting should work, according to https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/docs/usage/options.md#custom-serializer-settings.
The text was updated successfully, but these errors were encountered: