StreamNative.AvroSchemaGenerator
1.0.0
dotnet add package StreamNative.AvroSchemaGenerator --version 1.0.0
NuGet\Install-Package StreamNative.AvroSchemaGenerator -Version 1.0.0
<PackageReference Include="StreamNative.AvroSchemaGenerator" Version="1.0.0" />
<PackageVersion Include="StreamNative.AvroSchemaGenerator" Version="1.0.0" />
<PackageReference Include="StreamNative.AvroSchemaGenerator" />
paket add StreamNative.AvroSchemaGenerator --version 1.0.0
#r "nuget: StreamNative.AvroSchemaGenerator, 1.0.0"
#:package StreamNative.AvroSchemaGenerator@1.0.0
#addin nuget:?package=StreamNative.AvroSchemaGenerator&version=1.0.0
#tool nuget:?package=StreamNative.AvroSchemaGenerator&version=1.0.0
StreamNative.AvroSchemaGenerator
Generate Apache Avro schemas from .NET types, with support for RECURSIVE SCHEMA.
This package is a StreamNative-maintained distribution based on Sharp-Pulsar/AvroSchemaGenerator. The original project is licensed under the Apache License, Version 2.0.
Getting Started
Install the NuGet package StreamNative.AvroSchemaGenerator:
dotnet add package StreamNative.AvroSchemaGenerator
Then copy/paste the code below:
using AvroSchemaGenerator;
public class Course
{
public string Level { get; set; }
public int Year { get; set; }
public string State { get; set; }
public string Gender { get; set; }
}
var avroSchema = typeof(Course).GetSchema();
By default, StreamNative.AvroSchemaGenerator generates schema with optional fields. The code below is an example of how to mark fields as required.
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using AvroSchemaGenerator;
public class Course
{
[Required]
public string Level { get; set; }
[Required]
public int Year { get; set; }
[Required]
public string State { get; set; }
[Required]
public string Gender { get; set; }
}
var avroSchema = typeof(Course).GetSchema();
You can assign a default value as well
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using AvroSchemaGenerator;
public class Course
{
[DefaultValue("200")]
[Required]
public string Level { get; set; }
[Required]
public int Year { get; set; }
[DefaultValue("Closed")]
public string State { get; set; }
public string Gender { get; set; }
}
var avroSchema = typeof(Course).GetSchema();
Aliases
[Aliases("OldCourse")]
public class Course
{
[Aliases("Level")]
public string NewLevel { get; set; }
}
Logical Types
public class MessageTimeKind
{
[LogicalType(LogicalTypeKind.TimeMicrosecond)]
public TimeSpan TimeMicros { get; set; }
[LogicalType(LogicalTypeKind.TimeMillisecond)]
public TimeSpan TimeMillis { get; set; }
}
public class MessageTimestampKind
{
[LogicalType(LogicalTypeKind.TimestampMicrosecond)]
public DateTime StampMicros { get; set; }
[LogicalType(LogicalTypeKind.TimestampMillisecond)]
public DateTime StampMillis { get; set; }
}
public class MessageDateKind
{
[LogicalType(LogicalTypeKind.Date)]
public DateTime CreatedTime { get; set; }
public AvroDecimal Size { get; set; }
public string DayOfWeek { get; set; }
}
Custom Avro Definition
public class CustomDefinition
{
[AvroSchema("{\n" +
" \"type\": \"bytes\",\n" +
" \"logicalType\": \"decimal\",\n" +
" \"precision\": 10,\n" +
" \"scale\": 6\n" +
"}")]
public AvroDecimal DecimalAvro { get; set; }
}
NOTE
- Don't use same declaring type as dictionary value
- Don't use same declaring type as list argument
- Dictionary key must be a string type
License
This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.
Attribution
This project is based on Sharp-Pulsar/AvroSchemaGenerator, which is licensed under the Apache License, Version 2.0. StreamNative maintains this package as a separate distribution with StreamNative-specific packaging and maintenance changes. See NOTICE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 8.0.5)
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on StreamNative.AvroSchemaGenerator:
| Package | Downloads |
|---|---|
|
StreamNative.Pulsar.Client
StreamNative-maintained .NET client library for Apache Pulsar. |
|
|
StreamNative.Pulsar.Client.Otel
StreamNative-maintained OpenTelemetry plugin for Pulsar.Client. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 188 | 7/13/2026 |
| 1.0.0-rc.2 | 61 | 7/13/2026 |
| 1.0.0-rc.1 | 104 | 7/10/2026 |
| 1.0.0-rc.0 | 92 | 6/25/2026 |