|
| 1 | +"""OpenAPI core wrappers module""" |
| 2 | +import warnings |
| 3 | + |
| 4 | +from six.moves.urllib.parse import urljoin |
| 5 | + |
| 6 | + |
| 7 | +class BaseOpenAPIRequest(object): |
| 8 | + |
| 9 | + host_url = NotImplemented |
| 10 | + path = NotImplemented |
| 11 | + path_pattern = NotImplemented |
| 12 | + method = NotImplemented |
| 13 | + |
| 14 | + parameters = NotImplemented |
| 15 | + body = NotImplemented |
| 16 | + |
| 17 | + mimetype = NotImplemented |
| 18 | + |
| 19 | + @property |
| 20 | + def full_url_pattern(self): |
| 21 | + return urljoin(self.host_url, self.path_pattern) |
| 22 | + |
| 23 | + def get_body(self, spec): |
| 24 | + warnings.warn( |
| 25 | + "`get_body` method is deprecated. " |
| 26 | + "Use RequestValidator instead.", |
| 27 | + DeprecationWarning, |
| 28 | + ) |
| 29 | + # backward compatibility |
| 30 | + from openapi_core.shortcuts import validate_body |
| 31 | + return validate_body(spec, self, wrapper_class=None) |
| 32 | + |
| 33 | + def get_parameters(self, spec): |
| 34 | + warnings.warn( |
| 35 | + "`get_parameters` method is deprecated. " |
| 36 | + "Use RequestValidator instead.", |
| 37 | + DeprecationWarning, |
| 38 | + ) |
| 39 | + # backward compatibility |
| 40 | + from openapi_core.shortcuts import validate_parameters |
| 41 | + return validate_parameters(spec, self, wrapper_class=None) |
| 42 | + |
| 43 | + |
| 44 | +class BaseOpenAPIResponse(object): |
| 45 | + |
| 46 | + body = NotImplemented |
| 47 | + status_code = NotImplemented |
| 48 | + |
| 49 | + mimetype = NotImplemented |
0 commit comments