Skip to content

Commit 499f505

Browse files
adds docstring to interfaces
1 parent 9ba7aa2 commit 499f505

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/controllers/interface.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ async def wrapper(self, *args, **kwargs):
3737

3838

3939
class ControllerBase:
40+
"""
41+
ControllerBase is a base class for all controllers. It provides a set of
42+
methods to handle the CRUD operations for the models provided in the
43+
constructor. CRUD methods are generated dynamically based on the model
44+
methods and the model name.
45+
46+
The methods are named as follows:
47+
- post_{model_name} for POST method
48+
- get_{model_name}_by_id for GET method
49+
- put_{model_name}_by_id for PUT method
50+
- delete_{model_name}_by_id for DELETE method
51+
52+
"""
4053

4154
def __init__(self, models: List[ApiBaseModel]):
4255
self._initialized_models = {}

src/models/interface.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99

1010
class ApiBaseModel(BaseModel, ABC):
11+
"""
12+
Base class for all models in the API.
13+
14+
This class is used to define the common attributes and
15+
methods that all models in the API should have.
16+
"""
17+
1118
_id: Optional[str] = PrivateAttr(default=None)
1219
model_config = ConfigDict(
1320
use_enum_values=True,

src/repositories/interface.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ def get_instance(self):
8282
class RepositoryInterface:
8383
"""
8484
Interface class for all repositories (singleton)
85+
86+
This class is used to define the common attributes and
87+
methods that all repositories should have.
88+
89+
The class is a singleton, meaning that only one instance
90+
of the class is created and shared among all instances
91+
of the class. This is done to ensure that only one
92+
connection per collection in the database is created
93+
and shared among all repositories.
8594
"""
8695

8796
_global_instances = {}

0 commit comments

Comments
 (0)