Skip to content

Commit f21d301

Browse files
committed
fix: change HTTP methods from PUT to GET for association and unassociation endpoints
1 parent 6f81d80 commit f21d301

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

apps/knowledge/api/paragraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ def get_parameters():
201201
name="paragraph_id",
202202
description="段落id",
203203
type=OpenApiTypes.STR,
204-
location='path',
204+
location='query',
205205
required=True,
206206
),
207207
OpenApiParameter(
208208
name="problem_id",
209209
description="问题id",
210210
type=OpenApiTypes.STR,
211-
location='path',
211+
location='query',
212212
required=True,
213213
)
214214
]

apps/knowledge/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph', views.ParagraphView.as_view()),
3434
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/batch_delete', views.ParagraphView.BatchDelete.as_view()),
3535
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/batch_generate_related', views.ParagraphView.BatchGenerateRelated.as_view()),
36+
path( 'workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/association', views.ParagraphView.Association.as_view()),
37+
path( 'workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/unassociation', views.ParagraphView.UnAssociation.as_view()),
3638
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<str:paragraph_id>', views.ParagraphView.Operate.as_view()),
3739
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<str:paragraph_id>/problem', views.ParagraphView.Problem.as_view()),
3840
path( 'workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<int:current_page>/<int:page_size>', views.ParagraphView.Page.as_view()),
39-
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<str:paragraph_id>/problem/<str:problem_id>/association', views.ParagraphView.Association.as_view()),
40-
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<str:paragraph_id>/problem/<str:problem_id>/unassociation', views.ParagraphView.UnAssociation.as_view()),
4141
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem', views.ProblemView.as_view()),
4242
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem/batch_delete', views.ProblemView.BatchDelete.as_view()),
4343
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem/batch_association', views.ProblemView.BatchAssociation.as_view()),

apps/knowledge/views/paragraph.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class UnAssociation(APIView):
207207
authentication_classes = [TokenAuth]
208208

209209
@extend_schema(
210-
methods=['PUT'],
210+
methods=['GET'],
211211
summary=_('Disassociation issue'),
212212
description=_('Disassociation issue'),
213213
operation_id=_('Disassociation issue'), # type: ignore
@@ -216,23 +216,22 @@ class UnAssociation(APIView):
216216
tags=[_('Knowledge Base/Documentation/Paragraph')] # type: ignore
217217
)
218218
@has_permissions(PermissionConstants.DOCUMENT_EDIT.get_workspace_permission())
219-
def put(self, request: Request,
220-
workspace_id: str, knowledge_id: str, document_id: str, paragraph_id: str, problem_id: str):
219+
def get(self, request: Request, workspace_id: str, knowledge_id: str, document_id: str):
221220
return result.success(ParagraphSerializers.Association(
222221
data={
223222
'workspace_id': workspace_id,
224223
'knowledge_id': knowledge_id,
225224
'document_id': document_id,
226-
'paragraph_id': paragraph_id,
227-
'problem_id': problem_id
225+
'paragraph_id': request.query_params.get('paragraph_id'),
226+
'problem_id': request.query_params.get('problem_id')
228227
}
229228
).un_association())
230229

231230
class Association(APIView):
232231
authentication_classes = [TokenAuth]
233232

234233
@extend_schema(
235-
methods=['PUT'],
234+
methods=['GET'],
236235
summary=_('Related questions'),
237236
description=_('Related questions'),
238237
operation_id=_('Related questions'), # type: ignore
@@ -241,15 +240,14 @@ class Association(APIView):
241240
tags=[_('Knowledge Base/Documentation/Paragraph')] # type: ignore
242241
)
243242
@has_permissions(PermissionConstants.DOCUMENT_EDIT.get_workspace_permission())
244-
def put(self, request: Request,
245-
workspace_id: str, knowledge_id: str, document_id: str, paragraph_id: str, problem_id: str):
243+
def get(self, request: Request, workspace_id: str, knowledge_id: str, document_id: str):
246244
return result.success(ParagraphSerializers.Association(
247245
data={
248246
'workspace_id': workspace_id,
249247
'knowledge_id': knowledge_id,
250248
'document_id': document_id,
251-
'paragraph_id': paragraph_id,
252-
'problem_id': problem_id
249+
'paragraph_id': request.query_params.get('paragraph_id'),
250+
'problem_id': request.query_params.get('problem_id')
253251
}
254252
).association())
255253

0 commit comments

Comments
 (0)