pub trait Apiv2Schema {
// Provided methods
fn name() -> Option<String> { ... }
fn description() -> &'static str { ... }
fn required() -> bool { ... }
fn raw_schema() -> DefaultSchemaRaw { ... }
fn schema_with_ref() -> DefaultSchemaRaw { ... }
fn security_scheme() -> Option<SecurityScheme> { ... }
fn header_parameter_schema() -> Vec<Parameter<DefaultSchemaRaw>> { ... }
}
Expand description
Represents a OpenAPI v2 schema object convertible. This is auto-implemented by framework-specific macros:
Apiv2Schema
for schema objects.Apiv2Security
for security scheme objects.Apiv2Header
for header parameters objects.
This is implemented for primitive types by default.
Provided Methods§
sourcefn name() -> Option<String>
fn name() -> Option<String>
Name of this schema. This is the name to which the definition of the object is mapped.
sourcefn description() -> &'static str
fn description() -> &'static str
Description of this schema. In case the trait is derived, uses the documentation on the type.
sourcefn raw_schema() -> DefaultSchemaRaw
fn raw_schema() -> DefaultSchemaRaw
Returns the raw schema for this object.
sourcefn schema_with_ref() -> DefaultSchemaRaw
fn schema_with_ref() -> DefaultSchemaRaw
Returns the schema with a reference (if this is an object).
Here, we set the global reference to this object using its name,
and we either remove the reference (remove_refs
) or remove all
properties other than the reference (retain_ref
) based on where
we’re storing this object in the spec i.e., in an operation/response
or in the map of definitions.
And we do that because at the time of this writing, statically collecting all models for all operations involved a lot of work, and so I went for runtime collection. Even though this happens at runtime, we’re only doing this once at the start of the application, so it won’t affect the incoming requests at all.
sourcefn security_scheme() -> Option<SecurityScheme>
fn security_scheme() -> Option<SecurityScheme>
Returns the security scheme for this object.
fn header_parameter_schema() -> Vec<Parameter<DefaultSchemaRaw>>
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.
Implementations on Foreign Types§
impl Apiv2Schema for Value
impl Apiv2Schema for Value
impl Apiv2Schema for ()
impl Apiv2Schema for Bytes
impl Apiv2Schema for HttpRequest
impl Apiv2Schema for HttpResponse
impl Apiv2Schema for Payload
impl Apiv2Schema for Response<BoxBody>
source§impl<'a, T: Apiv2Schema> Apiv2Schema for &'a [T]
impl<'a, T: Apiv2Schema> Apiv2Schema for &'a [T]
fn raw_schema() -> DefaultSchemaRaw
impl<A: Apiv2Schema> Apiv2Schema for Path<(A,)>
impl<A: Apiv2Schema, B: Apiv2Schema> Apiv2Schema for Path<(A, B)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema> Apiv2Schema for Path<(A, B, C)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema, G: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F, G)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema, G: Apiv2Schema, H: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F, G, H)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema, G: Apiv2Schema, H: Apiv2Schema, I: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F, G, H, I)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema, G: Apiv2Schema, H: Apiv2Schema, I: Apiv2Schema, J: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F, G, H, I, J)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema, G: Apiv2Schema, H: Apiv2Schema, I: Apiv2Schema, J: Apiv2Schema, K: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F, G, H, I, J, K)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema, G: Apiv2Schema, H: Apiv2Schema, I: Apiv2Schema, J: Apiv2Schema, K: Apiv2Schema, L: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F, G, H, I, J, K, L)>
impl<A: Apiv2Schema, B: Apiv2Schema, C: Apiv2Schema, D: Apiv2Schema, E: Apiv2Schema, F: Apiv2Schema, G: Apiv2Schema, H: Apiv2Schema, I: Apiv2Schema, J: Apiv2Schema, K: Apiv2Schema, L: Apiv2Schema, M: Apiv2Schema> Apiv2Schema for Path<(A, B, C, D, E, F, G, H, I, J, K, L, M)>
source§impl<K: ToString, V: Apiv2Schema> Apiv2Schema for BTreeMap<K, V>
impl<K: ToString, V: Apiv2Schema> Apiv2Schema for BTreeMap<K, V>
fn raw_schema() -> DefaultSchemaRaw
source§impl<K: ToString, V: Apiv2Schema> Apiv2Schema for HashMap<K, V>
impl<K: ToString, V: Apiv2Schema> Apiv2Schema for HashMap<K, V>
fn raw_schema() -> DefaultSchemaRaw
impl<T> Apiv2Schema for Data<T>
impl<T: Clone> Apiv2Schema for ReqData<T>
source§impl<T: Apiv2Schema + Clone> Apiv2Schema for Cow<'_, T>
impl<T: Apiv2Schema + Clone> Apiv2Schema for Cow<'_, T>
fn name() -> Option<String>
fn raw_schema() -> DefaultSchemaRaw
fn security_scheme() -> Option<SecurityScheme>
fn header_parameter_schema() -> Vec<Parameter<DefaultSchemaRaw>>
source§impl<T: Apiv2Schema> Apiv2Schema for Option<T>
impl<T: Apiv2Schema> Apiv2Schema for Option<T>
fn name() -> Option<String>
fn required() -> bool
fn raw_schema() -> DefaultSchemaRaw
fn security_scheme() -> Option<SecurityScheme>
fn header_parameter_schema() -> Vec<Parameter<DefaultSchemaRaw>>
source§impl<T: Apiv2Schema> Apiv2Schema for BinaryHeap<T>
impl<T: Apiv2Schema> Apiv2Schema for BinaryHeap<T>
fn raw_schema() -> DefaultSchemaRaw
source§impl<T: Apiv2Schema> Apiv2Schema for BTreeSet<T>
impl<T: Apiv2Schema> Apiv2Schema for BTreeSet<T>
fn raw_schema() -> DefaultSchemaRaw
source§impl<T: Apiv2Schema> Apiv2Schema for LinkedList<T>
impl<T: Apiv2Schema> Apiv2Schema for LinkedList<T>
fn raw_schema() -> DefaultSchemaRaw
source§impl<T: Apiv2Schema> Apiv2Schema for VecDeque<T>
impl<T: Apiv2Schema> Apiv2Schema for VecDeque<T>
fn raw_schema() -> DefaultSchemaRaw
source§impl<T: Apiv2Schema> Apiv2Schema for Vec<T>
impl<T: Apiv2Schema> Apiv2Schema for Vec<T>
fn raw_schema() -> DefaultSchemaRaw
source§impl<T: Apiv2Schema> Apiv2Schema for HashSet<T>
impl<T: Apiv2Schema> Apiv2Schema for HashSet<T>
fn raw_schema() -> DefaultSchemaRaw
impl<T: Apiv2Schema> Apiv2Schema for Form<T>
source§impl<T: Apiv2Schema> Apiv2Schema for Json<T>
impl<T: Apiv2Schema> Apiv2Schema for Json<T>
JSON needs specialization because it updates the global definitions.