Skip to content

Commit

Permalink
Revert "Support generic default values"
Browse files Browse the repository at this point in the history
This feature inadvertently introduced a breaking change (#144)

This reverts commits: feb6c4b
b38a553.
  • Loading branch information
GREsau committed May 17, 2022
1 parent 1610294 commit d93bdc4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
12 changes: 0 additions & 12 deletions schemars/tests/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,3 @@ struct NotSerialize;
fn schema_default_values() -> TestResult {
test_default_generated_schema::<MyStruct>("default")
}

#[allow(dead_code)]
#[derive(JsonSchema)]
struct StructWithGenericDefaults {
#[serde(default = "Vec::new")]
a_vec: Vec<String>,
}

#[test]
fn schema_with_generic_default_value() -> TestResult {
test_default_generated_schema::<StructWithGenericDefaults>("generic_default")
}
14 changes: 0 additions & 14 deletions schemars/tests/expected/generic_default.json

This file was deleted.

2 changes: 1 addition & 1 deletion schemars_derive/src/schema_exprs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ fn field_default_expr(field: &Field, container_has_default: bool) -> Option<Toke
quote!(container_default.#member)
}
SerdeDefault::Default => quote!(<#ty>::default()),
SerdeDefault::Path(path) => quote!({ #path() as #ty }),
SerdeDefault::Path(path) => quote!(#path()),
};

let default_expr = match field.serde_attrs.skip_serializing_if() {
Expand Down

0 comments on commit d93bdc4

Please sign in to comment.