diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs b/src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs
index 786d9cd3..141916d7 100644
--- a/src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs
+++ b/src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs
@@ -10,11 +10,6 @@ public class AsyncApiAvroSchemaPayload : IAsyncApiMessagePayload
{
private AvroSchema schema;
- public AsyncApiAvroSchemaPayload()
- {
- this.schema = new AvroSchema();
- }
-
public AsyncApiAvroSchemaPayload(AvroSchema schema)
{
this.schema = schema;
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroArray.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroArray.cs
index 65f2cddd..9306c7d9 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroArray.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroArray.cs
@@ -2,6 +2,8 @@
namespace LEGO.AsyncAPI.Models
{
+ using System.Collections.Generic;
+ using System.Linq;
using LEGO.AsyncAPI.Writers;
public class AvroArray : AvroSchema
@@ -10,11 +12,31 @@ public class AvroArray : AvroSchema
public AvroSchema Items { get; set; }
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
+
public override void SerializeV2(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
+ {
+ item.Value.SerializeV2(writer);
+ }
+ }
+ }
writer.WriteEndObject();
}
}
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroEnum.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroEnum.cs
index ae474e4f..92b02ad3 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroEnum.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroEnum.cs
@@ -3,6 +3,7 @@
namespace LEGO.AsyncAPI.Models
{
using System.Collections.Generic;
+ using System.Linq;
using LEGO.AsyncAPI.Writers;
public class AvroEnum : AvroSchema
@@ -10,7 +11,7 @@ public class AvroEnum : AvroSchema
public string Type { get; } = "enum";
public string Name { get; set; }
-
+
public string Namespace { get; set; }
public string Doc { get; set; }
@@ -21,16 +22,36 @@ public class AvroEnum : AvroSchema
public string Default { get; set; }
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
+
public override void SerializeV2(IAsyncApiWriter writer)
{
writer.WriteStartObject();
writer.WriteOptionalProperty("type", this.Type);
writer.WriteRequiredProperty("name", this.Name);
- writer.WriteRequiredProperty("namespace", this.Namespace);
+ writer.WriteOptionalProperty("namespace", this.Namespace);
writer.WriteOptionalCollection("aliases", this.Aliases, (w, s) => w.WriteValue(s));
writer.WriteOptionalProperty("doc", this.Doc);
writer.WriteRequiredCollection("symbols", this.Symbols, (w, s) => w.WriteValue(s));
writer.WriteRequiredProperty("default", this.Default);
+ 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();
}
}
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroField.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroField.cs
index 89be453b..5ce87047 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroField.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroField.cs
@@ -5,6 +5,7 @@ namespace LEGO.AsyncAPI.Models
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;
using System.Collections.Generic;
+ using System.Linq;
///
/// Represents a field within an Avro record schema.
@@ -41,6 +42,11 @@ public class AvroField : IAsyncApiSerializable
///
public IList Aliases { get; set; } = new List();
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
+
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();
}
}
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroFixed.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroFixed.cs
index 35363425..d7bac5de 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroFixed.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroFixed.cs
@@ -4,26 +4,48 @@ namespace LEGO.AsyncAPI.Models
{
using LEGO.AsyncAPI.Writers;
using System.Collections.Generic;
+ using System.Linq;
public class AvroFixed : AvroSchema
{
public string Type { get; } = "fixed";
public string Name { get; set; }
- public string Namespaace { get; set; }
+
+ public string? Namespaace { get; set; }
public IList Aliases { get; set; } = new List();
public int Size { get; set; }
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
+
public override void SerializeV2(IAsyncApiWriter writer)
{
writer.WriteStartObject();
writer.WriteOptionalProperty("type", this.Type);
writer.WriteRequiredProperty("name", this.Name);
- writer.WriteRequiredProperty("name", this.Namespaace);
+ writer.WriteOptionalProperty("namespace", this.Namespaace);
writer.WriteOptionalCollection("aliases", this.Aliases, (w, s) => w.WriteValue(s));
writer.WriteRequiredProperty("size", this.Size);
+ 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();
}
}
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroMap.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroMap.cs
index fa99615d..382f25d5 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroMap.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroMap.cs
@@ -4,20 +4,40 @@ namespace LEGO.AsyncAPI.Models
{
using System;
using System.Collections.Generic;
+ using System.Linq;
using LEGO.AsyncAPI.Writers;
public class AvroMap : AvroSchema
{
public string Type { get; } = "map";
- public IDictionary Values { get; set; } = new Dictionary();
+ public AvroPrimitiveType Values { get; set; }
+
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
public override void SerializeV2(IAsyncApiWriter writer)
{
- Convert.ToBoolean()
writer.WriteStartObject();
writer.WriteOptionalProperty("type", this.Type);
- writer.WriteRequiredObject("values", this.Values, (w, f) => f.SerializeV2(w));
+ writer.WriteRequiredProperty("values", this.Values.GetDisplayName());
+ 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();
}
}
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroPrimitive.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroPrimitive.cs
index 7025a31d..6810f1e2 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroPrimitive.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroPrimitive.cs
@@ -2,20 +2,46 @@
namespace LEGO.AsyncAPI.Models
{
+ using System.Collections.Generic;
+ using System.Linq;
using LEGO.AsyncAPI.Writers;
public class AvroPrimitive : AvroSchema
{
public AvroPrimitiveType Type { get; set; }
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
+
public AvroPrimitive(AvroPrimitiveType type)
{
this.Type = type;
}
+ public AvroPrimitive()
+ {
+ }
+
public override void SerializeV2(IAsyncApiWriter writer)
{
writer.WriteValue(this.Type.GetDisplayName());
+ 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);
+ }
+ }
+ }
}
}
}
\ No newline at end of file
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroRecord.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroRecord.cs
index c45936f6..c5725dd4 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroRecord.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroRecord.cs
@@ -25,18 +25,27 @@ public class AvroRecord : AvroSchema
///
public string? Doc { get; set; }
+ ///
+ ///
+ ///
public IList Aliases { get; set; } = new List();
+ ///
+ ///
+ ///
public IList Fields { get; set; } = new List();
- public IDictionary Metadata { get; set; } = new Dictionary();
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
public override void SerializeV2(IAsyncApiWriter writer)
{
writer.WriteStartObject();
writer.WriteOptionalProperty("type", this.Type);
writer.WriteRequiredProperty("name", this.Name);
- writer.WriteRequiredProperty("namespace", this.Namespace);
+ writer.WriteOptionalProperty("namespace", this.Namespace);
writer.WriteOptionalProperty("doc", this.Doc);
writer.WriteOptionalCollection("aliases", this.Aliases, (w, s) => w.WriteValue(s));
writer.WriteRequiredCollection("fields", this.Fields, (w, s) => s.SerializeV2(w));
diff --git a/src/LEGO.AsyncAPI/Models/Avro/AvroUnion.cs b/src/LEGO.AsyncAPI/Models/Avro/AvroUnion.cs
index 7949dd4a..567a5dd6 100644
--- a/src/LEGO.AsyncAPI/Models/Avro/AvroUnion.cs
+++ b/src/LEGO.AsyncAPI/Models/Avro/AvroUnion.cs
@@ -3,12 +3,18 @@
namespace LEGO.AsyncAPI.Models
{
using System.Collections.Generic;
+ using System.Linq;
using LEGO.AsyncAPI.Writers;
public class AvroUnion : AvroSchema
{
public IList Types { get; set; } = new List();
+ ///
+ /// A map of properties not in the schema, but added as additional metadata.
+ ///
+ public IDictionary Metadata { get; set; } = new Dictionary();
+
public override void SerializeV2(IAsyncApiWriter writer)
{
writer.WriteStartArray();
@@ -16,6 +22,22 @@ public override void SerializeV2(IAsyncApiWriter writer)
{
type.SerializeV2(writer);
}
+
+ 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.WriteEndArray();
}
}