Repository navigation
Expand file tree
/
Copy pathAvroArray.cs
More file actions
47 lines (41 loc) · 1.44 KB
/
Copy pathAvroArray.cs
File metadata and controls
47 lines (41 loc) · 1.44 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
38
39
40
41
42
43
44
45
46
47
// Copyright (c) The LEGO Group. All rights reserved.
namespace LEGO.AsyncAPI.Models
{
using System.Collections.Generic;
using System.Linq;
using LEGO.AsyncAPI.Writers;
public class AvroArray : AvroSchema
{
public override string Type { get; } = "array";
/// <summary>
/// The schema of the array's items.
/// </summary>
public AvroSchema Items { get; set; }
/// <summary>
/// A map of properties not in the schema, but added as additional metadata.
/// </summary>
public override IDictionary<string, AsyncApiAny> Metadata { get; set; } = new Dictionary<string, AsyncApiAny>();
public override void SerializeV2WithoutReference(IAsyncApiWriter writer)
{
writer.WriteStartObject();
writer.WriteOptionalProperty("type", this.Type);
writer.WriteRequiredObject("items", this.Items, (w, f) => f.SerializeV2(w));
if (this.Metadata.Any())
{
foreach (var item in this.Metadata)
{
writer.WritePropertyName(item.Key);
if (item.Value == null)
{
writer.WriteNull();
}
else
{
writer.WriteAny(item.Value);
}
}
}
writer.WriteEndObject();
}
}
}