leo-vital commented on issue #252:
URL: https://github.com/apache/avro-rs/issues/252#issuecomment-3177888121
> It would be easier to discuss if you provide sample writer (before) schema
and reader (after) schema. If I understand you correctly you ask whether you
can derive the reader schema with `AvroSchema`. Correct ? Let's see how it
looks like and then we can answer!
@martin-g Let's say this is the struct:
```rust
#[derive(AvroSchema)]
struct Book {
title: String,
}
```
And the schema generated from that ends up looking like this:
```
{"subject":"book-schema-value",
"version":1,
"id":1,
"schema":"
{\"type\":\"record\",
\"name\":\"Book\",
\"fields\":[{\"name\":\"title\",\"type\":\"string\"}]}"}
```
So let's say we register that schema as the initial version of the schema,
in the Schema Registry. Then we want to add an optional new field to the struct:
```rust
#[derive(AvroSchema)]
struct Book {
title: String,
subtitle: Option<String>,
}
```
The generated schema will look like this:
```
{"subject":"book-schema-value",
"version":1,
"id":1,
"schema":"
{\"type\":\"record\",
\"name\":\"Book\",
\"fields\":[{\"name\":\"title\",\"type\":\"string\"},
{\"name\":\"subtitle\",\"type\":[\"null\",\"string\"]}]}"}
```
And when trying to register that as a new version of the schema in the
Registry, the aformentioned `READER_FIELD_MISSING_DEFAULT_VALUE` error will
happen in the Registry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]