Skip to content

Commit 5c36ce8

Browse files
committed
fix schema doc tests
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
1 parent 48b51ed commit 5c36ce8

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/engine.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,11 @@ impl Engine {
510510
/// engine.enable_type_checking();
511511
///
512512
/// // Set input schema
513+
/// # #[cfg(feature = "jsonschema")]
513514
/// if let Some(checker) = engine.get_type_checker_mut() {
514515
/// let schema = Schema::from_json_str(
515516
/// r#"{"type": "object", "properties": {"value": {"type": "integer"}}}"#
516-
/// )?;
517+
/// ).map_err(|e| anyhow::anyhow!("{e}"))?;
517518
/// checker.set_input_schema(schema);
518519
/// }
519520
///

src/schema.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ pub mod validate;
214214
/// Schemas are typically created by deserializing from JSON Schema format:
215215
///
216216
/// ```rust
217+
/// use regorus::schema::Schema;
217218
/// use serde_json::json;
218219
///
219220
/// // Create a schema from JSON
@@ -253,12 +254,16 @@ pub mod validate;
253254
///
254255
/// ## Simple String Schema
255256
/// ```rust
257+
/// # use regorus::schema::Schema;
258+
/// # use serde_json::json;
256259
/// let schema = json!({ "type": "string", "minLength": 1 });
257260
/// let parsed: Schema = serde_json::from_value(schema).unwrap();
258261
/// ```
259262
///
260263
/// ## Complex Object Schema
261264
/// ```rust
265+
/// # use regorus::schema::Schema;
266+
/// # use serde_json::json;
262267
/// let schema = json!({
263268
/// "type": "object",
264269
/// "properties": {
@@ -280,6 +285,8 @@ pub mod validate;
280285
///
281286
/// ## Union Types with anyOf
282287
/// ```rust
288+
/// # use regorus::schema::Schema;
289+
/// # use serde_json::json;
283290
/// let schema = json!({
284291
/// "anyOf": [
285292
/// { "type": "string" },

0 commit comments

Comments
 (0)