Skip to main content

OpenApiBuilder

Struct OpenApiBuilder 

Source
pub struct OpenApiBuilder { /* private fields */ }
Expand description

OpenAPI 文档构建器

提供流畅的 API 来构建 OpenAPI 文档。

Implementations§

Source§

impl OpenApiBuilder

Source

pub fn new() -> Self

创建新的 OpenAPI 构建器

Source

pub fn with_title_and_version( title: impl Into<String>, version: impl Into<String>, ) -> Self

创建指定标题和版本的 OpenAPI 构建器

Source

pub fn title(self, title: impl Into<String>) -> Self

设置 API 标题

Source

pub fn version(self, version: impl Into<String>) -> Self

设置 API 版本

Source

pub fn description(self, desc: impl Into<String>) -> Self

设置 API 描述

Source

pub fn terms_of_service(self, url: impl Into<String>) -> Self

设置服务条款 URL

Source

pub fn contact(self, contact: Contact) -> Self

设置联系信息

Source

pub fn license(self, license: License) -> Self

设置许可信息

Source

pub fn path(self, path: impl Into<String>, item: PathItem) -> Self

添加路径

Source

pub fn paths(self, paths: BTreeMap<String, PathItem>) -> Self

添加多个路径

Source

pub fn schema(self, name: impl Into<String>, schema: Schema) -> Self

添加 Schema 组件

Source

pub fn schemas(self, schemas: BTreeMap<String, Schema>) -> Self

添加多个 Schema 组件

Source

pub fn response(self, name: impl Into<String>, response: Response) -> Self

添加响应组件

Source

pub fn responses(self, responses: BTreeMap<String, Response>) -> Self

添加多个响应组件

Source

pub fn parameter(self, name: impl Into<String>, parameter: Parameter) -> Self

添加参数组件

Source

pub fn parameters(self, parameters: BTreeMap<String, Parameter>) -> Self

添加多个参数组件

Source

pub fn request_body(self, name: impl Into<String>, body: RequestBody) -> Self

添加请求体组件

Source

pub fn request_bodies(self, bodies: BTreeMap<String, RequestBody>) -> Self

添加多个请求体组件

Source

pub fn security_scheme( self, name: impl Into<String>, scheme: SecurityScheme, ) -> Self

添加安全方案组件

Source

pub fn security_schemes(self, schemes: BTreeMap<String, SecurityScheme>) -> Self

添加多个安全方案组件

Source

pub fn server(self, url: impl Into<String>, description: Option<String>) -> Self

添加服务器

Source

pub fn servers(self, servers: Vec<Server>) -> Self

添加多个服务器

Source

pub fn tag(self, name: impl Into<String>, description: Option<String>) -> Self

添加标签

Source

pub fn tags(self, tags: Vec<Tag>) -> Self

添加多个标签

Source

pub fn external_docs( self, url: impl Into<String>, description: Option<String>, ) -> Self

设置外部文档

Source

pub fn security(self, security: SecurityRequirement) -> Self

添加安全要求

Source

pub fn securities(self, securities: Vec<SecurityRequirement>) -> Self

添加多个安全要求

Source

pub fn build(self) -> OpenApiDoc

构建 OpenAPI 文档

Trait Implementations§

Source§

impl Default for OpenApiBuilder

Source§

fn default() -> Self

创建默认的 OpenAPI 构建器

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.