serialization of the gRPC JSONB now fully works for the validation

This commit is contained in:
Priec
2025-09-14 11:24:27 +02:00
parent d88c239bf6
commit ceb560c658
14 changed files with 25 additions and 4290 deletions

View File

@@ -1,10 +1,9 @@
// common/build.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_server(true)
.file_descriptor_set_path("src/proto/descriptor.bin")
.out_dir("src/proto")
// Derive serde for all relevant messages
// Derive serde for the messages
.type_attribute(
".komp_ac.table_validation.FieldValidation",
"#[derive(serde::Serialize, serde::Deserialize)]",
@@ -25,21 +24,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
".komp_ac.table_validation.UpdateFieldValidationResponse",
"#[derive(serde::Serialize, serde::Deserialize)]",
)
// Derive serde for the enum and keep legacy string values in JSON
// Enum -> readable strings in JSON ("BYTES", "DISPLAY_WIDTH")
.type_attribute(
".komp_ac.table_validation.CountMode",
"#[derive(serde::Serialize, serde::Deserialize)]",
"#[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = \"SCREAMING_SNAKE_CASE\")]",
)
.type_attribute(
".komp_ac.table_validation.CountMode",
r#"#[serde(rename_all = "SCREAMING_SNAKE_CASE")]"#,
)
// Back-compat: allow old "character_limits" key to deserialize into "limits"
.field_attribute(
".komp_ac.table_validation.FieldValidation.limits",
r#"#[serde(alias = "character_limits")]"#,
)
// Compile all protos (same list you already have)
.compile_protos(
&[
"proto/common.proto",