Skip to content

Commit

Permalink
doc: tighten schema inference maximum depth to 12
Browse files Browse the repository at this point in the history
Deeply nested schemas are not useful and, in practice, are always
recursive data-structures.

Fixes #1667
  • Loading branch information
jgraettinger committed Sep 30, 2024
1 parent 0fb8177 commit 33fe96f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions crates/doc/src/shape/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,10 @@ pub fn enforce_shape_complexity_limit(shape: &mut Shape, limit: usize, depth_lim
}

pub const DEFAULT_SCHEMA_COMPLEXITY_LIMIT: usize = 1_000;
/// The default depth limit is chosen to result in JSON schemas that can be parsed
/// using a maximum recursion limit of 128, because that's what serde-json uses.
/// Each level of nesting in a source document produces two levels of nesting in the
/// schema due to the `properties` keyword. Then there's room for one last level of
/// nesting for the leave node schema, which will be an object.
pub const DEFAULT_SCHEMA_DEPTH_LIMIT: usize = 63;
/// The default depth limit is chosen to produce JSON schemas which are highly
/// descriptive for non-degenerate, non-recursive data structures, without endlessly
/// producing deeply nested properties for recurisve structures.
pub const DEFAULT_SCHEMA_DEPTH_LIMIT: usize = 12;

#[cfg(test)]
mod test {
Expand Down

0 comments on commit 33fe96f

Please sign in to comment.