Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Rust): Use rename_all #2214

Merged
merged 11 commits into from
May 17, 2023
Merged

Conversation

taorepoara
Copy link
Contributor

Detects the the most used naming style in the class properties and enum cases to define it in the rename_all when needed.

Replaces #2210
Closes #528

@taorepoara
Copy link
Contributor Author

I don't understand the test error. Can someone help me with this ?

@taorepoara
Copy link
Contributor Author

Ok, I understood the problem.

The union field of this schema test is renamed to top_level_union: https://github.com/quicktype/quicktype/blob/master/test/inputs/schema/pattern.schema#L12

Does someone know why the field name is not kept ?

@taorepoara
Copy link
Contributor Author

taorepoara commented Mar 16, 2023

I've fixed the problem with the unit tests.

I also add one with camel case properties to test the new feature.

Copy link
Member

@dvdsgl dvdsgl left a comment

Choose a reason for hiding this comment

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

Very nice work! Just a few small stylistic changes requested.

packages/quicktype-core/src/language/Rust.ts Outdated Show resolved Hide resolved
"UPPERCASE": {
regex: /^[A-Z][A-Z0-9]*$/,
toParts: (name: string): string[] => [name],
fromParts: (parts: string[]): string => parts.map(p => p.toUpperCase()).join(''),
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to write the types for each toParts and fromParts wince you declared them for the entire struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I use them to detect the input fields formats.
I also use them to detect if a field does not match the global type.

packages/quicktype-core/src/language/Rust.ts Outdated Show resolved Hide resolved
packages/quicktype-core/src/language/Rust.ts Outdated Show resolved Hide resolved
@taorepoara taorepoara requested a review from dvdsgl May 6, 2023 13:47
@dvdsgl
Copy link
Member

dvdsgl commented May 16, 2023

I’ve just fixed the tests, please merge master.

@dvdsgl dvdsgl merged commit 4c23429 into glideapps:master May 17, 2023
23 of 24 checks passed
@taorepoara taorepoara deleted the rust-camel-case-rename branch May 17, 2023 12:21
github-actions bot pushed a commit to iamwavecut/quicktype-bin that referenced this pull request May 18, 2023
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.

Use rename_all = "camelCase" for rust instead of renaming each value individually
2 participants