AsyncAPI.NET.Readers
6.0.0-beta.109
dotnet add package AsyncAPI.NET.Readers --version 6.0.0-beta.109
NuGet\Install-Package AsyncAPI.NET.Readers -Version 6.0.0-beta.109
<PackageReference Include="AsyncAPI.NET.Readers" Version="6.0.0-beta.109" />
paket add AsyncAPI.NET.Readers --version 6.0.0-beta.109
#r "nuget: AsyncAPI.NET.Readers, 6.0.0-beta.109"
// Install AsyncAPI.NET.Readers as a Cake Addin #addin nuget:?package=AsyncAPI.NET.Readers&version=6.0.0-beta.109&prerelease // Install AsyncAPI.NET.Readers as a Cake Tool #tool nuget:?package=AsyncAPI.NET.Readers&version=6.0.0-beta.109&prerelease
AsyncAPI.NET
The AsyncAPI.NET SDK contains a useful object model for the AsyncAPI specification in .NET along with common serializers to extract raw AsyncAPI JSON and YAML documents from the model as well.
CHANGELOG
Wiki and getting started guide
Installation
Install the NuGet packages:
AsyncAPI.NET
AsyncAPI.Readers
AsyncAPI.Bindings
Example Usage
Main classes to know:
- AsyncApiStringReader
- AsyncApiStringWriter
- There is an extension on the AsyncApiDocument type which allows Serializing as well (
new AsyncApiDocument().SerializeAsJson()
ornew AsyncApiDocument().SerializeAsYaml()
- There is an extension on the AsyncApiDocument type which allows Serializing as well (
Writing
var myFirstAsyncApi = new AsyncApiDocument
{
Info = new AsyncApiInfo
{
Title = "my first asyncapi",
},
Channels = new Dictionary<string, AsyncApiChannel>
{
{
"users", new AsyncApiChannel
{
Subscribe = new AsyncApiOperation
{
OperationId = "users",
Description = "my users channel",
Message = new List<AsyncApiMessage>
{
new AsyncApiMessageReference("#/components/messages/MyMessage"),
},
},
}
},
},
Components = new AsyncApiComponents
{
Messages = new Dictionary<string, AsyncApiMessage>
{
{
"MyMessage", new AsyncApiMessage
{
Name = "Hello!",
}
},
},
},
};
var yaml = myFirstAsyncApi.SerializeAsYaml(AsyncApi);
//asyncapi: 2.6.0
// info:
// title: my first asyncapi
//channels:
// users:
// subscribe:
// operationId: users
// description: my users channel
// message:
// $ref: '#/components/messages/MyMessage'
//components:
// messages:
// MyMessage:
// name: Hello!
Reading
There are 3 reader types
- AsyncApiStringReader
- AsyncApiTextReader
- AsyncApiStreamReader
All 3 supports both json and yaml.
StreamReader
var httpClient = new HttpClient
{
BaseAddress = new Uri("https://raw.githubusercontent.com/asyncapi/spec/"),
};
var stream = await httpClient.GetStreamAsync("master/examples/streetlights-kafka.yml");
var asyncApiDocument = new AsyncApiStreamReader().Read(stream, out var diagnostic);
StringReader
var yaml =
"""
asyncapi: 2.6.0
info:
title: my first asyncapi
channels:
users:
subscribe:
operationId: users
description: my users channel
message:
$ref: '#/components/messages/MyMessage'
components:
messages:
MyMessage:
name: Hello!
""";
var asyncApiDocument = new AsyncApiStringReader().Read(yaml, out var diagnostic);
All readers will write warnings and errors to the diagnostics.
Reference Resolution
Internal references are resolved by default. This includes component and non-component references e.g #/components/messages/MyMessage
and #/servers/0
.
External references can be resolved by setting ReferenceResolution
to ResolveAllReferences
.
The default implementation will resolve anything prefixed with file://
, http://
& https://
, however a custom implementation can be made, by inhereting from the IStreamLoader
interface and setting the ExternalReferenceLoader
in the AsyncApiReaderSettings
.
External references are always force converted to Json during resolution. This means that both yaml and json is supported - but not other serialization languages.
var settings = new AsyncApiReaderSettings { ReferenceResolution = ReferenceResolution.ResolveAllReferences };
var document = new AsyncApiStringReader(settings).Read(json, out var diagnostics);
Reference resolution can be disabled by setting ReferenceResolution
to DoNotResolveReferences
.
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.
var settings = new AsyncApiReaderSettings();
settings.Bindings = BindingsCollection.All;
var asyncApiDocument = new AsyncApiStringReader(settings).Read(yaml, out var diagnostic);
Attribution
Contribution
This project welcomes contributions and suggestions. Do you want to contribute to the project? Find out how here.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- AsyncAPI.NET (>= 6.0.0-beta.109)
- JsonPointer.Net (>= 5.3.0)
- System.Text.Json (>= 9.0.1)
- YamlDotNet (>= 13.0.1)
-
net8.0
- AsyncAPI.NET (>= 6.0.0-beta.109)
- JsonPointer.Net (>= 5.3.0)
- System.Text.Json (>= 9.0.1)
- YamlDotNet (>= 13.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AsyncAPI.NET.Readers:
Package | Downloads |
---|---|
AsyncAPI.NET.Bindings
AsyncAPI.NET Bindings |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.0.0-beta.109 | 32 | 1/31/2025 |
6.0.0-beta.108 | 36 | 1/31/2025 |
6.0.0-beta.107 | 38 | 1/27/2025 |
6.0.0-beta.106 | 28 | 1/27/2025 |
6.0.0-beta.105 | 28 | 1/23/2025 |
6.0.0-beta.104 | 178 | 1/10/2025 |
6.0.0-beta.99 | 618 | 10/25/2024 |
6.0.0-beta.98 | 62 | 10/14/2024 |
6.0.0-beta.97 | 859 | 9/4/2024 |
6.0.0-beta.96 | 88 | 8/22/2024 |
6.0.0-beta.95 | 129 | 8/16/2024 |
6.0.0-beta.94 | 73 | 8/12/2024 |
6.0.0-beta.93 | 78 | 8/8/2024 |
6.0.0-beta.92 | 79 | 7/4/2024 |
6.0.0-beta.91 | 66 | 6/14/2024 |
6.0.0-beta.1 | 15 | 1/9/2025 |
5.2.4 | 15,813 | 7/29/2024 |
5.2.3 | 93 | 7/29/2024 |
5.2.2 | 94 | 7/29/2024 |
5.2.2-beta.87 | 63 | 6/14/2024 |
5.2.1 | 2,508 | 6/12/2024 |
5.2.1-beta.86 | 57 | 5/28/2024 |
5.2.1-beta.85 | 57 | 5/28/2024 |
5.2.1-beta.84 | 919 | 5/21/2024 |
5.2.0 | 5,608 | 3/30/2024 |
5.2.0-beta.83 | 70 | 3/30/2024 |
5.2.0-beta.82 | 65 | 3/30/2024 |
5.2.0-beta.81 | 79 | 3/30/2024 |
5.2.0-beta.80 | 75 | 3/26/2024 |
5.2.0-beta.79 | 74 | 3/26/2024 |
5.2.0-beta.78 | 73 | 3/26/2024 |
5.2.0-beta.77 | 69 | 3/26/2024 |
5.2.0-beta.76 | 70 | 3/25/2024 |
5.2.0-beta.75 | 65 | 3/14/2024 |
5.2.0-beta.74 | 71 | 2/27/2024 |
5.2.0-beta.73 | 872 | 2/26/2024 |
5.2.0-beta.72 | 68 | 2/26/2024 |
5.2.0-beta.71 | 65 | 2/26/2024 |
5.1.1 | 1,449 | 2/16/2024 |
5.1.1-beta.69 | 72 | 2/16/2024 |
5.1.0 | 185 | 2/15/2024 |
5.1.0-beta | 138 | 2/13/2024 |
5.0.0 | 1,766 | 12/14/2023 |
4.2.0-beta | 900 | 11/1/2023 |
4.1.0 | 18,252 | 9/27/2023 |
4.1.0-beta | 850 | 9/25/2023 |
4.0.2 | 20,485 | 8/1/2023 |
4.0.2-beta | 177 | 7/30/2023 |
4.0.1 | 817 | 7/11/2023 |
4.0.1-beta | 324 | 6/29/2023 |
4.0.0 | 885 | 6/12/2023 |
4.0.0-beta | 573 | 6/5/2023 |
3.0.2 | 942 | 3/30/2023 |
3.0.1 | 2,572 | 3/13/2023 |
2.0.2 | 269 | 2/22/2023 |
2.0.1 | 1,629 | 2/8/2023 |
2.0.0 | 279 | 2/8/2023 |