AvroSchemaGenerator 2.6.0

AvroSchemaGenerator

Use to generate Avro Schema with support for RECURSIVE SCHEMA

Getting Started

Install the NuGet package AvroSchemaGenerator and 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, 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; }
}

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

Showing the top 20 packages that depend on AvroSchemaGenerator.

Packages Downloads
Pulsar.Client
.NET client library for Apache Pulsar
2

• Add back support for NET standard 2.0 • Add IEnumerabl<> support • @ThomasHarzer [https://github.com/eaba/AvroSchemaGenerator/commit/38c38308d183ecda416ce5b8b946ebe681c2f171] Full changelog at https://github.com/eaba/AvroSchemaGenerator/blob/main/CHANGELOG.md

Version Downloads Last updated
2.10.0 3 2026/4/12
2.9.2 2 2025/4/29
2.9.1 2 2026/4/13
2.9.0 1 2026/4/13
2.9.0-rc.39 2 2026/4/13
2.9.0-rc.15 1 2026/4/13
2.9.0-rc.6 1 2026/4/13
2.8.1 2 2026/4/13
2.8.0 1 2026/4/13
2.8.0-rc.22 1 2026/4/13
2.8.0-rc.21 1 2026/4/13
2.8.0-rc.13 1 2026/4/13
2.8.0-rc.6 1 2026/4/13
2.7.0 1 2026/4/13
2.7.0-rc.139 1 2026/4/13
2.7.0-rc.138 1 2026/4/13
2.6.0 1 2026/4/13
2.6.0-rc.136 1 2026/4/13
2.5.2-alpha.2 2 2026/4/13
2.5.2-Alpha.1 1 2026/4/13
2.5.1 1 2026/4/13
2.5.0 1 2026/4/13
2.4.1 1 2026/4/13
2.4.0 1 2026/4/13
2.4.0-beta 2 2026/4/8
2.3.3 2 2026/4/13
2.3.3-beta 1 2026/4/13
2.3.2 1 2026/4/13
2.3.1-beta 1 2026/4/13
2.3.0 1 2026/4/13
2.2.0 1 2026/4/13
2.2.0-beta.17 1 2026/4/13
2.1.0 1 2026/4/13
2.1.0-beta.16 2 2026/4/13
2.1.0-beta.15 1 2026/4/13
2.0.0 1 2026/4/13
2.0.0-beta.14 1 2026/4/13
1.9.0 2 2026/4/13
1.9.0-beta.13 1 2026/4/13
1.9.0-beta.12 1 2026/4/13
1.9.0-beta.11 1 2026/4/13
1.9.0-beta.10 1 2026/4/13
1.9.0-beta.9 1 2026/4/13
1.9.0-beta.5 2 2026/4/10
1.9.0-beta.3 2 2026/4/10
1.9.0-beta.2 2 2026/4/10
1.8.0 1 2026/4/13
1.7.0 1 2026/4/13
1.6.0 1 2026/4/13
1.5.4 1 2026/4/13
1.5.3 1 2026/4/13
1.5.2 2 2026/4/12
1.5.1 1 2026/4/13
1.5.0 2 2026/4/13
1.4.1 1 2026/4/13
1.4.0 1 2026/4/13
1.3.0 2 2026/4/13
1.2.0 1 2026/4/13
1.1.0 2 2026/4/13
1.0.0 1 2026/4/13
0.1.2 2 2026/4/13
0.1.1 1 2026/4/13
0.1.0 2 2026/4/13