fix: 修复swagger接口文档中schema不正确的问题

(cherry picked from commit 6f84239e8b)
This commit is contained in:
liqiang-fit2cloud 2024-11-13 15:14:06 +08:00 committed by shaohuzhang1
parent 3cd7b29611
commit ef2bcdcd17
2 changed files with 9 additions and 0 deletions

View File

@ -20,3 +20,10 @@ class CustomSwaggerAutoSchema(SwaggerAutoSchema):
if "api" in tags and operation_keys: if "api" in tags and operation_keys:
return [tags_dict.get(operation_keys[1]) if operation_keys[1] in tags_dict else operation_keys[1]] return [tags_dict.get(operation_keys[1]) if operation_keys[1] in tags_dict else operation_keys[1]]
return tags return tags
def get_schema(self, request=None, public=False):
schema = super().get_schema(request, public)
if request.is_secure():
schema.schemes = ['https']
else:
schema.schemes = ['http']
return schema

View File

@ -26,6 +26,8 @@ DATABASES = {
'default': CONFIG.get_db_setting() 'default': CONFIG.get_db_setting()
} }
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [