Expand description
Contains the Visitor trait, used to recursively modify a constructed schema and its subschemas.
Sometimes you may want to apply a change to a schema, as well as all schemas contained within it.
The easiest way to achieve this is by defining a type that implements Visitor.
All methods of Visitor have a default implementation that makes no change but recursively visits all subschemas.
When overriding one of these methods, you will usually want to still call this default implementation.
§Example
To add a custom property to all schemas:
use schemars::schema::SchemaObject;
use schemars::visit::{Visitor, visit_schema_object};
pub struct MyVisitor;
impl Visitor for MyVisitor {
    fn visit_schema_object(&mut self, schema: &mut SchemaObject) {
        // First, make our change to this schema
        schema.extensions.insert("my_property".to_string(), serde_json::json!("hello world"));
        // Then delegate to default implementation to visit any subschemas
        visit_schema_object(self, schema);
    }
}Structs§
- Remove
RefSiblings  - This visitor will restructure JSON Schema objects so that the 
$refproperty will never appear alongside any other properties. - Replace
Bool Schemas  - This visitor will replace all boolean JSON Schemas with equivalent object schemas.
 - SetSingle
Example  - This visitor will remove the 
examplesschema property and (if present) set its first value as theexampleproperty. 
Traits§
- Visitor
 - Trait used to recursively modify a constructed schema and its subschemas.
 
Functions§
- visit_
root_ schema  - Visits all subschemas of the 
RootSchema. - visit_
schema  - Visits all subschemas of the 
Schema. - visit_
schema_ object  - Visits all subschemas of the 
SchemaObject.