pub struct JsonSchema(/* private fields */);Expand description
Validated strict object JSON schema.
§Examples
use providers_kit::generation::JsonSchema;
let schema = JsonSchema::new(
serde_json::json!({"type":"object", "properties":{"answer":{"type":"string"}}}),
)?;
assert_eq!(schema.schema()["type"], "object");
Implementations§
Source§impl JsonSchema
impl JsonSchema
Sourcepub fn new(schema: Value) -> Result<Self, KitError>
pub fn new(schema: Value) -> Result<Self, KitError>
Validates and owns an object-shaped JSON schema.
§Errors
Returns an input error unless the schema is a JSON object whose root declares type: object. The selected operation performs any stricter schema or provider validation.
See crate::generation::JsonSchema for a complete example.
Sourcepub const fn schema(&self) -> &Value
pub const fn schema(&self) -> &Value
Borrows the validated schema document.
See crate::generation::JsonSchema for a complete example.
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
Consumes the wrapper and returns the schema document.
§Examples
use providers_kit::generation::JsonSchema;
let schema = JsonSchema::new(
serde_json::json!({"type":"object", "properties":{"answer":{"type":"string"}}}),
)?;
assert_eq!(schema.into_value()["type"], "object");
Trait Implementations§
Source§impl Clone for JsonSchema
impl Clone for JsonSchema
Source§impl Debug for JsonSchema
impl Debug for JsonSchema
Source§impl<'de> Deserialize<'de> for JsonSchema
impl<'de> Deserialize<'de> for JsonSchema
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for JsonSchema
impl PartialEq for JsonSchema
Source§impl Serialize for JsonSchema
impl Serialize for JsonSchema
impl StructuralPartialEq for JsonSchema
Auto Trait Implementations§
impl Freeze for JsonSchema
impl RefUnwindSafe for JsonSchema
impl Send for JsonSchema
impl Sync for JsonSchema
impl Unpin for JsonSchema
impl UnsafeUnpin for JsonSchema
impl UnwindSafe for JsonSchema
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
Mutably borrows from an owned value. Read more