-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2053e9
commit 799cf93
Showing
10 changed files
with
203 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ namespace LEGO.AsyncAPI.Models | |
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
using System.Collections.Generic; | ||
Check warning on line 7 in src/LEGO.AsyncAPI/Models/Avro/AvroField.cs GitHub Actions / build (macos-latest)
|
||
using System.Linq; | ||
|
||
/// <summary> | ||
/// Represents a field within an Avro record schema. | ||
|
@@ -41,6 +42,11 @@ public class AvroField : IAsyncApiSerializable | |
/// </summary> | ||
public IList<string> Aliases { get; set; } = new List<string>(); | ||
|
||
/// <summary> | ||
/// A map of properties not in the schema, but added as additional metadata. | ||
/// </summary> | ||
public IDictionary<string, AvroSchema> Metadata { get; set; } = new Dictionary<string, AvroSchema>(); | ||
|
||
public void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
|
@@ -50,6 +56,21 @@ public void SerializeV2(IAsyncApiWriter writer) | |
writer.WriteOptionalObject("default", this.Default, (w, s) => w.WriteAny(s)); | ||
writer.WriteOptionalProperty("order", this.Order); | ||
writer.WriteOptionalCollection("aliases", this.Aliases, (w, s) => w.WriteValue(s)); | ||
if (this.Metadata.Any()) | ||
{ | ||
foreach (var item in this.Metadata) | ||
{ | ||
writer.WritePropertyName(item.Key); | ||
if (item.Value == null) | ||
{ | ||
writer.WriteNull(); | ||
} | ||
else | ||
{ | ||
item.Value.SerializeV2(writer); | ||
} | ||
} | ||
} | ||
writer.WriteEndObject(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.