Repository: zulip/zulip

Issue:
OpenAPI testsuite reporting endpoint as not in urls.py
While working on the issue #24278, I noticed that adding the openAPI documentation for the endpoint /jwt/fetch_api_key returns an error that the endpoint is not in urls.py while running the backend testsuite. On closer inspection it seems that the testsuite detects urls in v1_api_mobile_patterns and v1_api_and_json_patterns and the above endpoint is not added to either despite having the /api/v1 prefix format. 

I think it makes sense to add the endpoint to the v1_api_and_json_patterns array

![Screenshot from 2023-04-04 09-59-16](https://user-images.githubusercontent.com/72982935/229688107-d3cce4be-2069-45ad-bbb3-3cccb715b5b0.png)

![Screenshot from 2023-04-04 01-07-00](https://user-images.githubusercontent.com/72982935/229687961-8db4c78b-3ec9-4f4b-b6f3-d34df35d4d17.png)




Discussion:
@zulipbot add "bug"
@zulipbot add "good first issue" "help wanted"
@zulipbot claim
Welcome to Zulip, @Riv3tz! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!

Here's some tips to get you off to a good start:

- Join me on the [Zulip developers' server](https://chat.zulip.org), to get help, chat about this issue, and meet the other developers.
- [Unwatch this repository](https://help.github.com/articles/unwatching-repositories/), so that you don't get 100 emails a day.

As you work on this issue, you'll also want to refer to the [Zulip code contribution guide](https://zulip.readthedocs.io/en/latest/contributing/index.html), as well as the rest of the developer documentation on that site.

See you on the other side (that is, the pull request side)!

@tanmaymunjal I've added the endpoint to the v1_api_and_json_patterns array. However, the build is failing since I've not added the docs. Not sure what the correct way to move forward is since you're working on the documentation for the same...
Hey @Riv3tz , I was looking into it and it seems to be the case that they is another testsuite issue which is not able to detect the token parameter, creating issues for me to OpenAPI document the endpoint, will look further into this to make sure it is not a mistake from my side else will need to start an issue on it as well ig

Resolving patch:
diff --git a/zproject/urls.py b/zproject/urls.py
--- a/zproject/urls.py
+++ b/zproject/urls.py
@@ -725,6 +725,9 @@
     # API key - as we consider access to the API key sensitive
     # and just having a logged-in session should be insufficient.
     rest_path("users/me/api_key/regenerate", POST=regenerate_api_key),
+    #  This view accepts a JWT containing an email and returns an API key
+    #  and the details for a single user.
+    path("jwt/fetch_api_key", jwt_fetch_api_key),
 ]
 
 # View for uploading messages from email mirror
@@ -755,11 +758,6 @@
 urls += [path("", include("social_django.urls", namespace="social"))]
 urls += [path("saml/metadata.xml", saml_sp_metadata)]
 
-#  This view accepts a JWT containing an email and returns an API key
-#  and the details for a single user.
-urls += [
-    path("api/v1/jwt/fetch_api_key", jwt_fetch_api_key),
-]
 
 # SCIM2
 


Test patch:
diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.py
--- a/zerver/tests/test_openapi.py
+++ b/zerver/tests/test_openapi.py
@@ -275,6 +275,7 @@ class OpenAPIArgumentsTest(ZulipTestCase):
         "/rest-error-handling",
         # Zulip outgoing webhook payload
         "/zulip-outgoing-webhook",
+        "/jwt/fetch_api_key",
     }
 
     # Endpoints where the documentation is currently failing our