paperclip_core::v2::schema

Trait Schema

source
pub trait Schema: Sized {
Show 18 methods // Required methods 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<&Resolvable<Self>>; fn items_mut(&mut self) -> Option<&mut 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); // Provided method fn contains_any(&self) -> bool { ... }
}
Expand description

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§

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

Mutable access to the items field, if it exists.

source

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

Value schema for maps (additional_properties field).

source

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

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

source

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

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

source

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

Mutable access to properties field.

source

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

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

source

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.
source

fn set_reference(&mut self, ref_: String)

Set the reference to this schema.

source

fn set_cyclic(&mut self, cyclic: bool)

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

source

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.

source

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.

source

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

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

Provided Methods§

source

fn contains_any(&self) -> bool

Returns whether this definition “is” or “has” Any type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§