Hi,
We have an API method that accepts a list of responses - Responses could be of various types = Number, Text, Date, List etc. Each of these link to a specific model e.g. NumberModel, TextModel, DateModel etc. all which inherit BaseResponseModel.
The request dto is defined to accept a list of BaseResponseModel and based on the response type id, we are planning on instantiating a specific type.
Based on the documentation
We have tried
JsConfig.TypeAttr = “ResponseTypeId”;
and
JsConfig.TypeAttr = “$type”; (as per doco)
// This does not work. Still requires a field __type to be passed in the model.
JsConfig.TypeFinder = typeId =>
{
var fieldTypeId = Guid.Parse(typeId);
if (fieldTypeId == ResponseType.Number)
return typeof(NumberModel);
return typeof(TextModel);
};
Also, is there any way to limit the TypeFinder to run only for a specific request type?
I would appreciate any assistance with this.
Thanks,
Leeny