Skip to content

Commit 6f84239

Browse files
fix: 修复swagger接口文档中schema不正确的问题
1 parent 4a043cf commit 6f84239

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

apps/common/config/swagger_conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ def get_tags(self, operation_keys=None):
2020
if "api" in tags and operation_keys:
2121
return [tags_dict.get(operation_keys[1]) if operation_keys[1] in tags_dict else operation_keys[1]]
2222
return tags
23+
def get_schema(self, request=None, public=False):
24+
schema = super().get_schema(request, public)
25+
if request.is_secure():
26+
schema.schemes = ['https']
27+
else:
28+
schema.schemes = ['http']
29+
return schema

apps/smartdoc/settings/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
'default': CONFIG.get_db_setting()
2727
}
2828

29+
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
30+
2931
# Application definition
3032

3133
INSTALLED_APPS = [

0 commit comments

Comments
 (0)