context.py 765B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. import json
  3. import typing
  4. from http import HTTPStatus
  5. import bottle
  6. from hapic.exception import OutputValidationException
  7. # from hapic.hapic import _default_global_error_schema
  8. from hapic.processor import RequestParameters, ProcessValidationError
  9. class ContextInterface(object):
  10. def get_request_parameters(self, *args, **kwargs) -> RequestParameters:
  11. raise NotImplementedError()
  12. def get_response(
  13. self,
  14. response: dict,
  15. http_code: int,
  16. ) -> typing.Any:
  17. raise NotImplementedError()
  18. def get_validation_error_response(
  19. self,
  20. error: ProcessValidationError,
  21. http_code: HTTPStatus=HTTPStatus.BAD_REQUEST,
  22. ) -> typing.Any:
  23. raise NotImplementedError()