Skip to content

Commit 17f063a

Browse files
authored
Fix jsonschema (#805)
Using `#[serde(rename="camelCase")] on an enum renames the enum tag, not the enum fields. For that, we have `rename_all_fields`. Turns out, that is not supported by schemars 0.8, which is the version used by ndc models. So, this PR users `#[serde(rename)]` on the individual fields.
1 parent 476b5ea commit 17f063a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### Fixed
1010

11+
- Fix a bug where the configuration jsonschema for `DynamicConnectionSettings` was not correctly renaming fields to camelCase.
12+
1113
## [v3.0.0] - 2025-07-02
1214

1315
### Added

crates/configuration/src/version5/connection_settings.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,28 @@ impl DatabaseConnectionSettings {
3939
}
4040
}
4141

42+
// note: we should be using #[serde(rename_all_fields = "camelCase") here, but that's not supported by schemars 0.8
43+
// schemars 1.0.3 does support it, but ndc models is still on 0.8.
44+
// we should update here once we upgrade ndc models and other dependencies
4245
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, JsonSchema)]
43-
#[serde(
44-
rename_all = "camelCase",
45-
rename_all_fields = "camelCase",
46-
tag = "mode"
47-
)]
46+
#[serde(rename_all = "camelCase", tag = "mode")]
4847
pub enum DynamicConnectionSettings {
4948
Named {
49+
#[serde(rename = "connectionUris")]
5050
connection_uris: ConnectionUris,
5151
/// When set to true, fallback to using the connectionUri if the connection_name request argument is missing
5252
/// If this is not set, the connectionUri is not used at runtime, but will still be used by cli utilities
53-
#[serde(default)]
53+
#[serde(default, rename = "fallbackToStatic")]
5454
fallback_to_static: bool,
5555
/// When set to true, eagerly create connection pools for all connection names at startup
5656
/// If this is not set, connection pools are created lazily when a request is made for a connection name
57-
#[serde(default)]
57+
#[serde(default, rename = "eagerConnections")]
5858
eager_connections: bool,
5959
},
6060
Dynamic {
6161
/// When set to true, fallback to using the connectionUri if the connection_string request argument is missing
6262
/// If this is not set, the connectionUri is not used at runtime, but will still be used by cli utilities
63-
#[serde(default)]
63+
#[serde(default, rename = "fallbackToStatic")]
6464
fallback_to_static: bool,
6565
},
6666
}

0 commit comments

Comments
 (0)