Skip to content

Commit f65ce8b

Browse files
Refactors conversation endpoints to use query helpers
Switches to using a query parameter utility for improved validation and simplifies endpoint signatures. Updates OpenAPI spec to clarify request body requirements and relaxes query param constraints to offer greater flexibility in API usage.
1 parent 083b377 commit f65ce8b

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

api/specs/web-server/_conversations.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from typing import Annotated
1313

14+
from _common import as_query
1415
from fastapi import APIRouter, Depends, status
1516
from models_library.api_schemas_webserver.conversations import (
1617
ConversationMessagePatch,
@@ -74,8 +75,8 @@ async def list_conversations(
7475
)
7576
async def update_conversation(
7677
_params: Annotated[ConversationPathParams, Depends()],
77-
_body: Annotated[ConversationPatch, Depends()],
78-
_query: Annotated[_GetConversationsQueryParams, Depends()],
78+
_body: ConversationPatch,
79+
_query: Annotated[as_query(_GetConversationsQueryParams), Depends()],
7980
): ...
8081

8182

@@ -85,7 +86,7 @@ async def update_conversation(
8586
)
8687
async def delete_conversation(
8788
_params: Annotated[ConversationPathParams, Depends()],
88-
_query: Annotated[_GetConversationsQueryParams, Depends()],
89+
_query: Annotated[as_query(_GetConversationsQueryParams), Depends()],
8990
): ...
9091

9192

@@ -95,7 +96,7 @@ async def delete_conversation(
9596
)
9697
async def get_conversation(
9798
_params: Annotated[ConversationPathParams, Depends()],
98-
_query: Annotated[_GetConversationsQueryParams, Depends()],
99+
_query: Annotated[as_query(_GetConversationsQueryParams), Depends()],
99100
): ...
100101

101102

@@ -121,7 +122,7 @@ async def create_conversation_message(
121122
)
122123
async def list_conversation_messages(
123124
_params: Annotated[ConversationPathParams, Depends()],
124-
_query: Annotated[_ListConversationMessageQueryParams, Depends()],
125+
_query: Annotated[as_query(_ListConversationMessageQueryParams), Depends()],
125126
): ...
126127

127128

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -593,19 +593,17 @@ paths:
593593
type: string
594594
format: uuid
595595
title: Conversation Id
596-
- name: name
597-
in: query
598-
required: false
599-
schema:
600-
anyOf:
601-
- type: string
602-
- type: 'null'
603-
title: Name
604596
- name: type
605597
in: query
606598
required: true
607599
schema:
608600
$ref: '#/components/schemas/ConversationType'
601+
requestBody:
602+
required: true
603+
content:
604+
application/json:
605+
schema:
606+
$ref: '#/components/schemas/ConversationPatch'
609607
responses:
610608
'200':
611609
description: Successful Response
@@ -704,16 +702,13 @@ paths:
704702
required: false
705703
schema:
706704
type: integer
707-
maximum: 50
708-
minimum: 1
709705
default: 20
710706
title: Limit
711707
- name: offset
712708
in: query
713709
required: false
714710
schema:
715711
type: integer
716-
minimum: 0
717712
default: 0
718713
title: Offset
719714
responses:
@@ -10210,6 +10205,15 @@ components:
1021010205
- MESSAGE
1021110206
- NOTIFICATION
1021210207
title: ConversationMessageType
10208+
ConversationPatch:
10209+
properties:
10210+
name:
10211+
anyOf:
10212+
- type: string
10213+
- type: 'null'
10214+
title: Name
10215+
type: object
10216+
title: ConversationPatch
1021310217
ConversationRestGet:
1021410218
properties:
1021510219
conversationId:

0 commit comments

Comments
 (0)