我有一个多态模型:
public class CreateOrderRequest
{
public List<CreateOrderItem> OrderItems { get; set; }
}
/// <summary>
/// Identifies a new item within an order
/// </summary>
[JsonConverter(typeof(CreateOrderLineJsonConvertor))]
[KnownType("GetKnownTypes")]
public class CreateOrderItem
{
public string OrderContext { get; set; }
public string OrderItemType { get; set; }
public static Type[] GetKnownTypes()
{
return new[]
{
typeof(OrderItemType1), typeof(OrderItemType2)
};
}
}
public class OrderItemType1: CreateOrderItem
{
public string Type1Prop {get;set;}
}
public class OrderItemType2: CreateOrderItem
{
public string Type2Prop {get;set;}
}
根据文档使用 NSwag (NSwag.AspNetCore),我希望这足以让文档指示/包含订单项目类型?但不是...
我是否完全错过了 NSwag 的要求?我有 OrderItemType 属性。我需要让歧视者参与进来吗?这是在哪里记录的?
TIA