pub trait OpenApiRouterExt<S>: Sized {
// Required methods
fn layer_documented<L>(self, layer: L) -> Self
where L: Layer<Route> + DocumentedLayer + Clone + Send + Sync + 'static,
L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static;
fn tag_all(self, tag: impl Into<String>) -> Self;
}Expand description
Adds OpenApiRouterExt::layer_documented and
OpenApiRouterExt::tag_all to OpenApiRouter. Implemented
for every state type the underlying router supports.
Required Methods§
Sourcefn layer_documented<L>(self, layer: L) -> Selfwhere
L: Layer<Route> + DocumentedLayer + Clone + Send + Sync + 'static,
L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
fn layer_documented<L>(self, layer: L) -> Selfwhere
L: Layer<Route> + DocumentedLayer + Clone + Send + Sync + 'static,
L::Service: Service<Request> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
Apply layer exactly like
OpenApiRouter::layer, and stamp
layer.contribution() onto every operation currently
present in the router. Routes added after this call (via
further merge,
nest, or
route) are unaffected — same
semantic as axum::Router::layer.
Convention: build the router up with all routes first, then
call layer_documented last. The
layer_documented_only_affects_routes_present_before_call
regression test pins this behavior in CI.
Sourcefn tag_all(self, tag: impl Into<String>) -> Self
fn tag_all(self, tag: impl Into<String>) -> Self
Stamp tag onto every operation currently present in the
router. Same snapshot semantic as Self::layer_documented —
routes added after this call are unaffected.
Typical use is inside a module’s routes() function so the
tag is declared once per module rather than on every handler:
pub fn routes() -> OpenApiRouter<AppState> {
OpenApiRouter::new()
.routes(routes!(list_models, get_model))
.tag_all("Models")
}Handler-level tags (from tag = "..." or tags(...) in the
macro) merge with the router-level tag — they do not replace
each other. Duplicate tags are deduplicated.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.