jklamer commented on PR #1631:
URL: https://github.com/apache/avro/pull/1631#issuecomment-1095891894
@martin-g darling is exactly what I was thinking there should be when I was
making it! Refactored it a bit to break it up into NamedTypes and their schema
options , and fields and their schema options! So we get docs on fields and
types out of the box and super easily. Check it out:
```
#[derive(Debug, Serialize, Deserialize, AvroSchema, Clone, PartialEq)]
#[avro(namespace = "com.testing.namespace", doc = "A Documented Record")]
struct TestBasicWithAttributes {
#[avro(doc = "Documented Field")]
a: i32,
b: String,
}
```
Also I was able to solve the `doc` issue where ToTokens on Option was
flattening away None by manually preserving it in the output tokens:
```
fn preserve_optional(op: Option<impl quote::ToTokens>) -> TokenStream {
match op {
Some(tt) => quote! {Some(#tt.to_owned())},
None => quote! {None},
}
}
```
--
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]