OpenAPITools / OpenAPITools/openapi-generator
[REQ] [rust] rust-server enum variants do not follow the Rust style guide
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
The rust-server generator generates enums with the variants capitalised. The rust style guide says that enum variants should be camel case with the first letter capitalised. https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
ExampleEnum:
type: string
enum:
- first
- second
- two_words
generates the following enum:
pub enum ExampleEnum {
#[serde(rename = "first")]
FIRST,
#[serde(rename = "second")]
SECOND,
#[serde(rename = "two_words")]
TWO_WORDS,
}
But I would expect it to produce:
pub enum ExampleEnum {
#[serde(rename = "first")]
First,
#[serde(rename = "second")]
Second,
#[serde(rename = "two_words")]
TwoWords,
}
The generated enum currently includes an attribute so that the compiler will not warn about the non camel case types.
#[allow(non_camel_case_types)]
Describe the solution you'd like
Add an option to generate enum variants in camel case instead of upper case. When generating in camel case it would not include the attribute allowing non camel case types above the enum.
Describe alternatives you've considered
I don't have any other ideas.
Additional context
Nothing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the rust-server generator's enum-generation path and inspect how uppercase variants and the non_camel_case_types attribute are produced. Trace existing generator options, then add coverage for first, second, and two_words to verify camel-case output omits the allow attribute while preserving the serde rename values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, rust
- Domain
- backend, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100