Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
AI OnAI Off
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
I believe you need to create your own convertor see here for an example
Property Lists Serialization and Content Delivery API (optimizely.com)
Thank you!
Basing on your post, I was able to figure out the solution for IEnumerable<string>:
public class ListPropertyConvertorProvider : IPropertyConverterProvider
{
private readonly IServiceProvider _serviceProvider;
public ListPropertyConvertorProvider(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
}
public IPropertyConverter? Resolve(PropertyData propertyData)
{
return propertyData switch
{
StringListProperty => _serviceProvider.GetRequiredService<StringItemListPropertyConverter>(),
_ => null
};
}
public int SortOrder => 100;
}
public class StringItemListPropertyConverter : IPropertyConverter
{
public IPropertyModel Convert(PropertyData propertyData, ConverterContext contentMappingContext)
{
return new StringItemPropertyModel((StringListProperty)propertyData);
}
}
public class StringItemPropertyModel : PropertyModel<IEnumerable<string>, PropertyList<string>>
{
public StringItemPropertyModel(StringListProperty type) : base(type) =>
Value = type.List;
}
For a given enumerable property:
public virtual IList<string> QuestionsAndAnswers { get; set; }
when calling Content Delivery API:
/api/episerver/v3.0/content/5421?expand=*
All properties of the block are received except the `QuestionsAndAnswers`.
Using:
- EPiServer.CMS 12.15.1
- EPiServer.CMS.Core 12.11.0
- EPiServer.ContentDeliveryApi.Cms 3.6.0
How should I let the API return that list?