From c4583b718791ea0544c97dcc558d62e6ba089478 Mon Sep 17 00:00:00 2001 From: maxime Date: Tue, 1 Aug 2023 17:43:59 +0200 Subject: [PATCH] [doc] add docstrings for halfapi routes --- halfapi/halfapi.py | 16 ++++++++++++++++ halfapi/lib/schemas.py | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/halfapi/halfapi.py b/halfapi/halfapi.py index 736d386..d26f1e1 100644 --- a/halfapi/halfapi.py +++ b/halfapi/halfapi.py @@ -158,6 +158,12 @@ class HalfAPI(Starlette): return __version__ async def version_async(self, request, *args, **kwargs): + """ + description: Version route + responses: + 200: + description: Currently running HalfAPI's version + """ return Response(self.version) @staticmethod @@ -174,6 +180,16 @@ class HalfAPI(Starlette): """ async def get_user(request, *args, **kwargs): + """ + description: WhoAmI route + responses: + 200: + description: The currently logged-in user + content: + application/json: + schema: + type: object + """ return ORJSONResponse({'user':request.user}) yield Route('/whoami', get_user) diff --git a/halfapi/lib/schemas.py b/halfapi/lib/schemas.py index 6cd3c89..eb243d2 100644 --- a/halfapi/lib/schemas.py +++ b/halfapi/lib/schemas.py @@ -27,8 +27,12 @@ SCHEMAS = SchemaGenerator( async def schema_json(request, *args, **kwargs): """ - description: Returns the current API routes description (OpenAPI v3) - as a JSON object + description: | + Returns the current API routes description (OpenAPI v3) + as a JSON object + responses: + 200: + description: API Schema in OpenAPI v3 format """ return ORJSONResponse( SCHEMAS.get_schema(routes=request.app.routes))