File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 66 @date:2023/9/5 14:01
77 @desc: 用于swagger 分组
88"""
9-
9+ from drf_yasg import openapi
10+ from drf_yasg .generators import OpenAPISchemaGenerator
1011from drf_yasg .inspectors import SwaggerAutoSchema
1112
1213tags_dict = {
@@ -20,10 +21,10 @@ def get_tags(self, operation_keys=None):
2021 if "api" in tags and operation_keys :
2122 return [tags_dict .get (operation_keys [1 ]) if operation_keys [1 ] in tags_dict else operation_keys [1 ]]
2223 return tags
24+
25+
26+ class CustomOpenAPISchemaGenerator (OpenAPISchemaGenerator ):
2327 def get_schema (self , request = None , public = False ):
2428 schema = super ().get_schema (request , public )
25- if request .is_secure ():
26- schema .schemes = ['https' ]
27- else :
28- schema .schemes = ['http' ]
29- return schema
29+ schema .schemes = ['https' , 'http' ]
30+ return schema
Original file line number Diff line number Diff line change 8686
8787SWAGGER_SETTINGS = {
8888 'DEFAULT_AUTO_SCHEMA_CLASS' : 'common.config.swagger_conf.CustomSwaggerAutoSchema' ,
89+ 'DEFAULT_GENERATOR_CLASS' : 'common.config.swagger_conf.CustomOpenAPISchemaGenerator' ,
8990 "DEFAULT_MODEL_RENDERING" : "example" ,
9091 'USE_SESSION_AUTH' : False ,
9192 'SECURITY_DEFINITIONS' : {
You can’t perform that action at this time.
0 commit comments