From d93bdc43e37bd384b83bbed825d2a6192d87890b Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Tue, 17 May 2022 18:17:17 +0100 Subject: [PATCH] Revert "Support generic default values" This feature inadvertently introduced a breaking change (#144) This reverts commits: feb6c4b2fec86f8ac2afd973a3b3a2d6f51135f2 b38a55331b8b6171305359f618e997a7ce275e4d. --- schemars/tests/default.rs | 12 ------------ schemars/tests/expected/generic_default.json | 14 -------------- schemars_derive/src/schema_exprs.rs | 2 +- 3 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 schemars/tests/expected/generic_default.json diff --git a/schemars/tests/default.rs b/schemars/tests/default.rs index e6546300..fbc1033b 100644 --- a/schemars/tests/default.rs +++ b/schemars/tests/default.rs @@ -56,15 +56,3 @@ struct NotSerialize; fn schema_default_values() -> TestResult { test_default_generated_schema::("default") } - -#[allow(dead_code)] -#[derive(JsonSchema)] -struct StructWithGenericDefaults { - #[serde(default = "Vec::new")] - a_vec: Vec, -} - -#[test] -fn schema_with_generic_default_value() -> TestResult { - test_default_generated_schema::("generic_default") -} diff --git a/schemars/tests/expected/generic_default.json b/schemars/tests/expected/generic_default.json deleted file mode 100644 index 095b9991..00000000 --- a/schemars/tests/expected/generic_default.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "StructWithGenericDefaults", - "type": "object", - "properties": { - "a_vec": { - "default": [], - "type": "array", - "items": { - "type": "string" - } - } - } -} \ No newline at end of file diff --git a/schemars_derive/src/schema_exprs.rs b/schemars_derive/src/schema_exprs.rs index f41e37ae..c5b1672d 100644 --- a/schemars_derive/src/schema_exprs.rs +++ b/schemars_derive/src/schema_exprs.rs @@ -581,7 +581,7 @@ fn field_default_expr(field: &Field, container_has_default: bool) -> Option 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() {