Skip to content

Commit 4a6c6a8

Browse files
gokerakcVisualBean
authored andcommitted
feat: added new topic configuration properties
1 parent c336ed8 commit 4a6c6a8

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public class KafkaChannelBinding : ChannelBinding<KafkaChannelBinding>
5151
{ "retention.bytes", (a, n) => { a.RetentionBytes = n.GetIntegerValue(); } },
5252
{ "delete.retention.ms", (a, n) => { a.DeleteRetentionMiliseconds = n.GetIntegerValue(); } },
5353
{ "max.message.bytes", (a, n) => { a.MaxMessageBytes = n.GetIntegerValue(); } },
54+
{ "confluent.key.schema.validation", (a, n) => { a.ConfluentKeySchemaValidation = n.GetBooleanValue(); } },
55+
{ "confluent.key.subject.name.strategy", (a, n) => { a.ConfluentKeySubjectName = n.GetScalarValue(); } },
56+
{ "confluent.value.schema.validation", (a, n) => { a.ConfluentValueSchemaValidation = n.GetBooleanValue(); } },
57+
{ "confluent.value.subject.name.strategy", (a, n) => { a.ConfluentValueSubjectName = n.GetScalarValue(); } },
5458
};
5559

5660
/// <summary>

src/LEGO.AsyncAPI.Bindings/Kafka/TopicConfigurationObject.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ public class TopicConfigurationObject : IAsyncApiElement
3333
/// The max.message.bytes configuration option.
3434
/// </summary>
3535
public int? MaxMessageBytes { get; set; }
36+
37+
/// <summary>
38+
/// The confluent.key.schema.validation configuration option.
39+
/// </summary>
40+
public bool? ConfluentKeySchemaValidation { get; set; }
41+
42+
/// <summary>
43+
/// The confluent.key.subject.name.strategy configuration option.
44+
/// </summary>
45+
public string ConfluentKeySubjectName { get; set; }
46+
47+
/// <summary>
48+
/// The confluent.value.schema.validation configuration option.
49+
/// </summary>
50+
public bool? ConfluentValueSchemaValidation { get; set; }
51+
52+
/// <summary>
53+
/// The confluent.value.subject.name.strategy configuration option.
54+
/// </summary>
55+
public string ConfluentValueSubjectName { get; set; }
3656

3757
public void Serialize(IAsyncApiWriter writer)
3858
{
@@ -47,6 +67,10 @@ public void Serialize(IAsyncApiWriter writer)
4767
writer.WriteOptionalProperty<int>(AsyncApiConstants.RetentionBytes, this.RetentionBytes);
4868
writer.WriteOptionalProperty<int>(AsyncApiConstants.DeleteRetentionMiliseconds, this.DeleteRetentionMiliseconds);
4969
writer.WriteOptionalProperty<int>(AsyncApiConstants.MaxMessageBytes, this.MaxMessageBytes);
70+
writer.WriteOptionalProperty<bool>(AsyncApiConstants.ConfluentKeySchemaValidation, this.ConfluentKeySchemaValidation);
71+
writer.WriteOptionalProperty(AsyncApiConstants.ConfluentKeySubjectName, this.ConfluentKeySubjectName);
72+
writer.WriteOptionalProperty<bool>(AsyncApiConstants.ConfluentValueSchemaValidation, this.ConfluentValueSchemaValidation);
73+
writer.WriteOptionalProperty(AsyncApiConstants.ConfluentValueSubjectName, this.ConfluentValueSubjectName);
5074
writer.WriteEndObject();
5175
}
5276
}

src/LEGO.AsyncAPI/Models/AsyncApiConstants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public static class AsyncApiConstants
136136
public const string RetentionBytes = "retention.bytes";
137137
public const string DeleteRetentionMiliseconds = "delete.retention.ms";
138138
public const string MaxMessageBytes = "max.message.bytes";
139+
public const string ConfluentKeySchemaValidation = "confluent.key.schema.validation";
140+
public const string ConfluentKeySubjectName = "confluent.key.subject.name.strategy";
141+
public const string ConfluentValueSchemaValidation = "confluent.value.schema.validation";
142+
public const string ConfluentValueSubjectName = "confluent.value.subject.name.strategy";
139143
public const string TopicConfiguration = "topicConfiguration";
140144
public const string GeoReplication = "geo-replication";
141145
public const string AdditionalItems = "additionalItems";

test/LEGO.AsyncAPI.Tests/Bindings/Kafka/KafkaBindings_Should.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public void KafkaChannelBinding_WithFilledObject_SerializesAndDeserializes()
3030
retention.ms: 1
3131
retention.bytes: 2
3232
delete.retention.ms: 3
33-
max.message.bytes: 4";
33+
max.message.bytes: 4
34+
confluent.key.schema.validation: true
35+
confluent.key.subject.name.strategy: TopicNameStrategy
36+
confluent.value.schema.validation: true
37+
confluent.value.subject.name.strategy: TopicNameStrategy";
3438

3539
var channel = new AsyncApiChannel();
3640
channel.Bindings.Add(new KafkaChannelBinding
@@ -45,6 +49,10 @@ public void KafkaChannelBinding_WithFilledObject_SerializesAndDeserializes()
4549
RetentionBytes = 2,
4650
DeleteRetentionMiliseconds = 3,
4751
MaxMessageBytes = 4,
52+
ConfluentKeySchemaValidation = true,
53+
ConfluentKeySubjectName = "TopicNameStrategy",
54+
ConfluentValueSchemaValidation = true,
55+
ConfluentValueSubjectName = "TopicNameStrategy",
4856
},
4957
});
5058

0 commit comments

Comments
 (0)