Enum schemars::schema::Schema [−][src]
pub enum Schema {
Bool(bool),
Object(SchemaObject),
}
Expand description
A JSON Schema.
Variants
Bool(bool)
A trivial boolean JSON Schema.
The schema true
matches everything (always passes validation), whereas the schema false
matches nothing (always fails validation).
Tuple Fields of Bool
0: bool
Object(SchemaObject)
A JSON Schema object.
Tuple Fields of Object
0: SchemaObject
Implementations
Creates a new $ref
schema.
The given reference string should be a URI reference. This will usually be a JSON Pointer in URI Fragment representation.
Returns true
if self
is a $ref
schema.
If self
is a SchemaObject
with Some
reference
set, this returns true
.
Otherwise, returns false
.
Converts the given schema (if it is a boolean schema) into an equivalent schema object.
If the given schema is already a schema object, this has no effect.
Example
use schemars::schema::{Schema, SchemaObject};
let bool_schema = Schema::Bool(true);
assert_eq!(bool_schema.into_object(), SchemaObject::default());
Trait Implementations
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
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for Schema
impl UnwindSafe for Schema
Blanket Implementations
Mutably borrows from an owned value. Read more