From 28194830700ffb101a7943d9de606718bd249323 Mon Sep 17 00:00:00 2001 From: "Maxime Alves LIRMM@home" Date: Thu, 17 Jun 2021 19:02:11 +0200 Subject: [PATCH] [doc] docstring for api_routes --- halfapi/lib/schemas.py | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/halfapi/lib/schemas.py b/halfapi/lib/schemas.py index 7d95ed5..82abc29 100644 --- a/halfapi/lib/schemas.py +++ b/halfapi/lib/schemas.py @@ -16,26 +16,60 @@ from typing import Dict from starlette.schemas import SchemaGenerator from starlette.exceptions import HTTPException +from .. import __version__ from .routes import gen_starlette_routes, api_acls from .responses import ORJSONResponse logger = logging.getLogger('uvicorn.asgi') SCHEMAS = SchemaGenerator( - {"openapi": "3.0.0", "info": {"title": "HalfAPI", "version": "1.0"}} + {"openapi": "3.0.0", "info": {"title": "HalfAPI", "version": __version__}} ) async def get_api_routes(request, *args, **kwargs): """ - description: Returns the current API routes description (HalfAPI 0.2.1) + description: Returns the current API routes dictionary as a JSON object + example: { + "dummy_domain": { + "abc/alphabet": { + "GET": [ + { + "acl": "public" + } + ] + }, + "abc/alphabet/{test:uuid}": { + "GET": [ + { + "acl": "public" + } + ], + "POST": [ + { + "acl": "public" + } + ], + "PATCH": [ + { + "acl": "public" + } + ], + "PUT": [ + { + "acl": "public" + } + ] + } + } + } """ return ORJSONResponse(request.scope['api']) def get_api_domain_routes(domain): async def wrapped(request, *args, **kwargs): """ - description: Returns the current API routes description (HalfAPI 0.2.1) - as a JSON object + description: Returns the current API routes dictionary for a specific + domain as a JSON object """ if domain in request.scope['api']: return ORJSONResponse(request.scope['api'][domain])