[][src]Trait paperclip::v2::Schema

pub trait Schema {
    fn description(&self) -> Option<&str>;
fn reference(&self) -> Option<&str>;
fn data_type(&self) -> Option<DataType>;
fn format(&self) -> Option<&DataTypeFormat>;
fn items(&self) -> Option<&Either<Resolvable<Self>, Vec<Resolvable<Self>>>>;
fn items_mut(
        &mut self
    ) -> Option<&mut Either<Resolvable<Self>, Vec<Resolvable<Self>>>>;
fn additional_properties(&self) -> Option<&Either<bool, Resolvable<Self>>>;
fn additional_properties_mut(
        &mut self
    ) -> Option<&mut Either<bool, Resolvable<Self>>>;
fn properties(&self) -> Option<&BTreeMap<String, Resolvable<Self>>>;
fn properties_mut(
        &mut self
    ) -> Option<&mut BTreeMap<String, Resolvable<Self>>>;
fn required_properties(&self) -> Option<&BTreeSet<String>>;
fn enum_variants(&self) -> Option<&[Value]>;
fn set_reference(&mut self, ref_: String);
fn set_cyclic(&mut self, cyclic: bool);
fn is_cyclic(&self) -> bool;
fn name(&self) -> Option<&str>;
fn set_name(&mut self, name: &str); fn contains_any(&self) -> bool { ... } }

Interface for the Schema object.

This is only used for resolving the definitions.

NOTE: Don't implement this by yourself! Please use the #[api_v2_schema] proc macro attribute instead.

Required methods

fn description(&self) -> Option<&str>

Description for this schema, if any (description field).

fn reference(&self) -> Option<&str>

Reference to some other schema, if any ($ref field).

fn data_type(&self) -> Option<DataType>

Data type of this schema, if any (type field).

fn format(&self) -> Option<&DataTypeFormat>

Data type format used by this schema, if any (format field).

fn items(&self) -> Option<&Either<Resolvable<Self>, Vec<Resolvable<Self>>>>

Schema for array definitions, if any (items field).

fn items_mut(
    &mut self
) -> Option<&mut Either<Resolvable<Self>, Vec<Resolvable<Self>>>>

Mutable access to the items field, if it exists.

fn additional_properties(&self) -> Option<&Either<bool, Resolvable<Self>>>

Value schema for maps (additional_properties field).

fn additional_properties_mut(
    &mut self
) -> Option<&mut Either<bool, Resolvable<Self>>>

Mutable access to additional_properties field, if it's a map.

fn properties(&self) -> Option<&BTreeMap<String, Resolvable<Self>>>

Map of names and schema for properties, if it's an object (properties field)

fn properties_mut(&mut self) -> Option<&mut BTreeMap<String, Resolvable<Self>>>

Mutable access to properties field.

fn required_properties(&self) -> Option<&BTreeSet<String>>

Returns the required properties (if any) for this object.

fn enum_variants(&self) -> Option<&[Value]>

Enum variants in this schema (if any). It's serde_json::Value because:

  • Enum variants are allowed to have any type of value.
  • serde_json::Value works for both JSON and YAML.

fn set_reference(&mut self, ref_: String)

Set the reference to this schema.

fn set_cyclic(&mut self, cyclic: bool)

Set whether this definition is cyclic. This is done by the resolver.

fn is_cyclic(&self) -> bool

Returns whether this definition is cyclic.

NOTE: This is not part of the schema object, but it's set by the resolver using set_cyclic for codegen.

fn name(&self) -> Option<&str>

Name of this schema, if any.

NOTE: This is not part of the schema object, but it's set by the resolver using set_name for codegen.

fn set_name(&mut self, name: &str)

Sets the name for this schema. This is done by the resolver.

Loading content...

Provided methods

fn contains_any(&self) -> bool

Returns whether this definition "is" or "has" Any type.

Loading content...

Implementors

impl Schema for DefaultSchema[src]

Loading content...