From 4903b677f9abecf961b433d96b8234086916bcc3 Mon Sep 17 00:00:00 2001 From: Douwe van der Meij Date: Tue, 3 Sep 2024 08:47:37 +0200 Subject: [PATCH] DefaultRestRouterService now supports read model classes for find_entities --- fractal/__init__.py | 2 +- fractal/contrib/fastapi/routers/default.py | 6 +++++- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fractal/__init__.py b/fractal/__init__.py index d9f0fbd..e4085ac 100644 --- a/fractal/__init__.py +++ b/fractal/__init__.py @@ -1,6 +1,6 @@ """Fractal is a scaffolding toolkit for building SOLID logic for your Python applications.""" -__version__ = "5.2.1" +__version__ = "5.2.2" from abc import ABC diff --git a/fractal/contrib/fastapi/routers/default.py b/fractal/contrib/fastapi/routers/default.py index 0f01d20..7f7f0c3 100644 --- a/fractal/contrib/fastapi/routers/default.py +++ b/fractal/contrib/fastapi/routers/default.py @@ -58,6 +58,7 @@ def info( class DefaultRestRouterService(Service, ABC): domain_entity_class: Type[Model] + domain_read_model_class: Type[Model] = None entities_route: str entity_route: str entities_endpoint: str @@ -246,7 +247,10 @@ def add_entity( @router.get( router_service_class().entities_route, - response_model=List[router_service_class().domain_entity_class], + response_model=List[ + router_service_class().domain_entity_class + | router_service_class().domain_read_model_class + ], status_code=status.HTTP_200_OK, name=f"Find {router_service_class().domain_entity_class.__name__} entities", ) diff --git a/pyproject.toml b/pyproject.toml index 2d56426..a16a258 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fractal-toolkit" -version = "5.2.1" +version = "5.2.2" description = "Fractal is a scaffolding toolkit for building SOLID logic for your Python applications." authors = ["Douwe van der Meij "]