"""Main module of the Poiesis API.This module creates and configures the connexion app."""importloggingfrompathlibimportPathfromconnexionimportAsyncAppfromconnexion.resolverimportRelativeResolverfrompoiesis.api.constantsimportget_poiesis_api_constantsfrompoiesis.api.exceptionsimport(APIException,handle_api_exception,handle_unexpected_exception,)frompoiesis.constantsimportget_poiesis_constantsconstants=get_poiesis_constants()api_constant=get_poiesis_api_constants()
[docs]defcreate_app()->AsyncApp:"""Create the connexion app. Returns: AsyncApp: The connexion app. """openapi_spec_directory=Path(__file__).parent/"tes"/"spec"logging.basicConfig(level=getattr(logging,constants.LOG_LEVEL))app=AsyncApp(__name__,specification_dir=openapi_spec_directory,)app.add_api(f"{api_constant.SPEC_GIT_HASH}.openapi.yaml",resolver=RelativeResolver("poiesis.api.api_handlers"),validate_responses=True,)app.add_error_handler(Exception,handle_unexpected_exception)app.add_error_handler(APIException,handle_api_exception)returnapp