title: Custom Grouping on OpenAPI endpoints with Django Rest Framework
body: <p>I have a Django project and I am using Django REST framework. I am using <a href="https://github.com/tfranzel/drf-spectacular" rel="noreferrer">drf-spectacular</a>
  for OpenAPI representation, but I think my problem is not tied to this package, it's seems a more generic OpenAPI thing to me (but not 100% sure if I am right to this).</p>
  <p>Assume that I have a URL structure like this:</p>
  <pre><code>urlpatterns = [
      path('admin/', admin.site.urls),
      path('api/', include([
          path('v1/', include([
              path('auth/', include('rest_framework.urls', namespace='rest_framework')),
              path('jwt-auth/token/obtain', CustomTokenObtainPairView.as_view(), name='token_obtain_pair'),
              path('jwt-auth/token/refresh', CustomTokenRefreshView.as_view(), name='token_refresh'),
              path('home/', include(&quot;home.urls&quot;))
          ]))
      ])),
  
      # OpenAPI endpoints
      path('swagger/', SpectacularSwaggerView.as_view(url_name='schema-swagger-json'), name='schema-swagger-ui'),
      path('swagger.yaml/', SpectacularAPIView.as_view(), name='schema-swagger-yaml'),
      path('swagger.json/', SpectacularJSONAPIView.as_view(), name='schema-swagger-json'),
      path('redoc/', SpectacularRedocView.as_view(url_name='schema-swagger-yaml'), name='schema-redoc'),
  ]
  </code></pre>
  <p>In the corresponding swagger UI view, I get all endpoints grouped under <strong>api</strong> endpoint, e.g.:
  <a href="https://i.stack.imgur.com/EXPs7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EXPs7.png" alt="enter image description here" /></a></p>
  <p>If add more endpoints under v1, all go under the <strong>api</strong> endpoint.</p>
  <p>What I want to achieve is, to have the endpoints in Swagger grouped differently, e.g. by app. So I'd have <strong>home</strong>, <strong>jwt</strong>, <strong>another_endpoint</strong>, instead of just <strong>api</strong>, so it will be easier to navigate in Swagger (when I add more endpoints, with the current method it's just showing a massive list of URLs, not very user friendly).</p>
  <p>I've read that those groups are being extracted from the first path of a URL, in my case this is <strong>api</strong>, so if I change the URL structure, I could achieve what I need.</p>
  <p>But isn't there another way of doing this? I want to keep my URL structure, and customize how I display this with OpenAPI, so in the end I have a swagger that groups the endpoints by app, so it's easier to navigate and find what you are looking for.</p>