Friskes / drf-spectacular-websocket

Extend websocket schema decorator for Django Channels
MIT License
4 stars 2 forks source link

Support nested URLRouters in path definitions #4

Closed HMaker closed 3 weeks ago

HMaker commented 4 weeks ago

The library does not support nested URLRouters, it expects all path() declarations to end with a Consumer. The following breaks it:

application = ProtocolTypeRouter({
    "websocket": URLRouter([
        path('my/app/', URLRouter([ # <== nested URLRouter, drf-spectacular-websocket expects a Consumer
            path('consumer1/', MyConsumer1.as_asgi()),
            path('consumer2/', MyConsumer2.as_asgi()),
            path('consumer3/', MyConsumer3.as_asgi()),
        ])),
    ])
})

Nested URLRouters allow one to easily change the base URL of a set of endpointss (e.g. change per Django application). It makes namespaces way easier to manage.

Friskes commented 3 weeks ago

I'll think about what I can do about it

Friskes commented 3 weeks ago

Added support for nested routes https://github.com/Friskes/drf-spectacular-websocket/releases/tag/v1.2.8