From 2b976d22db06cea9ea1dacc72dd396a829a239c3 Mon Sep 17 00:00:00 2001 From: Joseph Shearer Date: Wed, 2 Oct 2024 14:52:22 -0400 Subject: [PATCH] dekaf: Add some important annotations to endpoint/resource schemas --- crates/dekaf/src/connector.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/dekaf/src/connector.rs b/crates/dekaf/src/connector.rs index dfce7911c6..253bdbb2f9 100644 --- a/crates/dekaf/src/connector.rs +++ b/crates/dekaf/src/connector.rs @@ -13,6 +13,7 @@ pub struct DekafConfig { /// The password that will authenticate Kafka consumers to this task. // TODO(jshearer): Uncomment when schemars 1.0 is out and we upgrade // #[schemars(extend("secret" = true))] + #[schemars(schema_with = "token_secret")] pub token: String, } @@ -21,9 +22,25 @@ pub struct DekafConfig { pub struct DekafResourceConfig { /// The exposed name of the topic that maps to this binding. This /// will be exposed through the Kafka metadata/discovery APIs. + #[schemars(schema_with = "collection_name")] pub topic_name: String, } +fn collection_name(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + serde_json::from_value(serde_json::json!({ + "x-collection-name": true, + })) + .unwrap() +} + +fn token_secret(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + serde_json::from_value(serde_json::json!({ + "title": "Dekaf Auth Token", + "secret": true, + })) + .unwrap() +} + pub async fn unary_materialize( request: materialize::Request, ) -> anyhow::Result {