From 586bf74ddd3362cd4bbe0a534cfb78d7f82d2de2 Mon Sep 17 00:00:00 2001 From: Paxton Date: Thu, 7 Jul 2022 02:17:29 +0000 Subject: [PATCH 1/4] add crud router name --- fastapi_crudrouter/core/_base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fastapi_crudrouter/core/_base.py b/fastapi_crudrouter/core/_base.py index e45d33fe..285a5ca6 100644 --- a/fastapi_crudrouter/core/_base.py +++ b/fastapi_crudrouter/core/_base.py @@ -61,6 +61,7 @@ def __init__( response_model=Optional[List[self.schema]], # type: ignore summary="Get All", dependencies=get_all_route, + name=f"get_all_{prefix}", ) if create_route: @@ -81,6 +82,7 @@ def __init__( response_model=Optional[List[self.schema]], # type: ignore summary="Delete All", dependencies=delete_all_route, + name=f"delete_all_{prefix}", ) if get_one_route: @@ -92,6 +94,7 @@ def __init__( summary="Get One", dependencies=get_one_route, error_responses=[NOT_FOUND], + name=f"get_one_{prefix}", ) if update_route: @@ -103,6 +106,7 @@ def __init__( summary="Update One", dependencies=update_route, error_responses=[NOT_FOUND], + name=f"update_one_{prefix}", ) if delete_one_route: @@ -114,6 +118,7 @@ def __init__( summary="Delete One", dependencies=delete_one_route, error_responses=[NOT_FOUND], + name=f"delete_one_{prefix}", ) def _add_api_route( From 9fddb6d5fd8bd4fb5dd60aadb2cded26e398ad5c Mon Sep 17 00:00:00 2001 From: Paxton Date: Thu, 7 Jul 2022 02:22:31 +0000 Subject: [PATCH 2/4] fix the route name issuse --- fastapi_crudrouter/core/_base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fastapi_crudrouter/core/_base.py b/fastapi_crudrouter/core/_base.py index 285a5ca6..0bc4b712 100644 --- a/fastapi_crudrouter/core/_base.py +++ b/fastapi_crudrouter/core/_base.py @@ -61,7 +61,7 @@ def __init__( response_model=Optional[List[self.schema]], # type: ignore summary="Get All", dependencies=get_all_route, - name=f"get_all_{prefix}", + name=f"get_all_{prefix.schema.__name__.lower()}", ) if create_route: @@ -82,7 +82,7 @@ def __init__( response_model=Optional[List[self.schema]], # type: ignore summary="Delete All", dependencies=delete_all_route, - name=f"delete_all_{prefix}", + name=f"delete_all_{prefix.schema.__name__.lower()}", ) if get_one_route: @@ -94,7 +94,7 @@ def __init__( summary="Get One", dependencies=get_one_route, error_responses=[NOT_FOUND], - name=f"get_one_{prefix}", + name=f"get_one_{prefix.schema.__name__.lower()}", ) if update_route: @@ -106,7 +106,7 @@ def __init__( summary="Update One", dependencies=update_route, error_responses=[NOT_FOUND], - name=f"update_one_{prefix}", + name=f"update_one_{prefix.schema.__name__.lower()}", ) if delete_one_route: @@ -118,7 +118,7 @@ def __init__( summary="Delete One", dependencies=delete_one_route, error_responses=[NOT_FOUND], - name=f"delete_one_{prefix}", + name=f"delete_one_{prefix.schema.__name__.lower()}", ) def _add_api_route( From f960abf7c78c6fbf477cee3f63591cd33e7e8239 Mon Sep 17 00:00:00 2001 From: Paxton Date: Thu, 7 Jul 2022 02:25:17 +0000 Subject: [PATCH 3/4] route name bug fix --- fastapi_crudrouter/core/_base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fastapi_crudrouter/core/_base.py b/fastapi_crudrouter/core/_base.py index 0bc4b712..b3d3af76 100644 --- a/fastapi_crudrouter/core/_base.py +++ b/fastapi_crudrouter/core/_base.py @@ -61,7 +61,7 @@ def __init__( response_model=Optional[List[self.schema]], # type: ignore summary="Get All", dependencies=get_all_route, - name=f"get_all_{prefix.schema.__name__.lower()}", + name=f"get_all_{prefix.replace('/','').lower()}", ) if create_route: @@ -82,7 +82,7 @@ def __init__( response_model=Optional[List[self.schema]], # type: ignore summary="Delete All", dependencies=delete_all_route, - name=f"delete_all_{prefix.schema.__name__.lower()}", + name=f"delete_all_{prefix.replace('/','').lower()}", ) if get_one_route: @@ -94,7 +94,7 @@ def __init__( summary="Get One", dependencies=get_one_route, error_responses=[NOT_FOUND], - name=f"get_one_{prefix.schema.__name__.lower()}", + name=f"get_one_{prefix.replace('/','').lower()}", ) if update_route: @@ -106,7 +106,7 @@ def __init__( summary="Update One", dependencies=update_route, error_responses=[NOT_FOUND], - name=f"update_one_{prefix.schema.__name__.lower()}", + name=f"update_one_{prefix.replace('/','').lower()}", ) if delete_one_route: @@ -118,7 +118,7 @@ def __init__( summary="Delete One", dependencies=delete_one_route, error_responses=[NOT_FOUND], - name=f"delete_one_{prefix.schema.__name__.lower()}", + name=f"delete_one_{prefix.replace('/','').lower()}", ) def _add_api_route( From 84e491c22ae546ba7ba2095db91f2c2e7673e10f Mon Sep 17 00:00:00 2001 From: Paxton Date: Thu, 7 Jul 2022 03:38:47 +0000 Subject: [PATCH 4/4] add create one name --- fastapi_crudrouter/core/_base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fastapi_crudrouter/core/_base.py b/fastapi_crudrouter/core/_base.py index b3d3af76..08bc1374 100644 --- a/fastapi_crudrouter/core/_base.py +++ b/fastapi_crudrouter/core/_base.py @@ -72,6 +72,7 @@ def __init__( response_model=self.schema, summary="Create One", dependencies=create_route, + name=f"create_one_{prefix.replace('/','').lower()}", ) if delete_all_route: