pub struct OpenApiDoc { /* private fields */ }Expand description
OpenAPI文档构建器
提供便捷的方法来构建和管理OpenAPI文档。
Implementations§
Source§impl OpenApiDoc
impl OpenApiDoc
Sourcepub fn from_openapi(openapi: OpenApi) -> Self
pub fn from_openapi(openapi: OpenApi) -> Self
由现有的 OpenApi 对象创建文档包装
Sourcepub fn description<S: Into<String>>(self, description: S) -> Self
pub fn description<S: Into<String>>(self, description: S) -> Self
设置API描述
Sourcepub fn add_server(self, url: &str, description: Option<&str>) -> Self
pub fn add_server(self, url: &str, description: Option<&str>) -> Self
Sourcepub fn add_placeholder_schemas(self, type_names: &[&str]) -> Self
pub fn add_placeholder_schemas(self, type_names: &[&str]) -> Self
为给定类型名追加占位 schema(占位 Object,用于引用解析)
Sourcepub fn apply_registered_schemas(self) -> Self
pub fn apply_registered_schemas(self) -> Self
应用由 endpoint 宏注册的 ToSchema 完整 schema
Sourcepub fn add_bearer_auth(
self,
scheme_name: &str,
description: Option<&str>,
) -> Self
pub fn add_bearer_auth( self, scheme_name: &str, description: Option<&str>, ) -> Self
添加 Bearer/JWT 安全定义
Sourcepub fn set_global_security(self, scheme_name: &str, scopes: &[&str]) -> Self
pub fn set_global_security(self, scheme_name: &str, scopes: &[&str]) -> Self
设置全局 security 要求
Sourcepub fn into_openapi(self) -> OpenApi
pub fn into_openapi(self) -> OpenApi
转换为OpenAPI对象
Sourcepub fn to_pretty_json(&self) -> Result<String>
pub fn to_pretty_json(&self) -> Result<String>
序列化为格式化的JSON字符串
Sourcepub fn to_json_value(&self) -> Result<Value>
pub fn to_json_value(&self) -> Result<Value>
序列化为JSON Value
Trait Implementations§
Source§impl Clone for OpenApiDoc
impl Clone for OpenApiDoc
Source§fn clone(&self) -> OpenApiDoc
fn clone(&self) -> OpenApiDoc
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OpenApiDoc
impl RefUnwindSafe for OpenApiDoc
impl Send for OpenApiDoc
impl Sync for OpenApiDoc
impl Unpin for OpenApiDoc
impl UnwindSafe for OpenApiDoc
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