# -*- coding: utf-8 -*- import typing from http import HTTPStatus from hapic.processor import RequestParameters from hapic.processor import ProcessValidationError if typing.TYPE_CHECKING: from hapic.decorator import DecoratedController class RouteRepresentation(object): def __init__( self, rule: str, method: str, original_route_object: typing.Any=None, ) -> None: self.rule = rule self.method = method self.original_route_object = original_route_object class ContextInterface(object): def get_request_parameters(self, *args, **kwargs) -> RequestParameters: raise NotImplementedError() def get_response( self, response: dict, http_code: int, ) -> typing.Any: raise NotImplementedError() def get_validation_error_response( self, error: ProcessValidationError, http_code: HTTPStatus=HTTPStatus.BAD_REQUEST, ) -> typing.Any: raise NotImplementedError() def find_route( self, decorated_controller: 'DecoratedController', ) -> RouteRepresentation: raise NotImplementedError() def get_swagger_path(self, contextualised_rule: str) -> str: """ Return OpenAPI path with context path :param contextualised_rule: path of original context :return: OpenAPI path """ raise NotImplementedError() def by_pass_output_wrapping(self, response: typing.Any) -> bool: """ Return True if the controller response is in final state: we do not have to apply output wrapper on it. :param response: the original response of controller :return: """ raise NotImplementedError()