Kriskras99 commented on issue #435:
URL: https://github.com/apache/avro-rs/issues/435#issuecomment-3796539573
The first issue can be reduced to this:
```rust
#[derive(AvroSchema)]
pub enum Color { G }
#[derive(AvroSchema)]
pub struct A {
pub color: Color,
}
#[derive(AvroSchema)]
pub struct C {
#[serde(flatten)]
pub a: A,
}
#[derive(AvroSchema)]
pub struct TestStruct {
pub a: Color,
pub c: C,
}
```
The problem is that when the `transparent` attribute is used, that schema is
called using a new `named_schemas` because we don't want to insert the schema
for `A` in case it's used in another field because then it would be a ref to a
schema that does not exist:
```
#[derive(AvroSchema)]
pub struct TestStruct {
pub a: Color,
pub c: C,
// This would fail if `transparent` forwards the `named_schemas`
pub b: A,
}
```
I think the solution would be changing to trait to this:
```rust
pub trait AvroSchemaComponent {
// If transparent is `true` then don't insert the schema into
`named_schemas`
fn get_schema_in_ctxt(named_schemas: &mut HashMap<Name, Schema>,
enclosing_namespace: &Namespace, transparent: bool);
}
```
This would of course be a breaking change.
--
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]