pub enum Schema {
Ref {
ref_path: String,
},
Object(ObjectType),
Array(ArrayType),
Primitive(PrimitiveSchema),
}Expand description
Schema 定义,支持引用、对象、数组、基本类型
Ref:通过$ref引用 components.schemas 中定义的 SchemaObject:对象类型,包含 properties 和 requiredArray:数组类型,包含 itemsPrimitive:基本类型(string/integer/number/boolean)
Variants§
Ref
引用其他已定义的 Schema
Object(ObjectType)
对象类型
Array(ArrayType)
数组类型
Primitive(PrimitiveSchema)
基本类型(string/integer/number/boolean)
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn object(obj: ObjectType) -> Self
pub fn object(obj: ObjectType) -> Self
创建一个对象 Schema
Sourcepub fn with_format(self, format: &str) -> Self
pub fn with_format(self, format: &str) -> Self
设置 format(仅对 Primitive 类型有效,其他类型返回原值)
Sourcepub fn with_description(self, desc: &str) -> Self
pub fn with_description(self, desc: &str) -> Self
设置描述(仅对 Primitive 类型有效)
Sourcepub fn with_example(self, value: Value) -> Self
pub fn with_example(self, value: Value) -> Self
设置示例值(仅对 Primitive 类型有效)
Sourcepub fn with_default(self, value: Value) -> Self
pub fn with_default(self, value: Value) -> Self
设置默认值(仅对 Primitive 类型有效)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more