1pub mod doc;
41#[cfg(feature = "swagger-ui-embedded")]
42pub mod embedded;
43pub use silent_openapi_macros::endpoint;
44pub mod error;
45pub mod handler;
46pub mod middleware;
47pub mod redoc;
48pub mod route;
49pub mod schema;
50pub mod ui_html;
51
52pub use error::{OpenApiError, Result};
54pub use handler::SwaggerUiHandler;
55pub use middleware::SwaggerUiMiddleware;
56pub use redoc::{ReDocHandler, ReDocMiddleware};
57pub use route::{DocumentedRoute, RouteDocumentation, RouteOpenApiExt};
58pub use schema::OpenApiDoc;
59
60pub use utoipa::{
62 IntoParams, IntoResponses, ToResponse, ToSchema,
63 openapi::{self, OpenApi},
64};
65
66pub const VERSION: &str = env!("CARGO_PKG_VERSION");
68
69#[derive(Clone)]
71pub struct SwaggerUiOptions {
72 pub try_it_out_enabled: bool,
73}
74
75impl Default for SwaggerUiOptions {
76 fn default() -> Self {
77 Self {
78 try_it_out_enabled: true,
79 }
80 }
81}
82
83pub fn create_openapi_doc(
103 title: &str,
104 version: &str,
105 description: &str,
106) -> utoipa::openapi::OpenApi {
107 use utoipa::openapi::*;
108
109 OpenApiBuilder::new()
110 .info(
111 InfoBuilder::new()
112 .title(title)
113 .version(version)
114 .description(Some(description))
115 .build(),
116 )
117 .build()
118}
119
120#[cfg(test)]
121mod tests {
122 use super::*;
123
124 #[test]
125 fn test_version() {
126 #[allow(clippy::const_is_empty)]
127 {
128 assert!(!VERSION.is_empty());
129 }
130 }
131
132 #[test]
133 fn test_create_openapi_doc() {
134 let doc = create_openapi_doc("Test API", "1.0.0", "A test API");
135 assert_eq!(doc.info.title, "Test API");
136 assert_eq!(doc.info.version, "1.0.0");
137 assert_eq!(doc.info.description, Some("A test API".to_string()));
138 }
139}