当我查询AutoQuery服务(常规GET请求)时,即使请求运行正常,也会在日志中收到警告。对于URL:https://localhost:5001/employees?BirthDate%3E=1950-01-01
,警告如下所示
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2 GET https://localhost:5001/employees?BirthDate%3E=1950-01-01 - -
warn: ServiceStack.Serialization.StringMapTypeDeserializer[0]
Property 'birthdate>' does not exist on type 'autoquery.ServiceModel.AutoQueries+QueryEmployee'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/2 GET https://localhost:5001/employees?BirthDate%3E=1950-01-01 - - - 200 - text/html 291.5297ms
我已经使用Northwind数据库创建了一个示例,该数据库是通过x mix northwind.sqlite
和DTO从以下官方示例中获得的:https://github.com/ServiceStackApps/Northwind/blob/master/src/Northwind/Northwind.ServiceModel/Types/Employee.cs。
这个“错误警告”有点麻烦,因为没有任何错误,而且它在我的日志中填满了我需要忽略的警告。特别是因为我已经在日志中为WARN+ERR设置了警报。
发布于 2021-08-25 01:43:02
当使用AutoQuery's Implicit Contentions时,会记录警告,因为请求发送到的API没有匹配的request DTO属性。
您可以将BirthDate
作为AutoQuery DTO的类型化属性添加,也可以使用以下命令忽略所有"BirthDate“属性:
SetConfig(new HostConfig {
IgnoreWarningsOnPropertyNames = { "BirthDate" }
});
或者,您可以使用以下命令禁用所有缺少属性的警告:
SetConfig(new HostConfig {
IgnoreWarningsOnAllProperties = true
});
在现在的最新版本5.12.1中,默认情况下,available on MyGet ServiceStack将不再警告AutoQuery DTO上缺少属性,可以使用以下命令重新启用它:
SetConfig(new HostConfig {
IgnoreWarningsOnAutoQueryApis = false
});
https://stackoverflow.com/questions/68920127
复制