Open peterschutt opened 6 months ago
I like the approach of allowing the config to take in multiple paths.
I'd prefer reusing routers rather than hardcoding url paths. Something like...
router_1 = Router(path="/")
router_2 = Router(path=f"/some-path")
app = Litestar(
[router_1, router_2],
openapi_config=OpenAPIConfig(routes=[(router_1, "/docs"), (router_2, "/schema")]),
)
The OpenAPIController does accept a router - the idea being you can configure other handlers, middleware, guards etc and we stick the handlers for the openapi UI on there. If we accept a sequence of paths, it also would make sense for us to accept a sequence of routers.
OpenAPIConfig(openapi_router=[Router("/schema"), Router("/some-prefix/schema")])
Summary
We've seen a pattern where an
OpenAPIController
subclass would be registered directly onto the application, and (prior to 2.8) implicitly via theOpenAPIConfig
object, e.g.,:This pattern supports serving the openapi schema routes both under
/schema
and/some-prefix/schema
.We need to consider how this pattern would be implemented in v3 when the OpenAPIController object doesn't exist.
ref: #3337
Basic Example
Drawbacks and Impact
No response
Unresolved questions
No response