I'm having trouble with the newly added support for default values in 8.0.1 when attempting to generate a schema.
Here's a sample code that highlights the issue:
using Chr.Avro.Abstract;
using Chr.Avro.Representation;
using DefaultValueAttribute = System.ComponentModel.DefaultValueAttribute;
var schemaBuilder = new SchemaBuilder();
var schema = schemaBuilder.BuildSchema<MyRecord>();
var writer = new JsonSchemaWriter();
Console.WriteLine(writer.Write(schema));
public class MyRecord
{
[DefaultValue(null)]
public int? Value { get; set; }
}
The default value null set on the record property causes an exception in the JsonSchemaWriter:
Unhandled exception. Chr.Avro.UnsupportedSchemaException: The default value of the Value field on RecordSchema MyRecord must be a JSON value.
at Chr.Avro.Representation.JsonRecordSchemaWriterCase.Write(Schema schema, Utf8JsonWriter json, Boolean canonical, JsonSchemaWriterContext context)
at Chr.Avro.Representation.JsonSchemaWriter.Write(Schema schema, Utf8JsonWriter json, Boolean canonical, JsonSchemaWriterContext context)
at Chr.Avro.Representation.JsonSchemaWriter.Write(Schema schema, Stream stream, Boolean canonical, JsonSchemaWriterContext context)
at Chr.Avro.Representation.JsonSchemaWriter.Write(Schema schema, Boolean canonical, JsonSchemaWriterContext context)
at Program.<Main>$(String[] args) in C:\Projects\Avro\AvroSchemaGeneration\AvroSchemaGeneration\Program.cs:line 9
The same error appears when running dotnet avro create, or when attempting to serialize the record.
Hi,
I'm having trouble with the newly added support for default values in 8.0.1 when attempting to generate a schema. Here's a sample code that highlights the issue:
The default value
null
set on the record property causes an exception in theJsonSchemaWriter
:The same error appears when running
dotnet avro create
, or when attempting to serialize the record.