forked from ByteBardOrg/AsyncAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (32 loc) · 1.24 KB
/
Program.cs
File metadata and controls
37 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace ByteBard.AsyncAPI.Readers.YamlExample
{
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using ByteBard.AsyncAPI.Readers;
public class Program
{
static async Task Main()
{
var httpClient = new HttpClient
{
BaseAddress = new Uri("https://raw.githubusercontent.com/asyncapi/spec/"),
};
var stream = await httpClient.GetStreamAsync("master/examples/streetlights-kafka.yml");
var streetlightKafkaSpec = await new StreamReader(stream, Encoding.UTF8).ReadToEndAsync();
var asyncApiDocument = new AsyncApiStringReader().Read(streetlightKafkaSpec, out var diagnostic);
if (diagnostic.HasError)
{
Console.WriteLine($"Error during spec parsing: {diagnostic.Error}");
}
else
{
Console.WriteLine("Kafka Starlight YAML spec successfully parsed into AsyncApiDocument object");
Console.WriteLine($"Api version: {asyncApiDocument.Asyncapi}");
Console.WriteLine($"Number of channels: {asyncApiDocument.Channels.Count}");
}
}
}
}