Skip to content

Commit

Permalink
Use prop_map_into instead of prop_map + into in json generation
Browse files Browse the repository at this point in the history
  • Loading branch information
matusf committed Jun 27, 2023
1 parent 026854d commit 5fcc876
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ fn generate_json_array(array: &ArrayType) -> BoxedStrategy<serde_json::Value> {

fn schema_type_to_json(schema_type: &Type) -> BoxedStrategy<serde_json::Value> {
match schema_type {
Type::Boolean {} => any::<bool>().prop_map(Into::into).boxed(),
Type::Integer(_integer_type) => any::<i64>().prop_map(Into::into).boxed(),
Type::Number(_number_type) => any::<f32>().prop_map(Into::into).boxed(),
Type::String(_string_type) => any::<String>().prop_map(Into::into).boxed(),
Type::Boolean {} => any::<bool>().prop_map_into::<serde_json::Value>().boxed(),
Type::Integer(_integer_type) => any::<i64>().prop_map_into::<serde_json::Value>().boxed(),
Type::Number(_number_type) => any::<f32>().prop_map_into::<serde_json::Value>().boxed(),
Type::String(_string_type) => any::<String>().prop_map_into::<serde_json::Value>().boxed(),
Type::Object(object_type) => generate_json_object(object_type),
Type::Array(array_type) => generate_json_array(array_type),
}
}

fn schema_kind_to_json(schema_kind: &SchemaKind) -> BoxedStrategy<serde_json::Value> {
match schema_kind {
SchemaKind::Any(_any) => any::<String>().prop_map(serde_json::Value::String).boxed(),
SchemaKind::Any(_any) => any::<String>().prop_map_into::<serde_json::Value>().boxed(),
SchemaKind::Type(schema_type) => schema_type_to_json(schema_type).boxed(),
SchemaKind::AnyOf { any_of: schemas } | SchemaKind::OneOf { one_of: schemas } => {
Union::new(
Expand Down

0 comments on commit 5fcc876

Please sign in to comment.