-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathKafkaServerBinding.cs
More file actions
57 lines (49 loc) · 2.11 KB
/
KafkaServerBinding.cs
File metadata and controls
57 lines (49 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace ByteBard.AsyncAPI.Bindings.Kafka
{
using System;
using ByteBard.AsyncAPI.Models;
using ByteBard.AsyncAPI.Readers.ParseNodes;
using ByteBard.AsyncAPI.Writers;
/// <summary>
/// Binding class for Kafka server settings.
/// </summary>
public class KafkaServerBinding : ServerBinding<KafkaServerBinding>
{
/// <summary>
/// API URL for the Schema Registry used when producing Kafka messages (if a Schema Registry was used).
/// </summary>
public string SchemaRegistryUrl { get; set; }
/// <summary>
/// The vendor of Schema Registry and Kafka serdes library that should be used (e.g. apicurio, confluent, ibm, or karapace).
/// </summary>
public string SchemaRegistryVendor { get; set; }
public override string BindingKey => "kafka";
protected override FixedFieldMap<KafkaServerBinding> FixedFieldMap => new()
{
{ "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } },
{ "schemaRegistryUrl", (a, n) => { a.SchemaRegistryUrl = n.GetScalarValue(); } },
{ "schemaRegistryVendor", (a, n) => { a.SchemaRegistryVendor = n.GetScalarValue(); } },
};
public override void SerializeV2(IAsyncApiWriter writer)
{
this.SerializeV3(writer);
}
public override void SerializeV3(IAsyncApiWriter writer)
{
this.SerializeProperties(writer);
}
public override void SerializeProperties(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}
writer.WriteStartObject();
writer.WriteOptionalProperty(AsyncApiConstants.SchemaRegistryUrl, this.SchemaRegistryUrl);
writer.WriteOptionalProperty(AsyncApiConstants.SchemaRegistryVendor, this.SchemaRegistryVendor);
writer.WriteOptionalProperty(AsyncApiConstants.BindingVersion, this.BindingVersion);
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}