code: def validate_request_method_to_operation(request_method, path_definition):
      
      try:
          operation_definition = path_definition[request_method]
      except KeyError:
          allowed_methods = set(REQUEST_METHODS).intersection(path_definition.keys())
          raise ValidationError(
              MESSAGES['request']['invalid_method'].format(
                  request_method, allowed_methods,
              ),
          )
      return operation_definition
docs: Given a request method, validate that the request method is valid for the
      api path.
  
      If so, return the operation definition related to this request method.