mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: schema access failure to https
This commit is contained in:
parent
f6e089daee
commit
b8960d57c8
|
|
@ -6,7 +6,7 @@
|
|||
@date:2023/9/5 14:01
|
||||
@desc: 用于swagger 分组
|
||||
"""
|
||||
|
||||
from drf_yasg.generators import OpenAPISchemaGenerator
|
||||
from drf_yasg.inspectors import SwaggerAutoSchema
|
||||
|
||||
tags_dict = {
|
||||
|
|
@ -20,10 +20,10 @@ class CustomSwaggerAutoSchema(SwaggerAutoSchema):
|
|||
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
|
||||
|
||||
|
||||
class CustomOpenAPISchemaGenerator(OpenAPISchemaGenerator):
|
||||
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
|
||||
schema.schemes = ['https', 'http']
|
||||
return schema
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ TEMPLATES = [
|
|||
|
||||
SWAGGER_SETTINGS = {
|
||||
'DEFAULT_AUTO_SCHEMA_CLASS': 'common.config.swagger_conf.CustomSwaggerAutoSchema',
|
||||
'DEFAULT_GENERATOR_CLASS': 'common.config.swagger_conf.CustomOpenAPISchemaGenerator',
|
||||
"DEFAULT_MODEL_RENDERING": "example",
|
||||
'USE_SESSION_AUTH': False,
|
||||
'SECURITY_DEFINITIONS': {
|
||||
|
|
|
|||
Loading…
Reference in New Issue