k__BackingField remove in C# (seen via Swashbuckle / Swagger)

后端 未结 1 1874
终归单人心
终归单人心 2021-01-02 00:36

I am using Swashbuckle 5 in my ASP.NET webapi project with all default settings. It serializes my method\'s output in order to show me schema of the reply. I am getting docu

相关标签:
1条回答
  • 2021-01-02 01:23

    Add this to WebApiConfig.cs:

    config.Formatters.JsonFormatter.SerializerSettings.ContractResolver =
        new DefaultContractResolver { IgnoreSerializableAttribute = true };
    

    This resolves the issue for classes marked with [Serializable]. I also have intermittent problems even if no classes have that attribute, so I always use this setting now.

    0 讨论(0)
提交回复
热议问题