1.Startup.cs文件
(1)Json格式设置
安装 Microsoft.AspNetCore.Mvc.NewtonsoftJson 3.1.0版本
//core3.1
.AddMvc() .AddNewtonsoftJson(options =>
{
//忽略循环引用
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; // 设置时区为 UTC)
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
});
(2)swagger配置
安装 swashbuckle.aspnetcore 5.6.3
//core3.1
services.AddSwaggerGen(e => {
e.SwaggerDoc("v1",
new Microso