Skip to content

Commit a65a99b

Browse files
fix: list functions pagination
1 parent 4ce8271 commit a65a99b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

services/web/server/src/simcore_service_webserver/functions/_controller/_functions_rest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
)
1010
from models_library.api_schemas_webserver.users import MyFunctionPermissionsGet
1111
from models_library.functions import FunctionClass, RegisteredProjectFunction
12-
from models_library.rest_pagination import Page
12+
from models_library.rest_pagination import ItemT, Page
1313
from models_library.rest_pagination_utils import paginate_data
1414
from pydantic import TypeAdapter
1515
from servicelib.aiohttp import status
@@ -18,6 +18,8 @@
1818
parse_request_path_parameters_as,
1919
parse_request_query_parameters_as,
2020
)
21+
from servicelib.mimetype_constants import MIMETYPE_APPLICATION_JSON
22+
from servicelib.rest_constants import RESPONSE_MODEL_POLICY
2123

2224
from ..._meta import API_VTAG as VTAG
2325
from ...login.decorators import login_required
@@ -37,6 +39,13 @@
3739
routes = web.RouteTableDef()
3840

3941

42+
def _create_json_response_from_page(page: Page[ItemT]):
43+
return web.Response(
44+
text=page.model_dump_json(**RESPONSE_MODEL_POLICY),
45+
content_type=MIMETYPE_APPLICATION_JSON,
46+
)
47+
48+
4049
@routes.post(f"/{VTAG}/functions", name="register_function")
4150
@login_required
4251
@handle_rest_requests_exceptions
@@ -143,7 +152,7 @@ async def list_functions(request: web.Request) -> web.Response:
143152
offset=query_params.offset,
144153
)
145154
)
146-
return envelope_json_response(page)
155+
return _create_json_response_from_page(page)
147156

148157

149158
@routes.get(

0 commit comments

Comments
 (0)