forked from LEGO/AsyncAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (27 loc) · 1.04 KB
/
Copy pathProgram.cs
File metadata and controls
32 lines (27 loc) · 1.04 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
namespace LEGO.AsyncAPI.Writers.Example
{
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Readers;
public class Program
{
static async Task Main()
{
var stream = typeof(Program).Assembly.GetManifestResourceStream(typeof(Program).Assembly
.GetManifestResourceNames().First(x => x.EndsWith("CompleteKafkaSpec.json")));
var completeKafkaSpecJson = await new StreamReader(stream).ReadToEndAsync();
var asyncApiDocument = new AsyncApiStringReader().Read(completeKafkaSpecJson, out var readDiagnostic);
var serializedAsyncApiDocument = new AsyncApiStringWriter().Write(asyncApiDocument, out var writeDiagnostic);
if (writeDiagnostic.HasError)
{
Console.WriteLine($"Error during writing AsyncApiDocument to JSON: {writeDiagnostic.Error}");
}
else
{
Console.Write(serializedAsyncApiDocument);
}
}
}
}