Skip to content

Commit 64e26dd

Browse files
committed
feat: change icon edit method from POST to PUT for tools and shared tools
1 parent 61359e0 commit 64e26dd

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

apps/tools/api/tool.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,42 @@ def get_parameters():
236236
@staticmethod
237237
def get_request():
238238
return PylintInstance
239+
240+
241+
class EditIconAPI(APIMixin):
242+
@staticmethod
243+
def get_parameters():
244+
return [
245+
OpenApiParameter(
246+
name="workspace_id",
247+
description="工作空间id",
248+
type=OpenApiTypes.STR,
249+
location='path',
250+
required=True,
251+
),
252+
OpenApiParameter(
253+
name="tool_id",
254+
description="工具id",
255+
type=OpenApiTypes.STR,
256+
location='path',
257+
required=True,
258+
),
259+
]
260+
261+
@staticmethod
262+
def get_request():
263+
return {
264+
'multipart/form-data': {
265+
'type': 'object',
266+
'properties': {
267+
'icon': {
268+
'type': 'string',
269+
'format': 'binary' # Tells Swagger it's a file
270+
}
271+
}
272+
}
273+
}
274+
275+
@staticmethod
276+
def get_response():
277+
return DefaultResultSerializer

apps/tools/views/tool.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from common.constants.permission_constants import PermissionConstants
1010
from common.result import result
1111
from tools.api.tool import ToolCreateAPI, ToolEditAPI, ToolReadAPI, ToolDeleteAPI, ToolTreeReadAPI, ToolDebugApi, \
12-
ToolExportAPI, ToolImportAPI, ToolPageAPI, PylintAPI
12+
ToolExportAPI, ToolImportAPI, ToolPageAPI, PylintAPI, EditIconAPI
1313
from tools.serializers.tool import ToolSerializer, ToolTreeSerializer
1414

1515

@@ -198,6 +198,16 @@ class EditIcon(APIView):
198198
authentication_classes = [TokenAuth]
199199
parser_classes = [MultiPartParser]
200200

201+
@extend_schema(
202+
methods=['PUT'],
203+
summary=_('Edit tool icon'),
204+
operation_id=_('Edit tool icon'), # type: ignore
205+
description=_('Edit tool icon'),
206+
request=EditIconAPI.get_request(),
207+
responses=EditIconAPI.get_response(),
208+
parameters=EditIconAPI.get_parameters(),
209+
tags=[_('Tool')] # type: ignore
210+
)
201211
@has_permissions(PermissionConstants.TOOL_EDIT.get_workspace_permission())
202212
def put(self, request: Request, id: str, workspace_id: str):
203213
return result.success(ToolSerializer.IconOperate(data={

0 commit comments

Comments
 (0)