我将使用Swashbuckle为我编写的ASP.NET Core API生成Swagger文档。在我的API中,我使用了很多自定义的Json转换器,因此我接收和返回的JSON并不完全符合C#类的定义。例如,我可能有一个像这样的类:
然而,Swashbuckle 将其记录为:
public class MyModel
{
private MyClass complicatedField;
}
这将被序列化为
{
"complicatedField": "String representation of the object"
}
然而,Swashbuckle 将其记录为:
{
"complicatedField": {/*Json object of all the fields MyClass has*/}
}
我该如何告诉Swashbuckle我的模型如何进行序列化和反序列化?