[doc] add docstrings for halfapi routes

This commit is contained in:
maxime 2023-08-01 17:43:59 +02:00
parent 2413436104
commit c4583b7187
2 changed files with 22 additions and 2 deletions

View File

@ -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)

View File

@ -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))