schemars icon indicating copy to clipboard operation
schemars copied to clipboard

Traversal of the Schema tree

Open karelispanagiotis opened this issue 2 years ago • 0 comments

I would like to traverse the RootSchema hierarchy (which I imagine as a tree) and print the paths to every node (from root to node). I cannot find the way to do so with the Visitor trait.

For example, for the Point struct

#[derive(JsonSchema)]
struct Coordinates {
    x: f32,
    y: f32,
}

#[derive(JsonSchema)]
enum PointType {
    Dot,
    Square,
    Triangle,
}

#[derive(JsonSchema)]
struct Point {
    coords: Coordinates,
    index: u32,
    point_type: PointType,
}

The output should be:

coords
coords/x
coords/y
index
point_type
point_type/Dot
point_type/Square
point_type/Triangle

What would you suggest?

karelispanagiotis avatar May 30 '23 15:05 karelispanagiotis