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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! # openapi-ui
//!
//](https://github.com/kimolalekan/openapi-ui/actions)
//! [](https://crates.io/crates/openapi-ui)
//! [](https://docs.rs/openapi-ui)
//! [](https://opensource.org/licenses/MIT)
//!
//! `openapi-ui` is a library for generating custom documentation UIs from OpenAPI specifications.
//!
//! It takes an OpenAPI JSON string and produces a self-contained HTML file with a responsive UI.
//!
//! **[🌐 Live Demo](https://kimolalekan.github.io/openapi-ui)**
//!
//! ## Web Framework Examples
//!
//! - [Axum](https://github.com/kimolalekan/openapi-ui/blob/main/examples/axum.rs)
//! - [Actix-web](https://github.com/kimolalekan/openapi-ui/blob/main/examples/actix.rs)
//! - [Rocket](https://github.com/kimolalekan/openapi-ui/blob/main/examples/rocket.rs)
//! - [Warp](https://github.com/kimolalekan/openapi-ui/blob/main/examples/warp.rs)
//! - [Poem](https://github.com/kimolalekan/openapi-ui/blob/main/examples/poem.rs)
//! - [Salvo](https://github.com/kimolalekan/openapi-ui/blob/main/examples/salvo.rs)
//!
//! ## Generating OpenAPI JSON with utoipa
//!
//! The OpenAPI JSON can be generated using [utoipa](https://crates.io/crates/utoipa):
//!
//! ```rust,ignore
//! use utoipa::OpenApi;
//! use openapi_ui::{generate_docs, ThemeMode};
//!
//! #[derive(OpenApi)]
//! #[openapi(paths(get_users), components(schemas(User)))]
//! struct ApiDoc;
//!
//! let openapi_json = ApiDoc::openapi().to_pretty_json().unwrap();
//! let html = generate_docs(&openapi_json, ThemeMode::System, None, None).unwrap();
//! ```
//!
//! ## Usage
//!
//! ```rust
//! use openapi_ui::{generate_docs, ThemeMode};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Use the sample Petstore API spec (or your own OpenAPI JSON)
//! let openapi_json = include_str!("sample_data.json");
//!
//! // Generate HTML with system theme and default favicon
//! let html = generate_docs(openapi_json, ThemeMode::System, None, None)?;
//!
//! std::fs::write("docs.html", html)?;
//! Ok(())
//! }
//! ```
//!
//! For more control, use the [`UIBuilder`]:
//!
//! ```rust
//! use openapi_ui::{UIBuilder, OpenAPISpec};
//! use std::fs;
//!
//! # fn run() -> Result<(), Box<dyn std::error::Error>> {
//! // Load your OpenAPI spec from file
//! let spec_json = fs::read_to_string("openapi.json")?;
//! let spec: OpenAPISpec = serde_json::from_str(&spec_json)?;
//!
//! let html = UIBuilder::new(spec)
//! .theme("dark")
//! .base_url("https://api.example.com")
//! .build();
//!
//! fs::write("docs.html", html)?;
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;