Skip to content

Commit 28e3315

Browse files
committed
docs: adding CRUD api documentation
1 parent bbc99f7 commit 28e3315

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

easy/controller/base.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
import logging
2-
from typing import Optional
32

43
from ninja_extra import ControllerBase
54

65
from easy.controller.meta import CrudAPI, CrudApiMetaclass
7-
from easy.services import BaseService
86

97
logger = logging.getLogger(__name__)
108

119

1210
class CrudAPIController(ControllerBase, CrudAPI, metaclass=CrudApiMetaclass):
13-
"""For Client facing APIs"""
11+
"""
12+
Base APIController for auto creating CRUD APIs
1413
15-
def __init__(self, service: Optional["BaseService"] = None):
16-
super().__init__(service=service) # type: ignore
14+
GET /{id} - Retrieve a single Object
15+
PUT / - Create a single Object
16+
PATCH /?id={id} - Update a single field for a Object
17+
DELETE /{id} - Delete a single Object
18+
GET /get_all - Retrieve multiple Object
19+
GET /filter/?filters={filters_dict}
20+
- Filter Objects with django-orm filter dict
21+
GET /filter_exclude/?filters={filters_dict}
22+
- Filter exclude Objects with Django-ORM filter dict
23+
24+
"""
25+
26+
...

easy/controller/meta.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def get_obj(self, request: HttpRequest, id: int) -> Any:
3636

3737
async def del_obj(self, request: HttpRequest, id: int) -> Any:
3838
"""
39-
DELETE /objects/{id}
39+
DELETE /{id}
4040
Delete a single Object
4141
"""
4242
return await self.service.del_obj(id)
@@ -59,15 +59,15 @@ async def filter_objs(
5959
) -> Any:
6060
"""
6161
GET /filter/?filters={filters_dict}
62-
Filter Objects
62+
Filter Objects with Django-ORM filter dict
6363
"""
6464
return await self.service.filter_objs(**json.loads(filters))
6565

6666
@paginate
6767
async def filter_exclude_objs(self, filters: Union[str, bytes]) -> Any:
6868
"""
6969
GET /filter_exclude/?filters={filters_dict}
70-
Filter exclude Objects
70+
Filter exclude Objects with Django-ORM filter dict
7171
"""
7272
return await self.service.filter_exclude_objs(**json.loads(filters))
7373

0 commit comments

Comments
 (0)