1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! # Reinhardt OpenAPI Router
//!
//! OpenAPI router wrapper that automatically adds documentation endpoints.
//!
//! ## Overview
//!
//! This crate provides a router wrapper that intercepts requests to OpenAPI
//! documentation paths and serves them from memory, delegating all other
//! requests to the wrapped handler.
//!
//! ## Example
//!
//! Apply `OpenApiRouter::wrap` inside the `#[routes]` function to expose OpenAPI
//! documentation alongside your application routes:
//!
//! ```rust,ignore
//! use reinhardt::routes;
//! use reinhardt_openapi::OpenApiRouter;
//! use reinhardt_urls::routers::UnifiedRouter;
//!
//! #[routes]
//! pub fn routes() -> OpenApiRouter<UnifiedRouter> {
//! let router = UnifiedRouter::new()
//! // Mount your application routes here
//! .mount("/", some_app::urls::routes());
//!
//! // Wrap with OpenAPI endpoints — served at:
//! // - /api/openapi.json (OpenAPI spec)
//! // - /api/docs (Swagger UI)
//! // - /api/redoc (Redoc UI)
//! OpenApiRouter::wrap(router).expect("Failed to wrap router with OpenAPI")
//! }
//! ```
//!
//! ## Separation Rationale
//!
//! This crate exists separately from `reinhardt-rest` to break a circular
//! dependency chain:
//!
//! ```text
//! reinhardt-urls → reinhardt-views → reinhardt-rest → reinhardt-urls (cycle!)
//! ```
//!
//! By placing `OpenApiRouter` in its own crate that depends on both
//! `reinhardt-urls` and `reinhardt-rest`, we avoid this cycle:
//!
//! ```text
//! reinhardt-openapi
//! ├── reinhardt-urls (Route, Router trait)
//! └── reinhardt-rest (generate_openapi_schema, SwaggerUI, RedocUI)
//! ```
pub use SchemaError;
pub use AuthGuard;
pub use OpenApiRouter;