2023-09-15 09:40:35 +00:00
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
"""
|
|
|
|
|
|
@project: qabot
|
|
|
|
|
|
@Author:虎
|
|
|
|
|
|
@file: swagger_conf.py
|
|
|
|
|
|
@date:2023/9/5 14:01
|
|
|
|
|
|
@desc: 用于swagger 分组
|
|
|
|
|
|
"""
|
2025-03-14 08:23:05 +00:00
|
|
|
|
from drf_yasg.generators import OpenAPISchemaGenerator
|
2023-09-15 09:40:35 +00:00
|
|
|
|
from drf_yasg.inspectors import SwaggerAutoSchema
|
|
|
|
|
|
|
|
|
|
|
|
tags_dict = {
|
|
|
|
|
|
'user': '用户'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CustomSwaggerAutoSchema(SwaggerAutoSchema):
|
|
|
|
|
|
def get_tags(self, operation_keys=None):
|
|
|
|
|
|
tags = super().get_tags(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
|
2025-03-14 08:23:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CustomOpenAPISchemaGenerator(OpenAPISchemaGenerator):
|
2024-11-13 07:14:06 +00:00
|
|
|
|
def get_schema(self, request=None, public=False):
|
|
|
|
|
|
schema = super().get_schema(request, public)
|
2025-03-14 08:23:05 +00:00
|
|
|
|
schema.schemes = ['https', 'http']
|
|
|
|
|
|
return schema
|