pub struct OpenApiDocument { /* private fields */ }Expand description
Minimal OpenAPI document metadata builder.
Implementations§
Source§impl OpenApiDocument
impl OpenApiDocument
Sourcepub fn new(title: impl Into<String>, version: impl Into<String>) -> Self
pub fn new(title: impl Into<String>, version: impl Into<String>) -> Self
Creates an OpenAPI document.
Sourcepub fn route(self, route: OpenApiRoute) -> Self
pub fn route(self, route: OpenApiRoute) -> Self
Adds route metadata to the document.
Sourcepub fn try_route(
self,
route: OpenApiRoute,
) -> Result<Self, OpenApiDocumentError>
pub fn try_route( self, route: OpenApiRoute, ) -> Result<Self, OpenApiDocumentError>
Tries to add route metadata to the document.
Sourcepub fn controller_routes(
self,
controller_prefix: &str,
routes: &[RouteMetadata],
) -> Self
pub fn controller_routes( self, controller_prefix: &str, routes: &[RouteMetadata], ) -> Self
Adds generated route metadata under a controller prefix.
Sourcepub fn try_controller_routes(
self,
controller_prefix: &str,
routes: &[RouteMetadata],
) -> Result<Self, OpenApiDocumentError>
pub fn try_controller_routes( self, controller_prefix: &str, routes: &[RouteMetadata], ) -> Result<Self, OpenApiDocumentError>
Tries to add generated route metadata under a controller prefix.
Sourcepub fn schemas_from_route_metadata(self, routes: &[RouteMetadata]) -> Self
pub fn schemas_from_route_metadata(self, routes: &[RouteMetadata]) -> Self
Registers schemas from route OpenAPI metadata callbacks.
Sourcepub fn try_schemas_from_route_metadata(
self,
routes: &[RouteMetadata],
) -> Result<Self, OpenApiDocumentError>
pub fn try_schemas_from_route_metadata( self, routes: &[RouteMetadata], ) -> Result<Self, OpenApiDocumentError>
Tries to register schemas from route OpenAPI metadata callbacks.
Sourcepub fn schema<T>(self) -> Selfwhere
T: ToSchema,
pub fn schema<T>(self) -> Selfwhere
T: ToSchema,
Adds a DTO schema generated by utoipa::ToSchema.
Sourcepub fn try_schema<T>(self) -> Result<Self, OpenApiDocumentError>where
T: ToSchema,
pub fn try_schema<T>(self) -> Result<Self, OpenApiDocumentError>where
T: ToSchema,
Tries to add a DTO schema generated by utoipa::ToSchema.
Sourcepub fn from_route_metadata(
title: impl Into<String>,
version: impl Into<String>,
routes: &[RouteMetadata],
) -> Self
pub fn from_route_metadata( title: impl Into<String>, version: impl Into<String>, routes: &[RouteMetadata], ) -> Self
Creates an OpenAPI document from generated route metadata.
Sourcepub fn try_from_route_metadata(
title: impl Into<String>,
version: impl Into<String>,
routes: &[RouteMetadata],
) -> Result<Self, OpenApiDocumentError>
pub fn try_from_route_metadata( title: impl Into<String>, version: impl Into<String>, routes: &[RouteMetadata], ) -> Result<Self, OpenApiDocumentError>
Tries to create an OpenAPI document from generated route metadata.
Sourcepub fn from_controller_routes(
title: impl Into<String>,
version: impl Into<String>,
controller_prefix: &str,
routes: &[RouteMetadata],
) -> Self
pub fn from_controller_routes( title: impl Into<String>, version: impl Into<String>, controller_prefix: &str, routes: &[RouteMetadata], ) -> Self
Creates an OpenAPI document from a controller prefix and generated route metadata.
Sourcepub fn try_from_controller_routes(
title: impl Into<String>,
version: impl Into<String>,
controller_prefix: &str,
routes: &[RouteMetadata],
) -> Result<Self, OpenApiDocumentError>
pub fn try_from_controller_routes( title: impl Into<String>, version: impl Into<String>, controller_prefix: &str, routes: &[RouteMetadata], ) -> Result<Self, OpenApiDocumentError>
Tries to create an OpenAPI document from controller route metadata.
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Renders the document as JSON.
Sourcepub fn into_router(self) -> Router
pub fn into_router(self) -> Router
Builds an Axum router serving OpenAPI JSON and Swagger UI docs.
Trait Implementations§
Source§impl Clone for OpenApiDocument
impl Clone for OpenApiDocument
Source§fn clone(&self) -> OpenApiDocument
fn clone(&self) -> OpenApiDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more