99arguments through to the relevant `fastapi` decorator.
1010
1111This will most usually be applied as a decorator with arguments, available
12- as :deco:`.fastapi_endpoint `. See the documentation for that function for
12+ as :deco:`.endpoint `. See the documentation for that function for
1313more detail.
1414"""
1515
3434 from .thing import Thing
3535
3636HTTPMethod = Literal ["get" , "post" , "put" , "delete" ]
37- """Valid HTTP verbs to use with `.fastapi_endpoint ` or `.EndpointDescriptor`."""
37+ """Valid HTTP verbs to use with `.endpoint ` or `.EndpointDescriptor`."""
3838
3939
4040class EndpointDescriptor (BaseDescriptor ):
@@ -49,7 +49,7 @@ def __init__(
4949 ) -> None :
5050 r"""Initialise an EndpointDescriptor.
5151
52- See `.fastapi_endpoint `, which is the usual way of instantiating this
52+ See `.endpoint `, which is the usual way of instantiating this
5353 class.
5454
5555 :param func: is the method (defined on a `.Thing`) wrapped by this
@@ -107,19 +107,19 @@ def add_to_fastapi(self, app: FastAPI, thing: Thing) -> None:
107107 "path set on the Thing. This usually means it is not connected "
108108 "to a ThingServer."
109109 )
110- # fastapi_endpoint is equivalent to app.get/app.post/whatever
111- fastapi_endpoint = getattr (app , self .http_method )
110+ # endpoint is equivalent to app.get/app.post/whatever
111+ endpoint = getattr (app , self .http_method )
112112 bound_function = partial (self .func , thing )
113113 # NB the line above can't use self.__get__ as wraps() confuses FastAPI
114114 kwargs : dict [str , Any ] = { # Auto-populate description and summary
115115 "description" : f"## { self .title } \n \n { self .description } " ,
116116 "summary" : self .title ,
117117 }
118118 kwargs .update (self .kwargs )
119- fastapi_endpoint (thing .path + self .path , ** kwargs )(bound_function )
119+ endpoint (thing .path + self .path , ** kwargs )(bound_function )
120120
121121
122- def fastapi_endpoint (
122+ def endpoint (
123123 method : HTTPMethod , path : Optional [str ] = None , ** kwargs : Any
124124) -> Callable [[Callable ], EndpointDescriptor ]:
125125 r"""Mark a function as a FastAPI endpoint without making it an action.
@@ -140,7 +140,7 @@ def fastapi_endpoint(
140140 .. code-block:: python
141141
142142 class DownloadThing(Thing):
143- @fastapi_endpoint ("get")
143+ @endpoint ("get")
144144 def plain_text_response(self) -> str:
145145 return "example string"
146146
0 commit comments