Skip to content
Alex Wichmann edited this page Feb 23, 2023 · 3 revisions

The AsyncAPI.NET library is a document object model (DOM) for an AsyncAPI description document. It provides a set of classes for constructing semantically valid AsyncAPI specifications. The library also includes a writer for serializing the DOM into JSON or YAML AsyncAPI specifications

Getting started

varmyFirstAsyncApi=newAsyncApiDocument{Info=newAsyncApiInfo{Title="my first asyncapi"},Channels=newDictionary<string,AsyncApiChannel>{{"users",newAsyncApiChannel{Subscribe=newAsyncApiOperation{OperationId="users",Description="my users channel"}}}}};varyaml=myFirstAsyncApi.SerializeAsYaml();//asyncapi: '2.6.0'// info:// title: my first asyncapi// channels:// users:// subscribe:// operationId: users// description: my users channel

Reading

varhttpClient=newHttpClient{BaseAddress=newUri("https://raw.githubusercontent.com/asyncapi/spec/"),};varstream=awaithttpClient.GetStreamAsync("master/examples/streetlights-kafka.yml");varasyncApiDocument=newAsyncApiStreamReader().Read(stream,outvardiagnostic);

You can read more about more advanced ways to of reading or writing in the Wiki

Clone this wiki locally