[schema] fixes non-str keys in ORJSONResponse
This commit is contained in:
parent
7d6bc2c181
commit
360f59b6ba
@ -47,7 +47,8 @@ class UnauthorizedResponse(Response):
|
||||
|
||||
class ORJSONResponse(JSONResponse):
|
||||
def render(self, content: typ.Any) -> bytes:
|
||||
return orjson.dumps(content)
|
||||
return orjson.dumps(content,
|
||||
option=orjson.OPT_NON_STR_KEYS)
|
||||
|
||||
|
||||
class HJSONResponse(ORJSONResponse):
|
||||
|
@ -5,19 +5,12 @@ from .routes import gen_starlette_routes, api_routes
|
||||
from .responses import *
|
||||
from starlette.schemas import SchemaGenerator
|
||||
from starlette.routing import Router
|
||||
schemas = SchemaGenerator(
|
||||
SCHEMAS = SchemaGenerator(
|
||||
{"openapi": "3.0.0", "info": {"title": "HalfAPI", "version": "1.0"}}
|
||||
)
|
||||
|
||||
|
||||
async def get_api_routes(request, *args, **kwargs):
|
||||
"""
|
||||
responses:
|
||||
200:
|
||||
description: Returns the current API routes description (HalfAPI 0.2.1)
|
||||
as a JSON object
|
||||
example:
|
||||
{
|
||||
example: > {
|
||||
"dummy_domain": {
|
||||
"/abc/alphabet/organigramme": {
|
||||
"fqtn": null,
|
||||
@ -37,6 +30,14 @@ async def get_api_routes(request, *args, **kwargs):
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
async def get_api_routes(request, *args, **kwargs):
|
||||
"""
|
||||
responses:
|
||||
200:
|
||||
description: Returns the current API routes description (HalfAPI 0.2.1)
|
||||
as a JSON object
|
||||
"""
|
||||
#TODO: LADOC
|
||||
d_api = {}
|
||||
for domain, m_domain in DOMAINSDICT.items():
|
||||
@ -52,7 +53,7 @@ async def schema_json(request, *args, **kwargs):
|
||||
as a JSON object
|
||||
"""
|
||||
return ORJSONResponse(
|
||||
schemas.get_schema(routes=request.app.routes))
|
||||
SCHEMAS.get_schema(routes=request.app.routes))
|
||||
|
||||
|
||||
def schema_dict_dom(m_domain: ModuleType) -> Dict:
|
||||
@ -71,4 +72,4 @@ def schema_dict_dom(m_domain: ModuleType) -> Dict:
|
||||
"""
|
||||
routes = [
|
||||
elt for elt in gen_starlette_routes(m_domain) ]
|
||||
return schemas.get_schema(routes=routes)
|
||||
return SCHEMAS.get_schema(routes=routes)
|
||||
|
Loading…
Reference in New Issue
Block a user