[schemas] supression des fonctions api_routes

This commit is contained in:
Maxime Alves LIRMM 2021-11-30 14:40:07 +01:00
parent 7230316296
commit ec26438340
4 changed files with 4 additions and 66 deletions

View File

@ -40,7 +40,7 @@ from halfapi.lib.responses import (ORJSONResponse, UnauthorizedResponse,
ServiceUnavailableResponse)
from halfapi.lib.routes import gen_domain_routes, gen_schema_routes, JSONRoute
from halfapi.lib.schemas import get_api_routes, get_api_domain_routes, schema_json, get_acls
from halfapi.lib.schemas import schema_json, get_acls
from halfapi.logging import logger, config_logging
from halfapi import __version__
@ -81,7 +81,7 @@ class HalfAPI:
DOMAINS[domain] = importlib.import_module(f'{domain}.{router}')
if DOMAINS:
self.api_routes = get_api_routes(DOMAINS)
self.api_routes = {}
routes = [ Route('/', JSONRoute(self.api_routes)) ]

View File

@ -1,7 +1,6 @@
""" Schemas module
Functions :
- get_api_routes
- schema_json
- schema_dict_dom
- get_acls
@ -27,67 +26,6 @@ SCHEMAS = SchemaGenerator(
{"openapi": "3.0.0", "info": {"title": "HalfAPI", "version": __version__}}
)
def get_api_routes(domains: Dict[str, ModuleType]) -> Dict:
"""
description: Returns the current API routes dictionary
as a JSON object
example: {
"dummy_domain": {
"abc/alphabet": {
"GET": {
"docs": "",
"acls": [
{
"acl": "public"
}
]
}
},
"abc/alphabet/{test:uuid}": {
"GET": [
{
"acl": "public"
}
],
"POST": [
{
"acl": "public"
}
],
"PATCH": [
{
"acl": "public"
}
],
"PUT": [
{
"acl": "public"
}
]
}
}
}
"""
return {
domain: api_routes(m_domain)[0]
for domain, m_domain in domains.items()
}
def get_api_domain_routes(m_domain: ModuleType) -> Coroutine:
routes, _ = api_routes(m_domain)
async def wrapped(request, *args, **kwargs):
"""
description: Returns the current API routes dictionary for a specific
domain as a JSON object
"""
return ORJSONResponse(routes)
return wrapped
async def schema_json(request, *args, **kwargs):
"""
description: Returns the current API routes description (OpenAPI v3)

View File

@ -25,7 +25,7 @@ def test_error(application_debug):
r = c.get('/halfapi/error/500')
assert r.status_code == 500
@pytest.skip
@pytest.mark.skip
def test_exception(application_debug):
c = TestClient(application_debug)
try:

View File

@ -16,7 +16,7 @@ def test_schemas_dict_dom():
'dummy_domain':routers})
assert isinstance(schema, dict)
def test_get_api_routes(project_runner, application_debug):
def test_get_api_schema(project_runner, application_debug):
c = TestClient(application_debug)
r = c.get('/')
assert isinstance(c, TestClient)