Skip to content
Alex Wichmann edited this page Jun 11, 2025 · 2 revisions

The AsyncApiReader is a component in the .NET library that can be used to deserialize AsyncAPI specifications from either JSON or YAML formats. The deserialized AsyncAPI document can then be manipulated in memory as a C# object.

Basic usage

To use any of the AsyncApiReaders, you first need to create an instance.

There are 3 types of readers, which all have the same API

  1. AsyncApiStringReader
  2. AsyncApiStreamReader
  3. AsyncApiTextReader

To use any of the AsyncApiReaders, you first need to create an instance.

varreader=newAsyncApiStringReader();vardoc=reader.Read(yaml,outvardiagnostic);

You can override default reader settings by passing in an AsyncApiReaderSettings object.

or overriding settings

varsettings=newAsyncApiReaderSettings();varreader=newAsyncApiStringReader(settings);

Diagnostics

When calling .Read() the reader will output any and all Diagnostics errors and warnings. These can be both from Serialization errors/warnings (if the specification is not proper json/yaml) or from validation errors/warnings

All diagnostic messages will contain a pointer to what failed, see example under ValidationRules

Clone this wiki locally