Skip to content

Latest commit

 

History

History
79 lines (53 loc) · 3.18 KB

README.md

File metadata and controls

79 lines (53 loc) · 3.18 KB

AsyncAPI.NET

Build & Test

AsyncAPI.NET provides a .NET object model for AsyncAPI documents, JSON/YAML readers and writers, and protocol bindings.

It supports AsyncAPI 2.x and 3.x. V2 documents are upgraded to the V3-shaped model when read and can be written back as V2. Serialization currently emits 2.6 or 3.1.0; the V3 selector is still named AsyncApiVersion.AsyncApi3_0.

See the documentation site for guides and examples, or the changelog for release notes.

Install

Install the core model and serializers, plus the readers for JSON/YAML input:

dotnet add package ByteBard.AsyncAPI.NET
dotnet add package ByteBard.AsyncAPI.NET.Readers

For protocol bindings, also install:

dotnet add package ByteBard.AsyncAPI.NET.Bindings

Binding readers require explicit registration; see protocol bindings.

Quick start

Parse YAML, check diagnostics, and write JSON (C# 11 or later):

using System;
using ByteBard.AsyncAPI;
using ByteBard.AsyncAPI.Models;
using ByteBard.AsyncAPI.Readers;

var source = """
asyncapi: 3.1.0
info:
  title: Example API
  version: 1.0.0
channels: {}
""";

var document = new AsyncApiStringReader().Read(source, out var diagnostics);

foreach (var error in diagnostics.Errors)
    Console.Error.WriteLine($"Error at {error.Pointer}: {error.Message}");
foreach (var warning in diagnostics.Warnings)
    Console.Error.WriteLine($"Warning at {warning.Pointer}: {warning.Message}");

if (diagnostics.Errors.Count > 0)
    return;

Console.WriteLine(document.SerializeAsJson(AsyncApiVersion.AsyncApi3_0));

Documentation

Contributing

Contributions and suggestions are welcome. See CONTRIBUTING.md and the documentation development instructions.

Attribution

License

Apache 2.0