diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendRequest.json new file mode 100644 index 00000000..463a6d6b --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendRequest.json @@ -0,0 +1,21 @@ +{ + "touser": "OPENID", + "template_id": "TEMPLATE_ID", + "page": "index", + "miniprogram_state": "developer", + "lang": "zh_CN", + "data": { + "number01": { + "value": "339208499" + }, + "date01": { + "value": "2015年01月05日" + }, + "site01": { + "value": "TIT创意园" + }, + "site02": { + "value": "广州市新港中路397号" + } + } +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendResponse.json new file mode 100644 index 00000000..f752befe --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinMessageSubscribe/CgibinMessageSubscribeSendResponse.json @@ -0,0 +1,4 @@ +{ + "errcode": 0, + "errmsg": "ok" +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs b/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs index 6051f1d0..27aab4fe 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.TestTools/CodeStyleUtil.cs @@ -490,16 +490,19 @@ namespace SKIT.FlurlHttpClient.Wechat // 如果是 GET 请求,检查是否包含 JSON 序列化字段 if ("GET".Equals(expectedRequestMethod, StringComparison.OrdinalIgnoreCase)) { - if (new Regex("\\[Newtonsoft.Json.JsonProperty\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) + if (!reqCodeSourceCode.Contains("/* @codestyle-disable") || !reqCodeSourceCode.Contains("no-jsonable-property-in-get")) { - lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); - return false; - } + if (new Regex("\\[Newtonsoft.Json.JsonProperty\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) + { + lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); + return false; + } - if (new Regex("\\[System.Text.Json.Serialization.JsonPropertyName\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) - { - lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); - return false; + if (new Regex("\\[System.Text.Json.Serialization.JsonPropertyName\\(\"[a-zA-Z0-9_]*\"\\)\\]").IsMatch(reqCodeSourceCode)) + { + lstError.Add(new Exception($"源代码 \"{reqCodeFileName}\" 下文档代码有误,请求模型为简单请求、不应包含可 JSON 序列化字段。")); + return false; + } } }