Skip to content

Commit 974503f

Browse files
authored
Makes AMQP binding properties required (#17)
Updates AMQP operation binding properties to be required. Removes nullable types and adjusts the fixed field map and writer to reflect these changes.
1 parent ccd6ff3 commit 974503f

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

src/ByteBard.AsyncAPI.Bindings/AMQP/AMQPOperationBinding.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class AMQPOperationBinding : OperationBinding<AMQPOperationBinding>
1414
/// <summary>
1515
/// TTL (Time-To-Live) for the message. It MUST be greater than or equal to zero.
1616
/// </summary>
17-
public uint? Expiration { get; set; }
17+
public uint Expiration { get; set; }
1818

1919
/// <summary>
2020
/// Identifies the user who has sent the message.
@@ -29,17 +29,17 @@ public class AMQPOperationBinding : OperationBinding<AMQPOperationBinding>
2929
/// <summary>
3030
/// A priority for the message.
3131
/// </summary>
32-
public int? Priority { get; set; }
32+
public int Priority { get; set; }
3333

3434
/// <summary>
3535
/// Delivery mode of the message. Its value MUST be either 1 (transient) or 2 (persistent).
3636
/// </summary>
37-
public DeliveryMode? DeliveryMode { get; set; }
37+
public DeliveryMode DeliveryMode { get; set; }
3838

3939
/// <summary>
4040
/// Whether the message is mandatory or not.
4141
/// </summary>
42-
public bool? Mandatory { get; set; }
42+
public bool Mandatory { get; set; }
4343

4444
/// <summary>
4545
/// Like cc but consumers will not receive this information.
@@ -49,27 +49,27 @@ public class AMQPOperationBinding : OperationBinding<AMQPOperationBinding>
4949
/// <summary>
5050
/// Whether the message should include a timestamp or not.
5151
/// </summary>
52-
public bool? Timestamp { get; set; }
52+
public bool Timestamp { get; set; }
5353

5454
/// <summary>
5555
/// Whether the consumer should ack the message or not.
5656
/// </summary>
57-
public bool? Ack { get; set; }
57+
public bool Ack { get; set; }
5858

5959
public override string BindingKey => "amqp";
6060

6161
protected override FixedFieldMap<AMQPOperationBinding> FixedFieldMap => new()
6262
{
6363
{ "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } },
64-
{ "expiration", (a, n) => { a.Expiration = (uint?)n.GetIntegerValueOrDefault(); } },
64+
{ "expiration", (a, n) => { a.Expiration = (uint)n.GetIntegerValue(); } },
6565
{ "userId", (a, n) => { a.UserId = n.GetScalarValueOrDefault(); } },
6666
{ "cc", (a, n) => { a.Cc = n.CreateSimpleList(s => s.GetScalarValue()); } },
67-
{ "priority", (a, n) => { a.Priority = n.GetIntegerValueOrDefault(); } },
68-
{ "deliveryMode", (a, n) => { a.DeliveryMode = (DeliveryMode?)n.GetIntegerValueOrDefault(); } },
69-
{ "mandatory", (a, n) => { a.Mandatory = n.GetBooleanValueOrDefault(); } },
67+
{ "priority", (a, n) => { a.Priority = n.GetIntegerValue(); } },
68+
{ "deliveryMode", (a, n) => { a.DeliveryMode = (DeliveryMode)n.GetIntegerValue(); } },
69+
{ "mandatory", (a, n) => { a.Mandatory = n.GetBooleanValue(); } },
7070
{ "bcc", (a, n) => { a.Bcc = n.CreateSimpleList(s => s.GetScalarValue()); } },
71-
{ "timestamp", (a, n) => { a.Timestamp = n.GetBooleanValueOrDefault(); } },
72-
{ "ack", (a, n) => { a.Ack = n.GetBooleanValueOrDefault(); } },
71+
{ "timestamp", (a, n) => { a.Timestamp = n.GetBooleanValue(); } },
72+
{ "ack", (a, n) => { a.Ack = n.GetBooleanValue(); } },
7373
};
7474

7575
/// <summary>
@@ -83,15 +83,15 @@ public override void SerializeProperties(IAsyncApiWriter writer)
8383
}
8484

8585
writer.WriteStartObject();
86-
writer.WriteOptionalProperty<int>("expiration", (int)this.Expiration);
87-
writer.WriteOptionalProperty("userId", this.UserId);
86+
writer.WriteRequiredProperty<int>("expiration", (int)this.Expiration);
87+
writer.WriteRequiredProperty("userId", this.UserId);
8888
writer.WriteOptionalCollection("cc", this.Cc, (w, s) => w.WriteValue(s));
89-
writer.WriteOptionalProperty("priority", this.Priority);
90-
writer.WriteOptionalProperty("deliveryMode", (int?)this.DeliveryMode);
91-
writer.WriteOptionalProperty("mandatory", this.Mandatory);
89+
writer.WriteRequiredProperty("priority", this.Priority);
90+
writer.WriteRequiredProperty("deliveryMode", (int)this.DeliveryMode);
91+
writer.WriteRequiredProperty("mandatory", this.Mandatory);
9292
writer.WriteOptionalCollection("bcc", this.Bcc, (w, s) => w.WriteValue(s));
93-
writer.WriteOptionalProperty("timestamp", this.Timestamp);
94-
writer.WriteOptionalProperty("ack", this.Ack);
93+
writer.WriteRequiredProperty("timestamp", this.Timestamp);
94+
writer.WriteRequiredProperty("ack", this.Ack);
9595
writer.WriteOptionalProperty(AsyncApiConstants.BindingVersion, this.BindingVersion);
9696
writer.WriteExtensions(this.Extensions);
9797
writer.WriteEndObject();

0 commit comments

Comments
 (0)