77from .. import status
88from ..pagination import paginate
99from .response import Detail
10- from .route import http_delete , http_get , http_patch , http_post , http_put
10+ from .route import route
1111
1212if t .TYPE_CHECKING :
1313 from .base import APIController , ModelControllerBase
@@ -38,12 +38,11 @@ def __init__(
3838 internal_type = controller_base_cls .model ._meta .pk .get_internal_type ()
3939 self ._pk_type : t .Type = TYPES .get (internal_type , str )
4040 self ._model_name = model_pk
41- self .validate_model_builder ()
4241
4342 def _register_create_endpoint (self ) -> None :
4443 create_schema = self ._create_schema
4544
46- @http_post (
45+ @route . post (
4746 "/" ,
4847 response = {201 : self ._model_schema },
4948 url_name = f"{ self ._model_name } -create" ,
@@ -66,7 +65,7 @@ def _register_update_endpoint(self) -> None:
6665 self ._model_name ,
6766 )
6867
69- @http_put (
68+ @route . put (
7069 _path ,
7170 response = {200 : self ._model_schema },
7271 url_name = f"{ self ._model_name } -put" ,
@@ -93,7 +92,7 @@ def _register_patch_endpoint(self) -> None:
9392 self ._model_name ,
9493 )
9594
96- @http_patch (
95+ @route . patch (
9796 _path ,
9897 response = {200 : self ._model_schema },
9998 url_name = f"{ self ._model_name } -patch" ,
@@ -119,7 +118,7 @@ def _register_get_item_endpoint(self) -> None:
119118 self ._model_name ,
120119 )
121120
122- @http_get (
121+ @route . get (
123122 _path ,
124123 response = {200 : self ._model_schema },
125124 url_name = f"{ self ._model_name } -get-item" ,
@@ -140,7 +139,7 @@ def _register_list_items_endpoint(self) -> None:
140139 if self ._base_cls .paginate_by :
141140 paginate_kwargs .update (page_size = self ._base_cls .paginate_by )
142141
143- @http_get (
142+ @route . get (
144143 "/" ,
145144 response = {
146145 200 : self ._base_cls .pagination_response_schema [self ._model_schema ]
@@ -161,7 +160,7 @@ def _register_delete_endpoint(self) -> None:
161160 self ._model_name ,
162161 )
163162
164- @http_delete (
163+ @route . delete (
165164 _path ,
166165 url_name = f"{ self ._model_name } -delete" ,
167166 response = Detail (status_code = 204 ),
0 commit comments