Swashbuckle正在使用System生成无效的JSON.集合.通用的KeyValuePair架构



我有一个ASP。NET核心API,它正在生成无效的JSON,我不确定它是从哪里来的。根据swagger验证器,问题在于以下模式。

"attribute components.schemas.Schema name System.Collections.Generic.KeyValuePair`2[[System.String,
 System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Collections.Generic.IEnumerable`1[[System.String,
 System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]],
 System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
 doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$"

以下是实际JSON:的副本

"System.Collections.Generic.KeyValuePair`2[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Collections.Generic.IEnumerable`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]": {
"type": "object",
"properties": {
"key": {
"type": "string",
"nullable": true,
"readOnly": true
},
"value": {
"type": "array",
"items": {
"type": "string"
},
"nullable": true,
"readOnly": true
}
}
}

我已经搜索了整个项目,找到了它被引用的地方,但我没有找到任何东西。我以前也在模式中见过System类。有人知道为什么这会出现在招摇撞骗的文件中吗?

我在从进行升级时遇到了同样的问题。NET Framework到。NET6。我找到了这个引用的来源,发现我仍然有一个Returntype为HttpResponseMessage而不是IActionResult的Endpoint

最新更新