pub struct OpenApiBuilder { /* private fields */ }Expand description
OpenAPI document builder.
Implementations§
Source§impl OpenApiBuilder
impl OpenApiBuilder
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Add a description.
Sourcepub fn registry(&mut self) -> SchemaRegistryMut<'_>
pub fn registry(&mut self) -> SchemaRegistryMut<'_>
Access the component schema registry for in-place registration.
Sourcepub fn add_route(&mut self, route: &Route)
pub fn add_route(&mut self, route: &Route)
Add a metadata-rich route (from fastapi-router) as an OpenAPI operation.
This is a convenience bridge used by integration tests and by higher-level crates.
Sourcepub fn add_routes<'a, I>(&mut self, routes: I)where
I: IntoIterator<Item = &'a Route>,
pub fn add_routes<'a, I>(&mut self, routes: I)where
I: IntoIterator<Item = &'a Route>,
Add multiple routes.
Sourcepub fn operation(
self,
method: &str,
path: impl Into<String>,
operation: Operation,
) -> Self
pub fn operation( self, method: &str, path: impl Into<String>, operation: Operation, ) -> Self
Add a path operation (GET, POST, etc.).
This is the primary method for registering routes with OpenAPI.
§Example
ⓘ
let builder = OpenApiBuilder::new("My API", "1.0.0")
.operation("GET", "/users", Operation {
operation_id: Some("get_users".to_string()),
summary: Some("List all users".to_string()),
responses: HashMap::from([
("200".to_string(), Response {
description: "Success".to_string(),
content: HashMap::new(),
})
]),
..Default::default()
});Sourcepub fn get(
self,
path: impl Into<String>,
operation_id: impl Into<String>,
) -> Self
pub fn get( self, path: impl Into<String>, operation_id: impl Into<String>, ) -> Self
Add a simple GET endpoint with default 200 response.
Sourcepub fn post(
self,
path: impl Into<String>,
operation_id: impl Into<String>,
) -> Self
pub fn post( self, path: impl Into<String>, operation_id: impl Into<String>, ) -> Self
Add a simple POST endpoint with default 200 response.
Sourcepub fn put(
self,
path: impl Into<String>,
operation_id: impl Into<String>,
) -> Self
pub fn put( self, path: impl Into<String>, operation_id: impl Into<String>, ) -> Self
Add a simple PUT endpoint with default 200 response.
Sourcepub fn delete(
self,
path: impl Into<String>,
operation_id: impl Into<String>,
) -> Self
pub fn delete( self, path: impl Into<String>, operation_id: impl Into<String>, ) -> Self
Add a simple DELETE endpoint with default 200 response.
Auto Trait Implementations§
impl Freeze for OpenApiBuilder
impl RefUnwindSafe for OpenApiBuilder
impl Send for OpenApiBuilder
impl Sync for OpenApiBuilder
impl Unpin for OpenApiBuilder
impl UnsafeUnpin for OpenApiBuilder
impl UnwindSafe for OpenApiBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more