[doc] add docstrings for halfapi routes
This commit is contained in:
parent
2413436104
commit
c4583b7187
|
@ -158,6 +158,12 @@ class HalfAPI(Starlette):
|
||||||
return __version__
|
return __version__
|
||||||
|
|
||||||
async def version_async(self, request, *args, **kwargs):
|
async def version_async(self, request, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
description: Version route
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Currently running HalfAPI's version
|
||||||
|
"""
|
||||||
return Response(self.version)
|
return Response(self.version)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -174,6 +180,16 @@ class HalfAPI(Starlette):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
async def get_user(request, *args, **kwargs):
|
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})
|
return ORJSONResponse({'user':request.user})
|
||||||
|
|
||||||
yield Route('/whoami', get_user)
|
yield Route('/whoami', get_user)
|
||||||
|
|
|
@ -27,8 +27,12 @@ SCHEMAS = SchemaGenerator(
|
||||||
|
|
||||||
async def schema_json(request, *args, **kwargs):
|
async def schema_json(request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
description: Returns the current API routes description (OpenAPI v3)
|
description: |
|
||||||
|
Returns the current API routes description (OpenAPI v3)
|
||||||
as a JSON object
|
as a JSON object
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: API Schema in OpenAPI v3 format
|
||||||
"""
|
"""
|
||||||
return ORJSONResponse(
|
return ORJSONResponse(
|
||||||
SCHEMAS.get_schema(routes=request.app.routes))
|
SCHEMAS.get_schema(routes=request.app.routes))
|
||||||
|
|
Loading…
Reference in New Issue