title: AssertionError: expected view func if endpoint is not provided - python
body: <p>trying to decorate end point with <strong>requires_fields</strong> decorator. this is the implementation.</p>
  <pre><code>import functools
  from flask import request, jsonify
  
  def requires_fields(fields):
      required_fields = set(fields)
  
      def wrapper(func):
          @functools.wraps(func)
          def decorated(*args, **kwargs):
              current_fields = set(request.get_json().keys())
              missing_fields = required_fields - current_fields
              if missing_fields:
                  return jsonify({'error': 'missing fields', 'fields': list(missing_fields)}), 400  # Bad Request
              resp = func(*args, **kwargs)
              return resp
      return wrapper
  
  @app.route('/is_registered', methods=['POST'])
  @requires_fields(['mobile'])
  def is_registered():
      _json = request.get_json()
      keys = _json.keys()
      customer = Customer()
      registered = False
  
      response = verify_required_params(['mobile'], keys)
      if response:
          return response
  
      _mobile = _json['mobile']
  
      validated = validate_mobile(_mobile)
      cust, response_code = customer.get(_mobile)
      if cust is not None and cust['id']:
          registered = True
  
      if not validated:
          response = responses.get(MOBILE_NUMBER_NOT_VALID)
          return jsonify(response)
  
      if not registered:
          response = responses.get(MOBILE_NUMBER_NOT_REGISTERED)
          return jsonify(response)
  
      response = responses.get(MOBILE_NUMBER_REGISTERED)
      return jsonify(response)
  </code></pre>
  <p>It is giving me this error:</p>
  <pre><code>assert view_func is not None, &quot;expected view func if endpoint is not provided.&quot;
  AssertionError: expected view func if endpoint is not provided.
  </code></pre>
  <p>What is causing this issue? How can we fix this?</p>