Repository navigation
feat: Add support for rename_all in AvroSchema macro - #207
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for the rename_all attribute in the AvroSchema derive macro to mirror serde’s behavior. Key changes include:
- Passing a new rename_all option from the macro input to both struct and enum schema generation.
- Implementing and integrating case conversion rules (in src/case.rs) for field and variant names.
- Adding tests to validate the new renaming behavior.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| avro_derive/src/lib.rs | Integrates rename_all parsing and applies the renaming rules to structs and enums. |
| avro_derive/src/case.rs | Implements case conversion rules to support the rename_all attribute. |
Comments suppressed due to low confidence (2)
avro_derive/src/lib.rs:156
- Consider adding a comment here to clarify that an explicit 'rename' attribute takes precedence over 'rename_all' for field names.
name = rename_all.apply_to_field(&name);
avro_derive/src/lib.rs:727
- Using substring matching on the generated token stream may be brittle; consider comparing the structured schema output or using more robust methods for validation in tests.
assert!(schema_token_stream.contains(expected_token_stream));
Supports the same settings as serde
martin-g
reviewed
Jun 10, 2025
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Member
|
Thank you, @Vaalla42 ! |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supports the same settings as serde.
Because we need to have the same behavior as serde, the case conversion code was copied from serde crate.