pub struct OpenApiBuilder { /* private fields */ }Expand description
OpenAPI 文档构建器
提供流畅的 API 来构建 OpenAPI 文档。
Implementations§
Source§impl OpenApiBuilder
impl OpenApiBuilder
Sourcepub fn with_title_and_version(
title: impl Into<String>,
version: impl Into<String>,
) -> Self
pub fn with_title_and_version( title: impl Into<String>, version: impl Into<String>, ) -> Self
创建指定标题和版本的 OpenAPI 构建器
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
设置 API 描述
Sourcepub fn terms_of_service(self, url: impl Into<String>) -> Self
pub fn terms_of_service(self, url: impl Into<String>) -> Self
设置服务条款 URL
Sourcepub fn parameters(self, parameters: BTreeMap<String, Parameter>) -> Self
pub fn parameters(self, parameters: BTreeMap<String, Parameter>) -> Self
添加多个参数组件
Sourcepub fn request_body(self, name: impl Into<String>, body: RequestBody) -> Self
pub fn request_body(self, name: impl Into<String>, body: RequestBody) -> Self
添加请求体组件
Sourcepub fn request_bodies(self, bodies: BTreeMap<String, RequestBody>) -> Self
pub fn request_bodies(self, bodies: BTreeMap<String, RequestBody>) -> Self
添加多个请求体组件
Sourcepub fn security_scheme(
self,
name: impl Into<String>,
scheme: SecurityScheme,
) -> Self
pub fn security_scheme( self, name: impl Into<String>, scheme: SecurityScheme, ) -> Self
添加安全方案组件
Sourcepub fn security_schemes(self, schemes: BTreeMap<String, SecurityScheme>) -> Self
pub fn security_schemes(self, schemes: BTreeMap<String, SecurityScheme>) -> Self
添加多个安全方案组件
添加多个标签
Sourcepub fn external_docs(
self,
url: impl Into<String>,
description: Option<String>,
) -> Self
pub fn external_docs( self, url: impl Into<String>, description: Option<String>, ) -> Self
设置外部文档
Sourcepub fn security(self, security: SecurityRequirement) -> Self
pub fn security(self, security: SecurityRequirement) -> Self
添加安全要求
Sourcepub fn securities(self, securities: Vec<SecurityRequirement>) -> Self
pub fn securities(self, securities: Vec<SecurityRequirement>) -> Self
添加多个安全要求
Sourcepub fn build(self) -> OpenApiDoc
pub fn build(self) -> OpenApiDoc
构建 OpenAPI 文档
Trait Implementations§
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