1
Some checks failed
API接口参数变更检测 / api-param-check (push) Has been cancelled

This commit is contained in:
2026-06-05 13:59:39 +08:00
parent e90b10b2ae
commit c21ba30c55
2 changed files with 12 additions and 6 deletions

View File

@@ -159,7 +159,10 @@ def _join_paths(base: str, sub: str) -> str:
def _http_method(ann_name: str, ann: Annotation) -> str:
"""从映射注解推断 HTTP 方法。"""
"""从映射注解推断 HTTP 方法。
支持大小写不敏感匹配,避免 PUTMapping、POSTMapping 等不规范写法导致解析失败。
"""
mapping = {
"GetMapping": "GET",
"PostMapping": "POST",
@@ -167,9 +170,11 @@ def _http_method(ann_name: str, ann: Annotation) -> str:
"DeleteMapping": "DELETE",
"PatchMapping": "PATCH",
}
if ann_name in mapping:
return mapping[ann_name]
if ann_name == "RequestMapping":
# 大小写不敏感匹配
for key, value in mapping.items():
if key.lower() == ann_name.lower():
return value
if ann_name.lower() == "requestmapping":
m = _ann_string(ann, "method")
if m:
return m.replace("RequestMethod.", "").upper()