Skip to content

Commit 7f07396

Browse files
authored
feat(api): Trim whitespaces (#488)
1 parent e10f85c commit 7f07396

File tree

11 files changed

+229
-3
lines changed

11 files changed

+229
-3
lines changed

etl-api/src/configs/destination.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ pub enum FullApiDestinationConfig {
1818
Memory,
1919
BigQuery {
2020
#[schema(example = "my-gcp-project")]
21+
#[serde(deserialize_with = "crate::utils::trim_string")]
2122
project_id: String,
2223
#[schema(example = "my_dataset")]
24+
#[serde(deserialize_with = "crate::utils::trim_string")]
2325
dataset_id: String,
2426
#[schema(example = "{\"type\": \"service_account\", \"project_id\": \"my-project\"}")]
2527
service_account_key: SerializableSecretString,
@@ -462,11 +464,17 @@ pub enum StoredIcebergConfig {
462464
pub enum FullApiIcebergConfig {
463465
Supabase {
464466
#[schema(example = "abcdefghijklmnopqrst")]
467+
#[serde(deserialize_with = "crate::utils::trim_string")]
465468
project_ref: String,
466469
#[schema(example = "my-warehouse")]
470+
#[serde(deserialize_with = "crate::utils::trim_string")]
467471
warehouse_name: String,
468472
#[schema(example = "my-namespace")]
469-
#[serde(skip_serializing_if = "Option::is_none")]
473+
#[serde(
474+
default,
475+
skip_serializing_if = "Option::is_none",
476+
deserialize_with = "crate::utils::trim_option_string"
477+
)]
470478
namespace: Option<String>,
471479
#[schema(
472480
example = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IjFkNzFjMGEyNmIxMDFjODQ5ZTkxZmQ1NjdjYjA5NTJmIn0.eyJleHAiOjIwNzA3MTcxNjAsImlhdCI6MTc1NjE0NTE1MCwiaXNzIjoic3VwYWJhc2UiLCJyZWYiOiJhYmNkZWZnaGlqbGttbm9wcXJzdCIsInJvbGUiOiJzZXJ2aWNlX3JvbGUifQ.YdTWkkIvwjSkXot3NC07xyjPjGWQMNzLq5EPzumzrdLzuHrj-zuzI-nlyQtQ5V7gZauysm-wGwmpztRXfPc3AQ"
@@ -477,20 +485,25 @@ pub enum FullApiIcebergConfig {
477485
#[schema(example = "ca833e890916d848c69135924bcd75e5909184814a0ebc6c988937ee094120d4")]
478486
s3_secret_access_key: SerializableSecretString,
479487
#[schema(example = "ap-southeast-1")]
488+
#[serde(deserialize_with = "crate::utils::trim_string")]
480489
s3_region: String,
481490
},
482491
Rest {
483492
#[schema(example = "https://abcdefghijklmnopqrst.storage.supabase.com/storage/v1/iceberg")]
493+
#[serde(deserialize_with = "crate::utils::trim_string")]
484494
catalog_uri: String,
485495
#[schema(example = "my-warehouse")]
496+
#[serde(deserialize_with = "crate::utils::trim_string")]
486497
warehouse_name: String,
487498
#[schema(example = "my-namespace")]
499+
#[serde(default, deserialize_with = "crate::utils::trim_option_string")]
488500
namespace: Option<String>,
489501
#[schema(example = "9156667efc2c70d89af6588da86d2924")]
490502
s3_access_key_id: SerializableSecretString,
491503
#[schema(example = "ca833e890916d848c69135924bcd75e5909184814a0ebc6c988937ee094120d4")]
492504
s3_secret_access_key: SerializableSecretString,
493505
#[schema(example = "https://s3.endpoint")]
506+
#[serde(deserialize_with = "crate::utils::trim_string")]
494507
s3_endpoint: String,
495508
},
496509
}

etl-api/src/configs/pipeline.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct ApiBatchConfig {
2929
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
3030
pub struct FullApiPipelineConfig {
3131
#[schema(example = "my_publication")]
32+
#[serde(deserialize_with = "crate::utils::trim_string")]
3233
pub publication_name: String,
3334
#[serde(skip_serializing_if = "Option::is_none")]
3435
pub batch: Option<ApiBatchConfig>,
@@ -63,7 +64,11 @@ impl From<StoredPipelineConfig> for FullApiPipelineConfig {
6364
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
6465
pub struct PartialApiPipelineConfig {
6566
#[schema(example = "my_publication")]
66-
#[serde(skip_serializing_if = "Option::is_none")]
67+
#[serde(
68+
default,
69+
skip_serializing_if = "Option::is_none",
70+
deserialize_with = "crate::utils::trim_option_string"
71+
)]
6772
pub publication_name: Option<String>,
6873
#[schema(example = r#"{"max_size": 1000000, "max_fill_ms": 10000}"#)]
6974
#[serde(skip_serializing_if = "Option::is_none")]

etl-api/src/configs/source.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ const DEFAULT_TLS_ENABLED: bool = false;
1717
#[serde(rename_all = "snake_case")]
1818
pub struct FullApiSourceConfig {
1919
#[schema(example = "localhost")]
20+
#[serde(deserialize_with = "crate::utils::trim_string")]
2021
pub host: String,
2122
#[schema(example = 5432)]
2223
pub port: u16,
2324
#[schema(example = "mydb")]
25+
#[serde(deserialize_with = "crate::utils::trim_string")]
2426
pub name: String,
2527
#[schema(example = "postgres")]
28+
#[serde(deserialize_with = "crate::utils::trim_string")]
2629
pub username: String,
2730
#[schema(example = "secret123")]
2831
#[serde(skip_serializing_if = "Option::is_none")]

etl-api/src/routes/destinations.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl ResponseError for DestinationError {
6464
#[derive(Debug, Serialize, Deserialize, ToSchema)]
6565
pub struct CreateDestinationRequest {
6666
#[schema(example = "My BigQuery Destination", required = true)]
67+
#[serde(deserialize_with = "crate::utils::trim_string")]
6768
pub name: String,
6869
#[schema(required = true)]
6970
pub config: FullApiDestinationConfig,
@@ -78,6 +79,7 @@ pub struct CreateDestinationResponse {
7879
#[derive(Debug, Serialize, Deserialize, ToSchema)]
7980
pub struct UpdateDestinationRequest {
8081
#[schema(example = "My Updated BigQuery Destination", required = true)]
82+
#[serde(deserialize_with = "crate::utils::trim_string")]
8183
pub name: String,
8284
#[schema(required = true)]
8385
pub config: FullApiDestinationConfig,

etl-api/src/routes/destinations_pipelines.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ impl ResponseError for DestinationPipelineError {
143143
#[derive(Debug, Serialize, Deserialize, ToSchema)]
144144
pub struct CreateDestinationPipelineRequest {
145145
#[schema(example = "My New Destination", required = true)]
146+
#[serde(deserialize_with = "crate::utils::trim_string")]
146147
pub destination_name: String,
147148
#[schema(required = true)]
148149
pub destination_config: FullApiDestinationConfig,
@@ -163,6 +164,7 @@ pub struct CreateDestinationPipelineResponse {
163164
#[derive(Debug, Serialize, Deserialize, ToSchema)]
164165
pub struct UpdateDestinationPipelineRequest {
165166
#[schema(example = "My Updated Destination", required = true)]
167+
#[serde(deserialize_with = "crate::utils::trim_string")]
166168
pub destination_name: String,
167169
#[schema(required = true)]
168170
pub destination_config: FullApiDestinationConfig,

etl-api/src/routes/images.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl ResponseError for ImageError {
5757
#[derive(Debug, Serialize, Deserialize, ToSchema)]
5858
pub struct CreateImageRequest {
5959
#[schema(example = "supabase/replicator:1.2.3", required = true)]
60+
#[serde(deserialize_with = "crate::utils::trim_string")]
6061
pub name: String,
6162
#[schema(example = true, required = true)]
6263
pub is_default: bool,
@@ -71,6 +72,7 @@ pub struct CreateImageResponse {
7172
#[derive(Debug, Serialize, Deserialize, ToSchema)]
7273
pub struct UpdateImageRequest {
7374
#[schema(example = "supabase/replicator:1.2.4", required = true)]
75+
#[serde(deserialize_with = "crate::utils::trim_string")]
7476
pub name: String,
7577
#[schema(example = false, required = true)]
7678
pub is_default: bool,

etl-api/src/routes/sources.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl ResponseError for SourceError {
6666
#[derive(Debug, Serialize, Deserialize, ToSchema)]
6767
pub struct CreateSourceRequest {
6868
#[schema(example = "My Postgres Source", required = true)]
69+
#[serde(deserialize_with = "crate::utils::trim_string")]
6970
pub name: String,
7071
#[schema(required = true)]
7172
pub config: FullApiSourceConfig,
@@ -80,6 +81,7 @@ pub struct CreateSourceResponse {
8081
#[derive(Debug, Serialize, Deserialize, ToSchema)]
8182
pub struct UpdateSourceRequest {
8283
#[schema(example = "My Updated Postgres Source", required = true)]
84+
#[serde(deserialize_with = "crate::utils::trim_string")]
8385
pub name: String,
8486
#[schema(required = true)]
8587
pub config: FullApiSourceConfig,

etl-api/src/routes/sources/publications.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl ResponseError for PublicationError {
8080
#[derive(Deserialize, ToSchema)]
8181
pub struct CreatePublicationRequest {
8282
#[schema(example = "my_publication", required = true)]
83+
#[serde(deserialize_with = "crate::utils::trim_string")]
8384
name: String,
8485
#[schema(required = true)]
8586
tables: Vec<Table>,

etl-api/src/routes/tenants.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ impl ResponseError for TenantError {
6060
#[derive(Debug, Serialize, Deserialize, ToSchema)]
6161
pub struct CreateTenantRequest {
6262
#[schema(example = "abczjjlmfsijwrlnwatw", required = true)]
63+
#[serde(deserialize_with = "crate::utils::trim_string")]
6364
pub id: String,
6465
#[schema(example = "My Tenant", required = true)]
66+
#[serde(deserialize_with = "crate::utils::trim_string")]
6567
pub name: String,
6668
}
6769

@@ -74,6 +76,7 @@ pub struct CreateTenantResponse {
7476
#[derive(Debug, Serialize, Deserialize, ToSchema)]
7577
pub struct CreateOrUpdateTenantRequest {
7678
#[schema(example = "My Updated Tenant", required = true)]
79+
#[serde(deserialize_with = "crate::utils::trim_string")]
7780
pub name: String,
7881
}
7982

@@ -86,6 +89,7 @@ pub struct CreateOrUpdateTenantResponse {
8689
#[derive(Debug, Serialize, Deserialize, ToSchema)]
8790
pub struct UpdateTenantRequest {
8891
#[schema(example = "My Updated Tenant", required = true)]
92+
#[serde(deserialize_with = "crate::utils::trim_string")]
8993
pub name: String,
9094
}
9195

etl-api/src/routes/tenants_sources.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ impl ResponseError for TenantSourceError {
6666
#[derive(Debug, Serialize, Deserialize, ToSchema)]
6767
pub struct CreateTenantSourceRequest {
6868
#[schema(example = "abczjjlmfsijwrlnwatw", required = true)]
69+
#[serde(deserialize_with = "crate::utils::trim_string")]
6970
pub tenant_id: String,
7071
#[schema(example = "My Tenant", required = true)]
72+
#[serde(deserialize_with = "crate::utils::trim_string")]
7173
pub tenant_name: String,
7274
#[schema(example = "My Postgres Source", required = true)]
75+
#[serde(deserialize_with = "crate::utils::trim_string")]
7376
pub source_name: String,
7477
#[schema(required = true)]
7578
pub source_config: FullApiSourceConfig,

0 commit comments

Comments
 (0)