#[non_exhaustive]pub struct Schema {Show 25 fields
pub type: Type,
pub format: String,
pub title: String,
pub description: String,
pub nullable: bool,
pub default: Option<Value>,
pub items: Option<Box<Schema>>,
pub min_items: i64,
pub max_items: i64,
pub enum: Vec<String>,
pub properties: HashMap<String, Schema>,
pub property_ordering: Vec<String>,
pub required: Vec<String>,
pub min_properties: i64,
pub max_properties: i64,
pub minimum: f64,
pub maximum: f64,
pub min_length: i64,
pub max_length: i64,
pub pattern: String,
pub example: Option<Value>,
pub any_of: Vec<Schema>,
pub additional_properties: Option<Value>,
pub ref: String,
pub defs: HashMap<String, Schema>,
/* private fields */
}gen-ai-cache-service or gen-ai-tuning-service or llm-utility-service or prediction-service or vertex-rag-service only.Expand description
Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.type: TypeOptional. The type of the data.
format: StringOptional. The format of the data. Supported formats: for NUMBER type: “float”, “double” for INTEGER type: “int32”, “int64” for STRING type: “email”, “byte”, etc
title: StringOptional. The title of the Schema.
description: StringOptional. The description of the data.
nullable: boolOptional. Indicates if the value may be null.
default: Option<Value>Optional. Default value of the data.
items: Option<Box<Schema>>Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY.
min_items: i64Optional. Minimum number of the elements for Type.ARRAY.
max_items: i64Optional. Maximum number of the elements for Type.ARRAY.
enum: Vec<String>Optional. Possible values of the element of primitive type with enum format. Examples:
- We can define direction as : {type:STRING, format:enum, enum:[“EAST”, NORTH“, “SOUTH”, “WEST”]}
- We can define apartment number as : {type:INTEGER, format:enum, enum:[“101”, “201”, “301”]}
properties: HashMap<String, Schema>Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT.
property_ordering: Vec<String>Optional. The order of the properties. Not a standard field in open api spec. Only used to support the order of the properties.
required: Vec<String>Optional. Required properties of Type.OBJECT.
min_properties: i64Optional. Minimum number of the properties for Type.OBJECT.
max_properties: i64Optional. Maximum number of the properties for Type.OBJECT.
minimum: f64Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER
maximum: f64Optional. Maximum value of the Type.INTEGER and Type.NUMBER
min_length: i64Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING
max_length: i64Optional. Maximum length of the Type.STRING
pattern: StringOptional. Pattern of the Type.STRING to restrict a string to a regular expression.
example: Option<Value>Optional. Example of the object. Will only populated when the object is the root.
any_of: Vec<Schema>Optional. The value should be validated against any (one or more) of the subschemas in the list.
additional_properties: Option<Value>Optional. Can either be a boolean or an object; controls the presence of additional properties.
ref: StringOptional. Allows indirect references between schema nodes. The value should
be a valid reference to a child of the root defs.
For example, the following schema defines a reference to a schema node named “Pet”:
type: object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string
The value of the “pet” property is a reference to the schema node named “Pet”. See details in https://json-schema.org/understanding-json-schema/structuring
defs: HashMap<String, Schema>Optional. A map of definitions for use by ref
Only allowed at the root of the schema.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn set_format<T: Into<String>>(self, v: T) -> Self
pub fn set_format<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_description<T: Into<String>>(self, v: T) -> Self
pub fn set_description<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_nullable<T: Into<bool>>(self, v: T) -> Self
pub fn set_nullable<T: Into<bool>>(self, v: T) -> Self
Sourcepub fn set_default<T>(self, v: T) -> Self
pub fn set_default<T>(self, v: T) -> Self
Sourcepub fn set_or_clear_default<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_default<T>(self, v: Option<T>) -> Self
Sourcepub fn set_or_clear_items<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_items<T>(self, v: Option<T>) -> Self
Sourcepub fn set_min_items<T: Into<i64>>(self, v: T) -> Self
pub fn set_min_items<T: Into<i64>>(self, v: T) -> Self
Sourcepub fn set_max_items<T: Into<i64>>(self, v: T) -> Self
pub fn set_max_items<T: Into<i64>>(self, v: T) -> Self
Sourcepub fn set_properties<T, K, V>(self, v: T) -> Self
pub fn set_properties<T, K, V>(self, v: T) -> Self
Sets the value of properties.
§Example
let x = Schema::new().set_properties([
("key0", Schema::default()/* use setters */),
("key1", Schema::default()/* use (different) setters */),
]);Sourcepub fn set_property_ordering<T, V>(self, v: T) -> Self
pub fn set_property_ordering<T, V>(self, v: T) -> Self
Sets the value of property_ordering.
§Example
let x = Schema::new().set_property_ordering(["a", "b", "c"]);Sourcepub fn set_required<T, V>(self, v: T) -> Self
pub fn set_required<T, V>(self, v: T) -> Self
Sourcepub fn set_min_properties<T: Into<i64>>(self, v: T) -> Self
pub fn set_min_properties<T: Into<i64>>(self, v: T) -> Self
Sourcepub fn set_max_properties<T: Into<i64>>(self, v: T) -> Self
pub fn set_max_properties<T: Into<i64>>(self, v: T) -> Self
Sourcepub fn set_minimum<T: Into<f64>>(self, v: T) -> Self
pub fn set_minimum<T: Into<f64>>(self, v: T) -> Self
Sourcepub fn set_maximum<T: Into<f64>>(self, v: T) -> Self
pub fn set_maximum<T: Into<f64>>(self, v: T) -> Self
Sourcepub fn set_min_length<T: Into<i64>>(self, v: T) -> Self
pub fn set_min_length<T: Into<i64>>(self, v: T) -> Self
Sourcepub fn set_max_length<T: Into<i64>>(self, v: T) -> Self
pub fn set_max_length<T: Into<i64>>(self, v: T) -> Self
Sourcepub fn set_pattern<T: Into<String>>(self, v: T) -> Self
pub fn set_pattern<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_example<T>(self, v: T) -> Self
pub fn set_example<T>(self, v: T) -> Self
Sourcepub fn set_or_clear_example<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_example<T>(self, v: Option<T>) -> Self
Sourcepub fn set_any_of<T, V>(self, v: T) -> Self
pub fn set_any_of<T, V>(self, v: T) -> Self
Sourcepub fn set_additional_properties<T>(self, v: T) -> Self
pub fn set_additional_properties<T>(self, v: T) -> Self
Sets the value of additional_properties.
§Example
use wkt::Value;
let x = Schema::new().set_additional_properties(Value::default()/* use setters */);Sourcepub fn set_or_clear_additional_properties<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_additional_properties<T>(self, v: Option<T>) -> Self
Sets or clears the value of additional_properties.
§Example
use wkt::Value;
let x = Schema::new().set_or_clear_additional_properties(Some(Value::default()/* use setters */));
let x = Schema::new().set_or_clear_additional_properties(None::<Value>);Trait Implementations§
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request