Skip to content

feat: Add support for rename_all in AvroSchema macro - #207

Merged
martin-g merged 5 commits into
apache:mainfrom
Vaalla42:feat/rename_all
Jun 10, 2025
Merged

martin-g merged 5 commits into
apache:mainfrom
Vaalla42:feat/rename_all

Conversation

@Vaalla42

@Vaalla42 Vaalla42 commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

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.

@martin-g
martin-g requested a review from Copilot June 9, 2025 12:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Comment thread avro_derive/src/lib.rs Resolved
Comment thread avro_derive/src/lib.rs Resolved
@martin-g
martin-g merged commit 092b36b into apache:main Jun 10, 2025
@martin-g

Copy link
Copy Markdown
Member

Thank you, @Vaalla42 !

@bryanburgers bryanburgers mentioned this pull request Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants