# Path: lepo/apidef/operation/base.py
# class Operation:
#     parameter_class = None  # This should never be used
# 
#     def __init__(self, api, path, method, data):
#         """
#         :type api: lepo.apidef.doc.APIDefinition
#         :type path: lepo.apidef.path.Path
#         :type method: str
#         :type data: dict
#         """
#         self.api = api
#         self.path = path
#         self.method = method
#         self.data = data
# 
#     @property
#     def id(self):
#         return self.data['operationId']
# 
#     @cached_property
#     def parameters(self):
#         """
#         Combined path-level and operation-level parameters.
# 
#         Any $refs are resolved here.
# 
#         Note that this implementation differs from the spec in that we only use
#         the _name_ of a parameter to consider its uniqueness, not the name and location.
# 
#         This is because we end up passing parameters to the handler by name anyway,
#         so any duplicate names, even if they had different locations, would be horribly mangled.
# 
#         :rtype: list[Parameter]
#         """
#         return list(self.get_parameter_dict().values())
# 
#     def get_parameter_dict(self):
#         parameters = OrderedDict()
#         for parameter in self._get_regular_parameters():
#             parameters[parameter.name] = parameter
#         return parameters
# 
#     def _get_regular_parameters(self):
#         for source in (
#             self.path.mapping.get('parameters', ()),
#             self.data.get('parameters', {}),
#         ):
#             source = maybe_resolve(source, self.api.resolve_reference)
#             for parameter in source:
#                 parameter_data = maybe_resolve(parameter, self.api.resolve_reference)
#                 parameter = self.parameter_class(data=parameter_data, operation=self, api=self.api)
#                 yield parameter
# 
#     def _get_overridable(self, key, default=None):
#         # TODO: This probes a little too deeply into the specifics of these objects, I think...
#         for obj in (
#             self.data,
#             self.path.mapping,
#             self.api.doc,
#         ):
#             if key in obj:
#                 return obj[key]
#         return default
# 
# Path: lepo/apidef/parameter/swagger.py
# class Swagger2Parameter(Swagger2BaseParameter, BaseTopParameter):
# 
#     def get_value(self, request, view_kwargs):
#         if self.location == 'path':
#             return view_kwargs.get(self.name, NO_VALUE)
# 
#         if self.location == 'header':
#             meta_key = f"HTTP_{self.name.upper().replace('-', '_')}"
#             return request.META.get(meta_key, NO_VALUE)
# 
#         if self.location == 'body':
#             return self.read_body(request)
# 
#         if self.location == 'formData' and self.type == 'file':
#             return request.FILES.get(self.name, NO_VALUE)
# 
#         if self.location in ('query', 'formData'):
#             source = (request.POST if self.location == 'formData' else request.GET)
# 
#             if self.name not in source:
#                 return NO_VALUE
# 
#             if self.type == 'array' and self.collection_format == 'multi':
#                 return source.getlist(self.name)
#             else:
#                 return source[self.name]
# 
#         return super().get_value(request, view_kwargs)  # pragma: no cover
# 
#     def read_body(self, request):
#         consumes = request.api_info.operation.consumes
#         if request.content_type not in consumes:
#             raise InvalidBodyFormat(f'Content-type {request.content_type} is not supported ({consumes!r} are)')
# 
#         return read_body(request, None)


from django.utils.functional import cached_property
from lepo.apidef.operation.base import Operation
from lepo.apidef.parameter.swagger import Swagger2Parameter



class Swagger2Operation(Operation):
    parameter_class = Swagger2Parameter

    @cached_property
    def consumes(self):

# Path: lepo/apidef/operation/base.py
# class Operation:
#     parameter_class = None  # This should never be used
# 
#     def __init__(self, api, path, method, data):
#         """
#         :type api: lepo.apidef.doc.APIDefinition
#         :type path: lepo.apidef.path.Path
#         :type method: str
#         :type data: dict
#         """
#         self.api = api
#         self.path = path
#         self.method = method
#         self.data = data
# 
#     @property
#     def id(self):
#         return self.data['operationId']
# 
#     @cached_property
#     def parameters(self):
#         """
#         Combined path-level and operation-level parameters.
# 
#         Any $refs are resolved here.
# 
#         Note that this implementation differs from the spec in that we only use
#         the _name_ of a parameter to consider its uniqueness, not the name and location.
# 
#         This is because we end up passing parameters to the handler by name anyway,
#         so any duplicate names, even if they had different locations, would be horribly mangled.
# 
#         :rtype: list[Parameter]
#         """
#         return list(self.get_parameter_dict().values())
# 
#     def get_parameter_dict(self):
#         parameters = OrderedDict()
#         for parameter in self._get_regular_parameters():
#             parameters[parameter.name] = parameter
#         return parameters
# 
#     def _get_regular_parameters(self):
#         for source in (
#             self.path.mapping.get('parameters', ()),
#             self.data.get('parameters', {}),
#         ):
#             source = maybe_resolve(source, self.api.resolve_reference)
#             for parameter in source:
#                 parameter_data = maybe_resolve(parameter, self.api.resolve_reference)
#                 parameter = self.parameter_class(data=parameter_data, operation=self, api=self.api)
#                 yield parameter
# 
#     def _get_overridable(self, key, default=None):
#         # TODO: This probes a little too deeply into the specifics of these objects, I think...
#         for obj in (
#             self.data,
#             self.path.mapping,
#             self.api.doc,
#         ):
#             if key in obj:
#                 return obj[key]
#         return default
# 
# Path: lepo/apidef/parameter/swagger.py
# class Swagger2Parameter(Swagger2BaseParameter, BaseTopParameter):
# 
#     def get_value(self, request, view_kwargs):
#         if self.location == 'path':
#             return view_kwargs.get(self.name, NO_VALUE)
# 
#         if self.location == 'header':
#             meta_key = f"HTTP_{self.name.upper().replace('-', '_')}"
#             return request.META.get(meta_key, NO_VALUE)
# 
#         if self.location == 'body':
#             return self.read_body(request)
# 
#         if self.location == 'formData' and self.type == 'file':
#             return request.FILES.get(self.name, NO_VALUE)
# 
#         if self.location in ('query', 'formData'):
#             source = (request.POST if self.location == 'formData' else request.GET)
# 
#             if self.name not in source:
#                 return NO_VALUE
# 
#             if self.type == 'array' and self.collection_format == 'multi':
#                 return source.getlist(self.name)
#             else:
#                 return source[self.name]
# 
#         return super().get_value(request, view_kwargs)  # pragma: no cover
# 
#     def read_body(self, request):
#         consumes = request.api_info.operation.consumes
#         if request.content_type not in consumes:
#             raise InvalidBodyFormat(f'Content-type {request.content_type} is not supported ({consumes!r} are)')
# 
#         return read_body(request, None)


# Path: lepo/apidef/operation/swagger.py
from django.utils.functional import cached_property
from lepo.apidef.operation.base import Operation
from lepo.apidef.parameter.swagger import Swagger2Parameter




class Swagger2Operation(Operation):
    parameter_class = Swagger2Parameter

    @cached_property
    def consumes(self):

        value = self._get_overridable('consumes', [])