forked from TencentBlueKing/bk-plugin-framework-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.py
More file actions
21 lines (12 loc) · 674 Bytes
/
Copy pathschema.py
File metadata and controls
21 lines (12 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import drf_spectacular.openapi
import drf_spectacular.utils
class IgnoreExcludeAutoSchema(drf_spectacular.openapi.AutoSchema):
"""忽略 @extend_schema(exclude=True),将所有 API 暴露到 Swagger 文档中"""
def is_excluded(self) -> bool:
return False
# Patch extend_schema 装饰器,使 exclude 参数无效
_original_extend_schema = drf_spectacular.utils.extend_schema
def _patched_extend_schema(*args, exclude=None, **kwargs):
"""将 exclude 强制设为 None,使 @extend_schema(exclude=True) 不生效"""
return _original_extend_schema(*args, exclude=None, **kwargs)
drf_spectacular.utils.extend_schema = _patched_extend_schema