Skip to content

Commit e8b2b6f

Browse files
committed
Merge branch 'main' into vnext
2 parents 19602c9 + c90f41d commit e8b2b6f

File tree

15 files changed

+358
-78
lines changed

15 files changed

+358
-78
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## [5.2.4](https://github.com/LEGO/AsyncAPI.NET/compare/v5.2.3...v5.2.4) (2024-07-29)
2+
3+
4+
### Bug Fixes
5+
6+
* remove persistence nullability ([52165f2](https://github.com/LEGO/AsyncAPI.NET/commit/52165f213502d9436e25a4e761804b5796b5de8c))
7+
8+
## [5.2.3](https://github.com/LEGO/AsyncAPI.NET/compare/v5.2.2...v5.2.3) (2024-07-29)
9+
10+
11+
### Bug Fixes
12+
13+
* add missing walk and visit methods for bindings. ([#191](https://github.com/LEGO/AsyncAPI.NET/issues/191)) ([b8307c5](https://github.com/LEGO/AsyncAPI.NET/commit/b8307c57a6f9bc7c546702c24dffdfb1833aa5d3))
14+
15+
## [5.2.2](https://github.com/LEGO/AsyncAPI.NET/compare/v5.2.1...v5.2.2) (2024-07-29)
16+
17+
18+
### Bug Fixes
19+
20+
* correct typing of exclusive maximums and minimums for draft7 jso… ([#188](https://github.com/LEGO/AsyncAPI.NET/issues/188)) ([fb50d00](https://github.com/LEGO/AsyncAPI.NET/commit/fb50d00192896f9ac26e65df1e991854b33aa17c))
21+
* resolving wrong reference ([#180](https://github.com/LEGO/AsyncAPI.NET/issues/180)) ([47685cd](https://github.com/LEGO/AsyncAPI.NET/commit/47685cd19c7e58391625be043b1e5d82c49eedc8))
22+
123
## [5.2.1](https://github.com/LEGO/AsyncAPI.NET/compare/v5.2.0...v5.2.1) (2024-06-12)
224

325

src/LEGO.AsyncAPI.Bindings/Pulsar/PulsarChannelBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class PulsarChannelBinding : ChannelBinding<PulsarChannelBinding>
1919
/// <summary>
2020
/// persistence of the topic in Pulsar persistent or non-persistent.
2121
/// </summary>
22-
public Persistence? Persistence { get; set; }
22+
public Persistence Persistence { get; set; }
2323

2424
/// <summary>
2525
/// Topic compaction threshold given in bytes.

src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public class AsyncApiSchemaDeserializer
6161
}
6262
},
6363
{
64-
"exclusiveMaximum", (a, n) => { a.ExclusiveMaximum = bool.Parse(n.GetScalarValue()); }
64+
"exclusiveMaximum", (a, n) =>
65+
{
66+
a.ExclusiveMaximum = double.Parse(n.GetScalarValue(), NumberStyles.Float, n.Context.Settings.CultureInfo);
67+
}
6568
},
6669
{
6770
"minimum",
@@ -71,7 +74,10 @@ public class AsyncApiSchemaDeserializer
7174
}
7275
},
7376
{
74-
"exclusiveMinimum", (a, n) => { a.ExclusiveMinimum = bool.Parse(n.GetScalarValue()); }
77+
"exclusiveMinimum", (a, n) =>
78+
{
79+
a.ExclusiveMinimum = double.Parse(n.GetScalarValue(), NumberStyles.Float, n.Context.Settings.CultureInfo);
80+
}
7581
},
7682
{
7783
"maxLength", (a, n) => { a.MaxLength = int.Parse(n.GetScalarValue(), n.Context.Settings.CultureInfo); }

src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs renamed to src/LEGO.AsyncAPI/Models/AsyncApiBindings{TBinding}.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,6 @@ namespace LEGO.AsyncAPI.Models
77
using LEGO.AsyncAPI.Models.Interfaces;
88
using LEGO.AsyncAPI.Writers;
99

10-
public static class BindingExtensions
11-
{
12-
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IServerBinding> bindings, out IServerBinding binding)
13-
where TBinding : IServerBinding
14-
{
15-
return bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out binding);
16-
}
17-
18-
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IChannelBinding> bindings, out IChannelBinding binding)
19-
where TBinding : IChannelBinding
20-
{
21-
return bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out binding);
22-
}
23-
24-
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IOperationBinding> bindings, out IOperationBinding binding)
25-
where TBinding : IOperationBinding
26-
{
27-
return bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out binding);
28-
}
29-
30-
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IMessageBinding> bindings, out IMessageBinding binding)
31-
where TBinding : IMessageBinding
32-
{
33-
return bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out binding);
34-
}
35-
}
36-
3710
public class AsyncApiBindings<TBinding> : Dictionary<string, TBinding>, IAsyncApiReferenceable
3811
where TBinding : IBinding
3912
{

src/LEGO.AsyncAPI/Models/AsyncApiSchema.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
4242
/// <summary>
4343
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
4444
/// </summary>
45-
public bool? ExclusiveMaximum { get; set; }
45+
public double? ExclusiveMaximum { get; set; }
4646

4747
/// <summary>
4848
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
@@ -52,7 +52,7 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
5252
/// <summary>
5353
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.
5454
/// </summary>
55-
public bool? ExclusiveMinimum { get; set; }
55+
public double? ExclusiveMinimum { get; set; }
5656

5757
/// <summary>
5858
/// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html.

src/LEGO.AsyncAPI/Models/AsyncApiSchemaPayload.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public AsyncApiJsonSchemaPayload(AsyncApiSchema schema)
3030

3131
public double? Maximum { get => this.schema.Maximum; set => this.schema.Maximum = value; }
3232

33-
public bool? ExclusiveMaximum { get => this.schema.ExclusiveMaximum; set => this.schema.ExclusiveMaximum = value; }
33+
public double? ExclusiveMaximum { get => this.schema.ExclusiveMaximum; set => this.schema.ExclusiveMaximum = value; }
3434

3535
public double? Minimum { get => this.schema.Minimum; set => this.schema.Minimum = value; }
3636

37-
public bool? ExclusiveMinimum { get => this.schema.ExclusiveMinimum; set => this.schema.ExclusiveMinimum = value; }
37+
public double? ExclusiveMinimum { get => this.schema.ExclusiveMinimum; set => this.schema.ExclusiveMinimum = value; }
3838

3939
public int? MaxLength { get => this.schema.MaxLength; set => this.schema.MaxLength = value; }
4040

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) The LEGO Group. All rights reserved.
2+
3+
namespace LEGO.AsyncAPI.Models
4+
{
5+
using System;
6+
using LEGO.AsyncAPI.Models.Interfaces;
7+
8+
public static class BindingExtensions
9+
{
10+
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IServerBinding> bindings, out TBinding binding)
11+
where TBinding : class, IServerBinding
12+
{
13+
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var serverBinding))
14+
{
15+
binding = serverBinding as TBinding;
16+
return true;
17+
}
18+
19+
binding = default;
20+
return false;
21+
}
22+
23+
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IChannelBinding> bindings, out TBinding binding)
24+
where TBinding : class, IChannelBinding
25+
{
26+
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var channelBinding))
27+
{
28+
binding = channelBinding as TBinding;
29+
return true;
30+
}
31+
32+
binding = default;
33+
return false;
34+
}
35+
36+
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IOperationBinding> bindings, out TBinding binding)
37+
where TBinding : class, IOperationBinding
38+
{
39+
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var operationBinding))
40+
{
41+
binding = operationBinding as TBinding;
42+
return true;
43+
}
44+
45+
binding = default;
46+
return false;
47+
}
48+
49+
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IMessageBinding> bindings, out TBinding binding)
50+
where TBinding : class, IMessageBinding
51+
{
52+
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var messageBinding))
53+
{
54+
binding = messageBinding as TBinding;
55+
return true;
56+
}
57+
58+
binding = default;
59+
return false;
60+
}
61+
}
62+
}

src/LEGO.AsyncAPI/Services/AsyncApiVisitorBase.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,38 @@ public virtual void Visit(IDictionary<string, AsyncApiChannel> channels)
246246
{
247247
}
248248

249+
public virtual void Visit(AsyncApiBindings<IServerBinding> bindings)
250+
{
251+
}
252+
253+
public virtual void Visit(IServerBinding binding)
254+
{
255+
}
256+
257+
public virtual void Visit(AsyncApiBindings<IChannelBinding> bindings)
258+
{
259+
}
260+
261+
public virtual void Visit(IChannelBinding binding)
262+
{
263+
}
264+
265+
public virtual void Visit(AsyncApiBindings<IOperationBinding> bindings)
266+
{
267+
}
268+
269+
public virtual void Visit(IOperationBinding binding)
270+
{
271+
}
272+
273+
public virtual void Visit(AsyncApiBindings<IMessageBinding> bindings)
274+
{
275+
}
276+
277+
public virtual void Visit(IMessageBinding binding)
278+
{
279+
}
280+
249281
public virtual void Visit(AsyncApiChannel channel)
250282
{
251283
}

src/LEGO.AsyncAPI/Services/AsyncApiWalker.cs

Lines changed: 118 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,48 @@ internal void Walk(AsyncApiComponents components)
7474
});
7575

7676
this.Walk(AsyncApiConstants.ServerBindings, () =>
77-
{
78-
if (components.ServerBindings != null)
79-
{
80-
foreach (var item in components.ServerBindings)
81-
{
82-
this.Walk(item.Key, () => this.Walk(item.Value, isComponent: true));
83-
}
84-
}
85-
});
77+
{
78+
if (components.ServerBindings != null)
79+
{
80+
foreach (var item in components.ServerBindings)
81+
{
82+
this.Walk(item.Key, () => this.Walk(item.Value, isComponent: true));
83+
}
84+
}
85+
});
86+
87+
this.Walk(AsyncApiConstants.ChannelBindings, () =>
88+
{
89+
if (components.ChannelBindings != null)
90+
{
91+
foreach (var item in components.ChannelBindings)
92+
{
93+
this.Walk(item.Key, () => this.Walk(item.Value, isComponent: true));
94+
}
95+
}
96+
});
97+
98+
this.Walk(AsyncApiConstants.OperationBindings, () =>
99+
{
100+
if (components.OperationBindings != null)
101+
{
102+
foreach (var item in components.OperationBindings)
103+
{
104+
this.Walk(item.Key, () => this.Walk(item.Value, isComponent: true));
105+
}
106+
}
107+
});
108+
109+
this.Walk(AsyncApiConstants.MessageBindings, () =>
110+
{
111+
if (components.MessageBindings != null)
112+
{
113+
foreach (var item in components.MessageBindings)
114+
{
115+
this.Walk(item.Key, () => this.Walk(item.Value, isComponent: true));
116+
}
117+
}
118+
});
86119

87120
this.Walk(AsyncApiConstants.Parameters, () =>
88121
{
@@ -567,6 +600,25 @@ internal void Walk(AsyncApiBindings<IServerBinding> serverBindings, bool isCompo
567600
}
568601

569602
this.visitor.Visit(serverBindings);
603+
if (serverBindings != null)
604+
{
605+
foreach (var binding in serverBindings)
606+
{
607+
this.visitor.CurrentKeys.ServerBinding = binding.Key;
608+
this.Walk(binding.Key, () => this.Walk(binding.Value));
609+
this.visitor.CurrentKeys.ServerBinding = null;
610+
}
611+
}
612+
}
613+
614+
internal void Walk(IServerBinding binding)
615+
{
616+
if (binding == null)
617+
{
618+
return;
619+
}
620+
621+
this.visitor.Visit(binding);
570622
}
571623

572624
internal void Walk(AsyncApiBindings<IChannelBinding> channelBindings, bool isComponent = false)
@@ -577,6 +629,25 @@ internal void Walk(AsyncApiBindings<IChannelBinding> channelBindings, bool isCom
577629
}
578630

579631
this.visitor.Visit(channelBindings);
632+
if (channelBindings != null)
633+
{
634+
foreach (var binding in channelBindings)
635+
{
636+
this.visitor.CurrentKeys.ChannelBinding = binding.Key;
637+
this.Walk(binding.Key, () => this.Walk(binding.Value));
638+
this.visitor.CurrentKeys.ChannelBinding = null;
639+
}
640+
}
641+
}
642+
643+
internal void Walk(IChannelBinding binding)
644+
{
645+
if (binding == null)
646+
{
647+
return;
648+
}
649+
650+
this.visitor.Visit(binding);
580651
}
581652

582653
internal void Walk(AsyncApiBindings<IOperationBinding> operationBindings, bool isComponent = false)
@@ -587,6 +658,25 @@ internal void Walk(AsyncApiBindings<IOperationBinding> operationBindings, bool i
587658
}
588659

589660
this.visitor.Visit(operationBindings);
661+
if (operationBindings != null)
662+
{
663+
foreach (var binding in operationBindings)
664+
{
665+
this.visitor.CurrentKeys.OperationBinding = binding.Key;
666+
this.Walk(binding.Key, () => this.Walk(binding.Value));
667+
this.visitor.CurrentKeys.OperationBinding = null;
668+
}
669+
}
670+
}
671+
672+
internal void Walk(IOperationBinding binding)
673+
{
674+
if (binding == null)
675+
{
676+
return;
677+
}
678+
679+
this.visitor.Visit(binding);
590680
}
591681

592682
internal void Walk(AsyncApiBindings<IMessageBinding> messageBindings, bool isComponent = false)
@@ -597,6 +687,25 @@ internal void Walk(AsyncApiBindings<IMessageBinding> messageBindings, bool isCom
597687
}
598688

599689
this.visitor.Visit(messageBindings);
690+
if (messageBindings != null)
691+
{
692+
foreach (var binding in messageBindings)
693+
{
694+
this.visitor.CurrentKeys.MessageBinding = binding.Key;
695+
this.Walk(binding.Key, () => this.Walk(binding.Value));
696+
this.visitor.CurrentKeys.MessageBinding = null;
697+
}
698+
}
699+
}
700+
701+
internal void Walk(IMessageBinding binding)
702+
{
703+
if (binding == null)
704+
{
705+
return;
706+
}
707+
708+
this.visitor.Visit(binding);
600709
}
601710

602711
internal void Walk(IList<AsyncApiMessageExample> examples)

0 commit comments

Comments
 (0)