AvroSchemaGenerator 2.8.0-rc.22
See the version list below for details.
dotnet add package AvroSchemaGenerator --version 2.8.0-rc.22
NuGet\Install-Package AvroSchemaGenerator -Version 2.8.0-rc.22
<PackageReference Include="AvroSchemaGenerator" Version="2.8.0-rc.22" />
paket add AvroSchemaGenerator --version 2.8.0-rc.22
#r "nuget: AvroSchemaGenerator, 2.8.0-rc.22"
// Install AvroSchemaGenerator as a Cake Addin #addin nuget:?package=AvroSchemaGenerator&version=2.8.0-rc.22&prerelease // Install AvroSchemaGenerator as a Cake Tool #tool nuget:?package=AvroSchemaGenerator&version=2.8.0-rc.22&prerelease
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; }
}
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
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 was computed. 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. |
-
net7.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 7.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on AvroSchemaGenerator:
Package | Downloads |
---|---|
Pulsar.Client
.NET client library for Apache Pulsar |
|
Pulsar.Client.Otel
OpenTelemetry plugin for Pulsar.Client |
|
SharpPulsar
SharpPulsar is Apache Pulsar Client built using Akka.net |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.10.0 | 4,507 | 12/16/2023 |
2.9.2 | 260,151 | 7/10/2023 |
2.9.1 | 1,453 | 3/19/2023 |
2.9.0 | 508 | 2/4/2023 |
2.9.0-rc.39 | 148 | 2/3/2023 |
2.9.0-rc.15 | 146 | 1/9/2023 |
2.9.0-rc.6 | 131 | 1/9/2023 |
2.8.1 | 103,833 | 1/9/2023 |
2.8.0 | 364 | 12/24/2022 |
2.8.0-rc.22 | 130 | 12/24/2022 |
2.8.0-rc.21 | 125 | 12/24/2022 |
2.8.0-rc.13 | 126 | 12/24/2022 |
2.8.0-rc.6 | 132 | 12/24/2022 |
2.7.0 | 134,732 | 7/20/2022 |
2.7.0-rc.139 | 151 | 7/20/2022 |
2.7.0-rc.138 | 138 | 7/20/2022 |
2.6.0 | 171,756 | 2/20/2022 |
2.6.0-rc.136 | 164 | 7/19/2022 |
2.5.2-alpha.2 | 172 | 1/16/2022 |
2.5.2-Alpha.1 | 165 | 1/16/2022 |
2.5.1 | 353 | 1/13/2022 |
2.5.0 | 456 | 12/26/2021 |
2.4.1 | 1,248 | 10/27/2021 |
2.4.0 | 50,709 | 9/28/2021 |
2.4.0-beta | 270 | 9/28/2021 |
2.3.3 | 935 | 9/15/2021 |
2.3.3-beta | 297 | 9/15/2021 |
2.3.2 | 372 | 9/15/2021 |
2.3.1-beta | 282 | 9/15/2021 |
2.3.0 | 419 | 9/15/2021 |
2.2.0 | 740 | 9/13/2021 |
2.2.0-beta.17 | 214 | 9/13/2021 |
2.1.0 | 770 | 9/11/2021 |
2.1.0-beta.16 | 228 | 9/13/2021 |
2.1.0-beta.15 | 283 | 9/11/2021 |
2.0.0 | 786 | 9/10/2021 |
2.0.0-beta.14 | 218 | 9/9/2021 |
1.9.0 | 52,426 | 4/14/2021 |
1.9.0-beta.13 | 245 | 9/9/2021 |
1.9.0-beta.12 | 215 | 4/14/2021 |
1.9.0-beta.11 | 199 | 4/14/2021 |
1.9.0-beta.10 | 201 | 4/13/2021 |
1.9.0-beta.9 | 197 | 4/13/2021 |
1.9.0-beta.5 | 185 | 4/13/2021 |
1.9.0-beta.3 | 184 | 4/13/2021 |
1.9.0-beta.2 | 229 | 4/11/2021 |
1.8.0 | 138,006 | 12/10/2020 |
1.7.0 | 621 | 11/4/2020 |
1.6.0 | 57,952 | 6/26/2020 |
1.5.4 | 516 | 6/21/2020 |
1.5.3 | 6,153 | 5/27/2020 |
1.5.2 | 4,785 | 5/13/2020 |
1.5.1 | 1,191 | 5/13/2020 |
1.5.0 | 502 | 5/13/2020 |
1.4.1 | 536 | 5/11/2020 |
1.4.0 | 512 | 5/11/2020 |
1.3.0 | 1,485 | 4/30/2020 |
1.2.0 | 539 | 4/28/2020 |
1.1.0 | 837 | 4/27/2020 |
1.0.0 | 511 | 4/27/2020 |
0.1.2 | 1,566 | 4/14/2020 |
0.1.1 | 504 | 4/14/2020 |
0.1.0 | 1,245 | 4/11/2020 |
• [update] .NET 7
• [fix] Resolves #64 Fixed that the same enum can be used multiple times in the schema @danny-krueger [https://github.com/eaba/AvroSchemaGenerator/pull/74/commits/ba622efc263f89ed8d5bc826493cf8a33637b580]
Full changelog at https://github.com/eaba/AvroSchemaGenerator/blob/main/CHANGELOG.md