This commit is contained in:
@@ -249,7 +249,9 @@ def compare_endpoints(
|
|||||||
matched_removed: Set[str] = set()
|
matched_removed: Set[str] = set()
|
||||||
matched_added: Set[str] = set()
|
matched_added: Set[str] = set()
|
||||||
|
|
||||||
# 1. HTTP 方法变更检测(uri + controller + method_name 相同,但 method 不同)
|
# 1. HTTP 方法变更检测(uri + controller 相同,但 method 不同)
|
||||||
|
# 放宽匹配条件:只要同一个 Controller 的同一个 URI 请求方式改变,就识别为「修改请求方式」
|
||||||
|
# 不再要求 method_name 相同(允许方法重命名场景)
|
||||||
# 如果同时有参数变更,生成两条独立报告(方法变更 + 参数变更),互不干扰
|
# 如果同时有参数变更,生成两条独立报告(方法变更 + 参数变更),互不干扰
|
||||||
for r_key, r_ep in unmatched_removed:
|
for r_key, r_ep in unmatched_removed:
|
||||||
for a_key, a_ep in unmatched_added:
|
for a_key, a_ep in unmatched_added:
|
||||||
@@ -258,7 +260,6 @@ def compare_endpoints(
|
|||||||
if (
|
if (
|
||||||
r_ep.uri == a_ep.uri
|
r_ep.uri == a_ep.uri
|
||||||
and r_ep.controller_class == a_ep.controller_class
|
and r_ep.controller_class == a_ep.controller_class
|
||||||
and r_ep.method_name == a_ep.method_name
|
|
||||||
and r_ep.http_method != a_ep.http_method
|
and r_ep.http_method != a_ep.http_method
|
||||||
):
|
):
|
||||||
# 先生成纯方法变更报告
|
# 先生成纯方法变更报告
|
||||||
|
|||||||
@@ -159,7 +159,10 @@ def _join_paths(base: str, sub: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def _http_method(ann_name: str, ann: Annotation) -> str:
|
def _http_method(ann_name: str, ann: Annotation) -> str:
|
||||||
"""从映射注解推断 HTTP 方法。"""
|
"""从映射注解推断 HTTP 方法。
|
||||||
|
|
||||||
|
支持大小写不敏感匹配,避免 PUTMapping、POSTMapping 等不规范写法导致解析失败。
|
||||||
|
"""
|
||||||
mapping = {
|
mapping = {
|
||||||
"GetMapping": "GET",
|
"GetMapping": "GET",
|
||||||
"PostMapping": "POST",
|
"PostMapping": "POST",
|
||||||
@@ -167,9 +170,11 @@ def _http_method(ann_name: str, ann: Annotation) -> str:
|
|||||||
"DeleteMapping": "DELETE",
|
"DeleteMapping": "DELETE",
|
||||||
"PatchMapping": "PATCH",
|
"PatchMapping": "PATCH",
|
||||||
}
|
}
|
||||||
if ann_name in mapping:
|
# 大小写不敏感匹配
|
||||||
return mapping[ann_name]
|
for key, value in mapping.items():
|
||||||
if ann_name == "RequestMapping":
|
if key.lower() == ann_name.lower():
|
||||||
|
return value
|
||||||
|
if ann_name.lower() == "requestmapping":
|
||||||
m = _ann_string(ann, "method")
|
m = _ann_string(ann, "method")
|
||||||
if m:
|
if m:
|
||||||
return m.replace("RequestMethod.", "").upper()
|
return m.replace("RequestMethod.", "").upper()
|
||||||
|
|||||||
Reference in New Issue
Block a user