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
//! # 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
//!
//! ```rust,ignore
//! use reinhardt_openapi::OpenApiRouter;
//! use reinhardt_urls::routers::BasicRouter;
//!
//! fn main() {
//! // Create your existing router
//! let router = BasicRouter::new();
//!
//! // Wrap with OpenAPI endpoints
//! let wrapped = OpenApiRouter::wrap(router);
//!
//! // The wrapped router now serves:
//! // - /api/openapi.json (OpenAPI spec)
//! // - /api/docs (Swagger UI)
//! // - /api/redoc (Redoc UI)
//! }
//! ```
//!
//! ## 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 OpenApiRouter;