You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our solution we have need for serialization and deserialization of the models received from delivery client.
The models are generated by model generator.
The models have properties with interface types and the implementation of the interfaces are hidden from us because they are internal to the delivery client library. This causes problem when we want to deserialize them because System.Text.Json can't deserialize to interface without any concrete implementation.
An example can be interface Kontent.Ai.Delivery.Abstractions.IDateTimeContent.
Proposed solution
Expose implementations for the interfaces used in models generated by model generator.
Additional context
I hope that it is understandable what is going on here, but if not, then let me know and i will provide you with some example project.
The text was updated successfully, but these errors were encountered:
Internally, the SDK uses ModelProvider class for mapping purposes, built around Newtonsoft.Json, which supports interface-to-type mapping. The generated models reflect that.
Assuming you're deserializing content from API, the item retrieval methods provide generic overloads (e.g. GetItemAsync<T>), where you can either provide the model directly, or pass in object and implement runtime type resolution.
That being said, you mentioned the need for both deserializing and serializing, which leads me to believe you might have a more specific scenario in mind. If that is the case, could you share some more details on the matter? In particular, is there a requirement on your end to use System.Text.Json rather than newtonsoft or the built-in SDK methods?
Also, while this doesn't necessarily relate to your issue, it should be pointed out the generator is outdated and currently doesn't align with some of the recent updates to delivery API, such as the addition of display_timezone property (datetime elements are still typed as DateTime? rather than IDateTimeContent). An update to the generator should be coming in the near future.
Motivation
In our solution we have need for serialization and deserialization of the models received from delivery client.
The models are generated by model generator.
The models have properties with interface types and the implementation of the interfaces are hidden from us because they are internal to the delivery client library. This causes problem when we want to deserialize them because System.Text.Json can't deserialize to interface without any concrete implementation.
An example can be interface Kontent.Ai.Delivery.Abstractions.IDateTimeContent.
Proposed solution
Expose implementations for the interfaces used in models generated by model generator.
Additional context
I hope that it is understandable what is going on here, but if not, then let me know and i will provide you with some example project.
The text was updated successfully, but these errors were encountered: