77//! A Facility to generate valid, random data for types that are
88//! `schemars::JsonSchema + serde::Deserialize`. It generates a JSON value
99//! based on the JSON schema and then deserializes that into the given type.
10+ //!
11+ //! Notes
12+ //! Configuration we might want
13+ //! - Should we use examples if they're present? Seems like might be a enum
14+ //! to select between "ignore examples", "exclusively use examples",
15+ //! "choose between generated values and examples (with some weight)",
16+ //! "choose examples for scalars (but not complex types)", etc.
17+ //! - One can imagine situations where it may not be tractable to know a priori
18+ //! if a value validates, for example if there were a structure that
19+ //! contained a complex regex or a `not` with a complex schema. The consumer
20+ //! might want to decide how many times we try to generate a type before
21+ //! giving up with an error.
22+ //! - Maximum array length.
23+ //!
24+ //! Do we need something to ensure that recursive types converge? For example,
25+ //! we could track the depth of an object (per-reference or in absolute terms)
26+ //! and bias towards simpler types as the depth increases (e.g. preferring to
27+ //! exclude non-required object properties or shortening arrays).
1028
1129use std:: fmt:: Display ;
1230
@@ -22,25 +40,6 @@ use schemars::{
2240use serde:: de:: DeserializeOwned ;
2341use serde_json:: { json, Number , Value } ;
2442
25- /// Notes
26- /// Configuration we might want
27- /// - Should we use examples if they're present? Seems like might be a enum
28- /// to select between "ignore examples", "exclusively use examples",
29- /// "choose between generated values and examples (with some weight)",
30- /// "choose examples for scalars (but not complex types)", etc.
31- /// - One can imagine situations where it may not be tractable to know a priori
32- /// if a value validates, for example if there were a structure that
33- /// contained a complex regex or a `not` with a complex schema. The consumer
34- /// might want to decide how many times we try to generate a type before
35- /// giving up with an error.
36- /// - Maximum array length.
37- ///
38- ///
39- /// Do we need something to ensure that recursive types converge? For example,
40- /// we could track the depth of an object (per-reference or in absolute terms)
41- /// and bias towards simpler types as the depth increases (e.g. preferring to
42- /// exclude non-required object properties or shortening arrays).
43-
4443// TODO This is going to let us have a fixed set of bytes or an RNG.
4544pub trait Source : Rng { }
4645impl < T > Source for T where T : Rng { }
@@ -417,6 +416,7 @@ fn mock_bool(src: &mut impl Source) -> Result<Value, Error> {
417416 Ok ( json ! { b } )
418417}
419418
419+ #[ allow( clippy:: manual_div_ceil) ]
420420fn mock_integer (
421421 format : & Option < String > ,
422422 number : & Option < Box < NumberValidation > > ,
0 commit comments