Skip to content

Commit 4f53f13

Browse files
committed
minor fixes and docs
1 parent 1dd2468 commit 4f53f13

File tree

11 files changed

+75
-165
lines changed

11 files changed

+75
-165
lines changed

src/LEGO.AsyncAPI/Models/Avro/AvroArray.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public class AvroArray : AvroSchema
1010
{
1111
public override string Type { get; } = "array";
1212

13+
/// <summary>
14+
/// The schema of the array's items.
15+
/// </summary>
1316
public AvroSchema Items { get; set; }
1417

1518
/// <summary>
@@ -37,6 +40,7 @@ public override void SerializeV2(IAsyncApiWriter writer)
3740
}
3841
}
3942
}
43+
4044
writer.WriteEndObject();
4145
}
4246
}

src/LEGO.AsyncAPI/Models/Avro/AvroEnum.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,34 @@ public class AvroEnum : AvroSchema
1010
{
1111
public override string Type { get; } = "enum";
1212

13+
/// <summary>
14+
/// The name of the schema. Required for named types. See <a href="https://avro.apache.org/docs/1.9.0/spec.html#names">Avro Names</a>.
15+
/// </summary>
1316
public string Name { get; set; }
1417

18+
/// <summary>
19+
/// The namespace of the schema. Useful for named types to avoid name conflicts.
20+
/// </summary>
1521
public string Namespace { get; set; }
1622

23+
/// <summary>
24+
/// Documentation for the schema.
25+
/// </summary>
1726
public string Doc { get; set; }
1827

28+
/// <summary>
29+
/// Alternate names for this enum.
30+
/// </summary>
1931
public IList<string> Aliases { get; set; } = new List<string>();
2032

33+
/// <summary>
34+
/// Listing symbols. All symbols in an enum must be unique.
35+
/// </summary>
2136
public IList<string> Symbols { get; set; } = new List<string>();
2237

38+
/// <summary>
39+
/// A default value for this enumeration.
40+
/// </summary>
2341
public string Default { get; set; }
2442

2543
/// <summary>
@@ -52,6 +70,7 @@ public override void SerializeV2(IAsyncApiWriter writer)
5270
}
5371
}
5472
}
73+
5574
writer.WriteEndObject();
5675
}
5776
}

src/LEGO.AsyncAPI/Models/Avro/AvroField.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace LEGO.AsyncAPI.Models
44
{
5-
using LEGO.AsyncAPI.Models.Interfaces;
6-
using LEGO.AsyncAPI.Writers;
75
using System.Collections.Generic;
86
using System.Linq;
7+
using LEGO.AsyncAPI.Models.Interfaces;
8+
using LEGO.AsyncAPI.Writers;
99

1010
/// <summary>
1111
/// Represents a field within an Avro record schema.
@@ -38,7 +38,7 @@ public class AvroField : IAsyncApiSerializable
3838
public string Order { get; set; }
3939

4040
/// <summary>
41-
/// An array of strings, providing alternate names for this record (optional).
41+
/// Alternate names for this record (optional).
4242
/// </summary>
4343
public IList<string> Aliases { get; set; } = new List<string>();
4444

@@ -71,6 +71,7 @@ public void SerializeV2(IAsyncApiWriter writer)
7171
}
7272
}
7373
}
74+
7475
writer.WriteEndObject();
7576
}
7677
}

src/LEGO.AsyncAPI/Models/Avro/AvroFieldType.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/LEGO.AsyncAPI/Models/Avro/AvroFixed.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,33 @@
22

33
namespace LEGO.AsyncAPI.Models
44
{
5-
using LEGO.AsyncAPI.Writers;
65
using System.Collections.Generic;
76
using System.Linq;
7+
using LEGO.AsyncAPI.Writers;
88

99
public class AvroFixed : AvroSchema
1010
{
1111
public override string Type { get; } = "fixed";
1212

13+
/// <summary>
14+
/// The name of the schema. Required for named types. See <a href="https://avro.apache.org/docs/1.9.0/spec.html#names">Avro Names</a>.
15+
/// </summary>
1316
public string Name { get; set; }
1417

18+
/// <summary>
19+
/// The namespace of the schema. Useful for named types to avoid name conflicts.
20+
/// </summary>
1521
public string Namespace { get; set; }
1622

23+
24+
/// <summary>
25+
/// Alternate names for this record.
26+
/// </summary>
1727
public IList<string> Aliases { get; set; } = new List<string>();
1828

29+
/// <summary>
30+
/// Number of bytes per value.
31+
/// </summary>
1932
public int Size { get; set; }
2033

2134
/// <summary>
@@ -46,6 +59,7 @@ public override void SerializeV2(IAsyncApiWriter writer)
4659
}
4760
}
4861
}
62+
4963
writer.WriteEndObject();
5064
}
5165
}

src/LEGO.AsyncAPI/Models/Avro/AvroMap.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public override void SerializeV2(IAsyncApiWriter writer)
3838
}
3939
}
4040
}
41+
4142
writer.WriteEndObject();
4243
}
4344
}

src/LEGO.AsyncAPI/Models/Avro/AvroRecord.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class AvroRecord : AvroSchema
2626
public string Doc { get; set; }
2727

2828
/// <summary>
29-
///
29+
/// Alternate names for this record.
3030
/// </summary>
3131
public IList<string> Aliases { get; set; } = new List<string>();
3232

@@ -64,6 +64,7 @@ public override void SerializeV2(IAsyncApiWriter writer)
6464
}
6565
}
6666
}
67+
6768
writer.WriteEndObject();
6869
}
6970
}
Lines changed: 25 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,25 @@
1-
// // Copyright (c) The LEGO Group. All rights reserved.
2-
//
3-
// namespace LEGO.AsyncAPI.Models
4-
// {
5-
// using System;
6-
// using System.Collections.Generic;
7-
// using LEGO.AsyncAPI.Models.Interfaces;
8-
// using LEGO.AsyncAPI.Writers;
9-
//
10-
// /// <summary>
11-
// /// Represents an Avro schema model (compatible with Avro 1.9.0).
12-
// /// </summary>
13-
// // #ToFix: Any type can be the main type so avroschema should be removed
14-
// /*
15-
// Record
16-
//
17-
// Fields:
18-
// name (string)
19-
// namespace (optional string)
20-
// doc (optional string)
21-
// aliases (optional array of strings)
22-
// fields (array of field objects, each with name, type, default, doc, order, and aliases)
23-
//
24-
// Enum
25-
// Fields:
26-
// name (string)
27-
// namespace (optional string)
28-
// aliases (optional array of strings)
29-
// symbols (array of strings)
30-
// default (optional string)
31-
// doc (optional string)
32-
//
33-
// Array
34-
// Fields:
35-
// items (type of the array elements)
36-
//
37-
// Map
38-
// Fields:
39-
// values (type of the map values)
40-
//
41-
// Union
42-
// Fields:
43-
// A list of potential types (each element is a valid Avro schema)
44-
//
45-
// Fixed
46-
// Fields:
47-
// name (string)
48-
// namespace (optional string)
49-
// aliases (optional array of strings)
50-
// size (integer specifying the number of bytes per value)
51-
// doc (optional string)
52-
// */
53-
//
54-
// public class AvroSchema : IAsyncApiSerializable, IAsyncApiReferenceable
55-
// {
56-
// /// <summary>
57-
// /// The type of the schema. See <a href="https://avro.apache.org/docs/1.9.0/spec.html#schema_primitive">Avro Schema Types</a>.
58-
// /// </summary>
59-
// public AvroSchemaType Type { get; set; }
60-
//
61-
// /// <summary>
62-
// /// The name of the schema. Required for named types (e.g., record, enum, fixed). See <a href="https://avro.apache.org/docs/1.9.0/spec.html#names">Avro Names</a>.
63-
// /// </summary>
64-
// public string Name { get; set; }
65-
//
66-
// /// <summary>
67-
// /// The namespace of the schema. Useful for named types to avoid name conflicts.
68-
// /// </summary>
69-
// public string? Namespace { get; set; }
70-
//
71-
// /// <summary>
72-
// /// Documentation for the schema.
73-
// /// </summary>
74-
// public string? Doc { get; set; }
75-
//
76-
// /// <summary>
77-
// /// The list of fields in the schema.
78-
// /// </summary>
79-
// public IList<AvroField> Fields { get; set; } = new List<AvroField>();
80-
//
81-
// public bool UnresolvedReference { get; set; }
82-
//
83-
// public AsyncApiReference Reference { get; set; }
84-
//
85-
// public void SerializeV2(IAsyncApiWriter writer)
86-
// {
87-
// if (writer is null)
88-
// {
89-
// throw new ArgumentNullException(nameof(writer));
90-
// }
91-
//
92-
// if (this.Reference != null && !writer.GetSettings().ShouldInlineReference(this.Reference))
93-
// {
94-
// this.Reference.SerializeV2(writer);
95-
// return;
96-
// }
97-
//
98-
// this.SerializeV2WithoutReference(writer);
99-
// }
100-
//
101-
// public void SerializeV2WithoutReference(IAsyncApiWriter writer)
102-
// {
103-
// writer.WriteStartObject();
104-
//
105-
// writer.WriteOptionalProperty(AsyncApiConstants.Type, this.Type.GetDisplayName());
106-
// writer.WriteOptionalProperty("name", this.Name);
107-
// writer.WriteOptionalProperty("namespace", this.Namespace);
108-
// writer.WriteOptionalProperty("doc", this.Doc);
109-
// writer.WriteOptionalCollection("fields", this.Fields, (w, f) => f.SerializeV2(w));
110-
//
111-
// writer.WriteEndObject();
112-
// }
113-
// }
114-
// }
1+
// Copyright (c) The LEGO Group. All rights reserved.
2+
3+
namespace LEGO.AsyncAPI.Models
4+
{
5+
using System.Collections.Generic;
6+
using LEGO.AsyncAPI.Models.Interfaces;
7+
using LEGO.AsyncAPI.Writers;
8+
9+
public abstract class AvroSchema : IAsyncApiSerializable
10+
{
11+
public abstract string Type { get; }
12+
13+
/// <summary>
14+
/// A map of properties not in the schema, but added as additional metadata.
15+
/// </summary>
16+
public abstract IDictionary<string, AsyncApiAny> Metadata { get; set; }
17+
18+
public static implicit operator AvroSchema(AvroPrimitiveType type)
19+
{
20+
return new AvroPrimitive(type);
21+
}
22+
23+
public abstract void SerializeV2(IAsyncApiWriter writer);
24+
}
25+
}

src/LEGO.AsyncAPI/Models/Avro/AvroSchemaType.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/LEGO.AsyncAPI/Models/Avro/AvroUnion.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public class AvroUnion : AvroSchema
1010
{
1111
public override string Type { get; } = "map";
1212

13+
/// <summary>
14+
/// The types in this union.
15+
/// </summary>
1316
public IList<AvroSchema> Types { get; set; } = new List<AvroSchema>();
1417

1518
/// <summary>
@@ -40,6 +43,7 @@ public override void SerializeV2(IAsyncApiWriter writer)
4043
}
4144
}
4245
}
46+
4347
writer.WriteEndArray();
4448
}
4549
}

src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public override void Visit(AsyncApiMessage message)
9292
{
9393
this.ResolveObject(message.Payload as AsyncApiJsonSchemaPayload, r => message.Payload = r);
9494
}
95+
9596
this.ResolveList(message.Traits);
9697
this.ResolveObject(message.CorrelationId, r => message.CorrelationId = r);
9798
this.ResolveObject(message.Bindings, r => message.Bindings = r);

0 commit comments

Comments
 (0)