Generate random values based on JSON Schema.
Experimental module.
value : GeneratorSettings -> Json.Schema.Definitions.Schema -> Random.Generator Json.Encode.Value
Random value generator.
buildSchema
|> withProperties
[ ( "foo", buildSchema |> withType "integer" ) ]
|> toSchema
|> Result.withDefault blankSchema
|> value defaultSettings
|> (\a -> Random.step a (Random.initialSeed 2))
|> (\( v, _ ) ->
Expect.equal v (Encode.object [ ( "foo", Encode.int 688281600 ) ])
)
See tests for more examples.
valueAt : GeneratorSettings -> Json.Schema.Definitions.Schema -> String -> Random.Generator Json.Encode.Value
Random value generator at path.
{ optionalPropertyProbability : Basics.Float
, degradationMultiplier : Basics.Float
, defaultListLengthLimit : Basics.Int
, defaultStringLengthLimit : Basics.Int
}
Customize generator behaviour using following parameters:
defaultSettings : GeneratorSettings
Defaults for GeneratorSettings