diff --git a/README.md b/README.md index 199a055c..fda302e2 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ Install the NuGet packages: [![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET?label=AsyncAPI.NET&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET/) [![Nuget](https://img.shields.io/nuget/vpre/AsyncAPI.NET?label=AsyncAPI.NET&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET/) -### AsyncAPI.NET.Readers -[![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET.Readers?label=AsyncAPI.NET.Readers&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Readers/) -[![Nuget](https://img.shields.io/nuget/vpre/AsyncAPI.NET.Readers?label=AsyncAPI.NET.Readers&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Readers/) +### AsyncAPI.Readers +[![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET.Readers?label=AsyncAPI.Readers&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Readers/) +[![Nuget](https://img.shields.io/nuget/vpre/AsyncAPI.NET.Readers?label=AsyncAPI.Readers&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Readers/) -### AsyncAPI.NET.Bindings -[![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET.Bindings?label=AsyncAPI.NET.Bindings&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Bindings/) +### AsyncAPI.Bindings +[![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET.Bindings?label=AsyncAPI.Bindings&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Bindings/) ## Example Usage @@ -78,6 +78,16 @@ var stream = await httpClient.GetStreamAsync("master/examples/streetlights-kafka var asyncApiDocument = new AsyncApiStreamReader().Read(stream, out var diagnostic); ``` +### Bindings +To add support for reading bindings, simply add the bindings you wish to support, to the `Bindings` collection of `AsyncApiReaderSettings`. +There is a nifty helper to add different types of bindings, or like in the example `All` of them. + +```csharp +var settings = new AsyncApiReaderSettings(); +settings.Bindings.Add(BindingsCollection.All); +var asyncApiDocument = new AsyncApiStringReader(settings).Read(stream, out var diagnostic); +``` + ## Attribution * [OpenAPI.Net](https://github.com/microsoft/OpenAPI.NET) - [MIT License](https://github.com/microsoft/OpenAPI.NET/blob/vnext/LICENSE) diff --git a/src/LEGO.AsyncAPI.Bindings/BindingsCollection.cs b/src/LEGO.AsyncAPI.Bindings/BindingsCollection.cs index 0a34ec39..b201a4dc 100644 --- a/src/LEGO.AsyncAPI.Bindings/BindingsCollection.cs +++ b/src/LEGO.AsyncAPI.Bindings/BindingsCollection.cs @@ -40,12 +40,13 @@ public static TCollection Add( Pulsar, Kafka, Http, + Websockets, }; public static IEnumerable> Http => new List> { new HttpOperationBinding(), - new HttpMessageBinding() + new HttpMessageBinding(), }; public static IEnumerable> Websockets => new List> @@ -63,7 +64,6 @@ public static TCollection Add( public static IEnumerable> Pulsar => new List> { - // Pulsar new PulsarServerBinding(), new PulsarChannelBinding(), }; diff --git a/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs b/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs index 01576991..47e7e1da 100644 --- a/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs +++ b/src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs @@ -43,7 +43,7 @@ public Dictionary> public List> Bindings - { get; } = + { get; set; } = new List>(); ///