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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//! # Reinhardt OpenAPI
//!
//! OpenAPI 3.0 schema generation for Reinhardt REST APIs.
//!
//! ## Overview
//!
//! This crate provides automatic OpenAPI documentation generation for Reinhardt
//! REST APIs, including schema derivation, Swagger UI integration, and ViewSet
//! inspection.
//!
//! ## Features
//!
//! - **OpenAPI 3.0**: Full OpenAPI 3.0 specification support
//! - **Auto-generation**: Automatic schema generation from ViewSets
//! - **Customization**: Override and extend generated schemas
//! - **Swagger UI**: Built-in Swagger UI and ReDoc integration
//! - **YAML/JSON**: Export schemas in both formats
//! - **Schema Registry**: Centralized schema management with `$ref` references
//! - **Enum Support**: Tagged, adjacently tagged, and untagged enum handling
//! - **Serde Integration**: Support for `#[serde(rename)]`, `#[serde(skip)]`, and more
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use reinhardt_rest::openapi::{SchemaGenerator, OpenApiSchema};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Generate schema from ViewSets
//! let generator = SchemaGenerator::new()
//! .title("My API")
//! .version("1.0.0")
//! .description("API documentation");
//!
//! let schema = generator.generate()?;
//! let json = schema.to_json()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Schema Derive Macro
//!
//! The `#[derive(Schema)]` macro generates OpenAPI schema definitions from Rust types.
//!
//! ### Basic Usage
//!
//! ```rust,ignore
//! use reinhardt_rest::openapi::Schema;
//!
//! #[derive(Schema)]
//! struct User {
//! id: i64,
//! username: String,
//! email: String,
//! #[schema(example = "true")]
//! is_active: bool,
//! }
//! ```
//!
//! ### Schema Attributes
//!
//! Field-level attributes:
//!
//! - `#[schema(example = "...")]`: Provide example value for documentation
//! - `#[schema(skip)]`: Exclude field from schema
//! - `#[schema(rename = "...")]`: Rename field in schema
//! - `#[schema(description = "...")]`: Add field description
//! - `#[schema(nullable)]`: Mark field as nullable
//! - `#[schema(format = "...")]`: Specify format (e.g., "email", "uri", "date-time")
//!
//! Container-level attributes:
//!
//! - `#[schema(rename_all = "...")]`: Apply case transformation (camelCase, snake_case, etc.)
//!
//! ### Serde Integration
//!
//! The Schema derive macro automatically respects serde attributes:
//!
//! ```rust,ignore
//! use serde::{Deserialize, Serialize};
//! use reinhardt_rest::openapi::Schema;
//!
//! #[derive(Serialize, Deserialize, Schema)]
//! #[serde(rename_all = "camelCase")]
//! struct UserResponse {
//! user_id: i64, // Becomes "userId" in schema
//! #[serde(skip)]
//! internal_field: String, // Excluded from schema
//! #[serde(rename = "mail")]
//! email: String, // Becomes "mail" in schema
//! }
//! ```
//!
//! ### Enum Schemas
//!
//! Support for various enum representations:
//!
//! ```rust,ignore
//! use reinhardt_rest::openapi::Schema;
//!
//! // Simple enum (string schema)
//! #[derive(Schema)]
//! enum Status {
//! Active,
//! Inactive,
//! Pending,
//! }
//!
//! // Tagged enum (object schema with discriminator)
//! #[derive(Schema)]
//! #[serde(tag = "type")]
//! enum Event {
//! Created { id: i64 },
//! Updated { id: i64, changes: Vec<String> },
//! Deleted { id: i64 },
//! }
//! ```
//!
//! ## Schema Registry
//!
//! Manage and reference schemas centrally:
//!
//! ```rust,ignore
//! use reinhardt_rest::openapi::SchemaRegistry;
//!
//! let mut registry = SchemaRegistry::new();
//!
//! // Register a schema
//! registry.register::<User>();
//!
//! // Get reference to schema
//! let user_ref = registry.get_ref::<User>(); // Returns "#/components/schemas/User"
//! ```
//!
//! ## Swagger UI Integration
//!
//! ```rust,ignore
//! use reinhardt_rest::openapi::{SwaggerUI, RedocUI};
//!
//! // Swagger UI endpoint
//! let swagger = SwaggerUI::new("/api/openapi.json")
//! .path("/docs")
//! .title("API Documentation");
//!
//! // ReDoc endpoint
//! let redoc = RedocUI::new("/api/openapi.json")
//! .path("/redoc");
//! ```
// Allow module_inception: Re-exporting openapi submodule from openapi.rs
// is intentional for compatibility with existing imports (`reinhardt_rest::openapi::OpenAPI`)
use Error;
pub use ;
// Re-export deprecated OpenApiConfig for backward compatibility
pub use OpenApiConfig;
pub use EndpointInspector;
pub use generate_openapi_schema;
pub use ;
pub use SchemaGenerator;
pub use ;
pub use ;
pub use SchemaRegistry;
pub use Schema;
pub use SchemaRegistration;
pub use ;
pub use ;
pub use Number;
// Re-export utoipa and inventory for macro-generated code
pub use inventory;
pub use utoipa;
/// Errors that can occur during OpenAPI schema operations.
/// Result type for OpenAPI schema operations.
pub type SchemaResult<T> = Result;