JsonSchema

Enum JsonSchema 

Source
pub enum JsonSchema {
    String {
        description: Option<String>,
        pattern: Option<String>,
        min_length: Option<u64>,
        max_length: Option<u64>,
        enum_values: Option<Vec<String>>,
    },
    Number {
        description: Option<String>,
        minimum: Option<f64>,
        maximum: Option<f64>,
    },
    Integer {
        description: Option<String>,
        minimum: Option<i64>,
        maximum: Option<i64>,
    },
    Boolean {
        description: Option<String>,
    },
    Array {
        description: Option<String>,
        items: Option<Box<JsonSchema>>,
        min_items: Option<u64>,
        max_items: Option<u64>,
    },
    Object {
        description: Option<String>,
        properties: Option<HashMap<String, JsonSchema>>,
        required: Option<Vec<String>>,
        additional_properties: Option<bool>,
    },
}
Expand description

A JSON Schema definition

Variants§

§

String

String type

Fields

§description: Option<String>
§pattern: Option<String>
§min_length: Option<u64>
§max_length: Option<u64>
§enum_values: Option<Vec<String>>
§

Number

Number type

Fields

§description: Option<String>
§minimum: Option<f64>
§maximum: Option<f64>
§

Integer

Integer type

Fields

§description: Option<String>
§minimum: Option<i64>
§maximum: Option<i64>
§

Boolean

Boolean type

Fields

§description: Option<String>
§

Array

Array type

Fields

§description: Option<String>
§min_items: Option<u64>
§max_items: Option<u64>
§

Object

Object type

Fields

§description: Option<String>
§required: Option<Vec<String>>
§additional_properties: Option<bool>

Implementations§

Source§

impl JsonSchema

Source

pub fn string() -> JsonSchema

Create a string schema

Source

pub fn string_with_description(description: impl Into<String>) -> JsonSchema

Create a string schema with description

Source

pub fn string_enum(values: Vec<String>) -> JsonSchema

Create a string enum schema

Source

pub fn number() -> JsonSchema

Create a number schema

Source

pub fn number_with_description(description: impl Into<String>) -> JsonSchema

Create a number schema with description

Source

pub fn integer() -> JsonSchema

Create an integer schema

Source

pub fn integer_with_description(description: impl Into<String>) -> JsonSchema

Create an integer schema with description

Source

pub fn boolean() -> JsonSchema

Create a boolean schema

Source

pub fn boolean_with_description(description: impl Into<String>) -> JsonSchema

Create a boolean schema with description

Source

pub fn array(items: JsonSchema) -> JsonSchema

Create an array schema

Source

pub fn array_with_description( items: JsonSchema, description: impl Into<String>, ) -> JsonSchema

Create an array schema with description

Source

pub fn object() -> JsonSchema

Create an object schema

Source

pub fn object_with_properties( properties: HashMap<String, JsonSchema>, ) -> JsonSchema

Create an object schema with properties

Source

pub fn object_with_required( properties: HashMap<String, JsonSchema>, required: Vec<String>, ) -> JsonSchema

Create an object schema with properties and required fields

Source

pub fn with_description(self, description: impl Into<String>) -> JsonSchema

Add description to any schema

Source

pub fn with_minimum(self, minimum: f64) -> JsonSchema

Add minimum constraint to number schema

Source

pub fn with_maximum(self, maximum: f64) -> JsonSchema

Add maximum constraint to number schema

Source

pub fn with_properties( self, properties: HashMap<String, JsonSchema>, ) -> JsonSchema

Add properties to object schema

Source

pub fn with_required(self, required: Vec<String>) -> JsonSchema

Add required fields to object schema

Trait Implementations§

Source§

impl Clone for JsonSchema

Source§

fn clone(&self) -> JsonSchema

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JsonSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for JsonSchema

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<JsonSchema, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for JsonSchema

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,