-
Notifications
You must be signed in to change notification settings - Fork 20
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
3d270e7
commit 56ff634
Showing
22 changed files
with
442 additions
and
30 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroArray : AvroFieldType | ||
{ | ||
public string Type { get; set; } = "array"; | ||
|
||
public AvroFieldType Items { get; set; } | ||
|
||
public override void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteOptionalProperty("type", this.Type); | ||
writer.WritePropertyName("items"); | ||
this.Items.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroEnum : AvroFieldType | ||
{ | ||
public string Type { get; set; } = "enum"; | ||
|
||
public string Name { get; set; } | ||
|
||
public IList<string> Symbols { get; set; } = new List<string>(); | ||
|
||
public override void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteOptionalProperty("type", this.Type); | ||
writer.WriteRequiredProperty("name", this.Name); | ||
writer.WritePropertyName("symbols"); | ||
writer.WriteStartArray(); | ||
foreach (var symbol in this.Symbols) | ||
{ | ||
writer.WriteValue(symbol); | ||
} | ||
|
||
writer.WriteEndArray(); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
/// <summary> | ||
/// Represents a field within an Avro record schema. | ||
/// </summary> | ||
public class AvroField : IAsyncApiSerializable | ||
{ | ||
/// <summary> | ||
/// The name of the field. | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// The type of the field. Can be a primitive type, a complex type, or a union. | ||
/// </summary> | ||
public AvroFieldType Type { get; set; } | ||
|
||
/// <summary> | ||
/// The documentation for the field. | ||
/// </summary> | ||
public string Doc { get; set; } | ||
|
||
/// <summary> | ||
/// The default value for the field. | ||
/// </summary> | ||
public AsyncApiAny Default { get; set; } | ||
|
||
/// <summary> | ||
/// The order of the field, can be 'ascending', 'descending', or 'ignore'. | ||
/// </summary> | ||
public string Order { get; set; } | ||
|
||
public void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
|
||
// name | ||
writer.WriteOptionalProperty("name", this.Name); | ||
|
||
// type | ||
if (this.Type != null) | ||
{ | ||
writer.WritePropertyName("type"); | ||
this.Type.SerializeV2(writer); | ||
} | ||
|
||
// doc | ||
writer.WriteOptionalProperty("doc", this.Doc); | ||
|
||
// default | ||
writer.WriteOptionalObject("default", this.Default, (w, s) => w.WriteAny(s)); | ||
|
||
// order | ||
writer.WriteOptionalProperty("order", this.Order); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public abstract class AvroFieldType : IAsyncApiSerializable | ||
{ | ||
public abstract void SerializeV2(IAsyncApiWriter writer); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroFixed : AvroFieldType | ||
{ | ||
public string Type { get; set; } = "fixed"; | ||
|
||
public string Name { get; set; } | ||
|
||
public int Size { get; set; } | ||
|
||
public override void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteOptionalProperty("type", this.Type); | ||
writer.WriteRequiredProperty("name", this.Name); | ||
writer.WriteRequiredProperty("size", this.Size); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroMap : AvroFieldType | ||
{ | ||
public string Type { get; set; } = "map"; | ||
|
||
public AvroFieldType Values { get; set; } | ||
|
||
public override void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteOptionalProperty("type", this.Type); | ||
writer.WritePropertyName("values"); | ||
this.Values.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroPrimitive : AvroFieldType | ||
{ | ||
public string Type { get; set; } | ||
|
||
public AvroPrimitive(string type) | ||
{ | ||
this.Type = type; | ||
} | ||
|
||
public override void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteValue(this.Type); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroRecord : AvroFieldType | ||
{ | ||
public string Type { get; set; } = "record"; | ||
|
||
public string Name { get; set; } | ||
|
||
public IList<AvroField> Fields { get; set; } = new List<AvroField>(); | ||
|
||
public override void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteOptionalProperty("type", this.Type); | ||
writer.WriteRequiredProperty("name", this.Name); | ||
writer.WritePropertyName("fields"); | ||
writer.WriteStartArray(); | ||
foreach (var field in this.Fields) | ||
{ | ||
field.SerializeV2(writer); | ||
} | ||
|
||
writer.WriteEndArray(); | ||
writer.WriteEndObject(); | ||
} | ||
} | ||
} |
Oops, something went wrong.