Skip to content

Commit

Permalink
fix: add setter to BindingParsers collection
Browse files Browse the repository at this point in the history
to be able to set during initialization, a setter was added to the Bindings property.
  • Loading branch information
VisualBean committed Jun 7, 2023
1 parent 0c9eab7 commit 211646e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/LEGO.AsyncAPI.Bindings/BindingsCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ public static TCollection Add<TCollection, TItem>(
Pulsar,
Kafka,
Http,
Websockets,
};

public static IEnumerable<IBindingParser<IBinding>> Http => new List<IBindingParser<IBinding>>
{
new HttpOperationBinding(),
new HttpMessageBinding()
new HttpMessageBinding(),
};

public static IEnumerable<IBindingParser<IBinding>> Websockets => new List<IBindingParser<IBinding>>
Expand All @@ -63,7 +64,6 @@ public static TCollection Add<TCollection, TItem>(

public static IEnumerable<IBindingParser<IBinding>> Pulsar => new List<IBindingParser<IBinding>>
{
// Pulsar
new PulsarServerBinding(),
new PulsarChannelBinding(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Readers/AsyncApiReaderSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Dictionary<string, Func<IAsyncApiAny, IAsyncApiExtension>>

public List<IBindingParser<IBinding>>
Bindings
{ get; } =
{ get; set; } =
new List<IBindingParser<IBinding>>();

/// <summary>
Expand Down

0 comments on commit 211646e

Please sign in to comment.