[rust] Extend oneOf array enum names with inner type#21599
Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom Aug 7, 2025
Merged
[rust] Extend oneOf array enum names with inner type#21599wing328 merged 1 commit intoOpenAPITools:masterfrom
wing328 merged 1 commit intoOpenAPITools:masterfrom
Conversation
Member
|
thanks for the pr cc @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) |
Member
|
tested locally to confirm the fix --- a/src/models/option1_or_option2_options.rs
+++ b/src/models/option1_or_option2_options.rs
@@ -14,13 +14,13 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Option1OrOption2Options {
- Array(Vec<String>),
- Array(Vec<i32>),
+ ArrayVecString(Vec<String>),
+ ArrayVeci32(Vec<i32>),
}
impl Default for Option1OrOption2Options {
fn default() -> Self {
- Self::Array(Default::default())
+ Self::ArrayVecString(Default::default())
}
}
let's give it (bug fix) a try if someone needs the old way to name the enum option, we can add an option to do so for fallback |
Goopher
pushed a commit
to Goopher/openapi-generator
that referenced
this pull request
Sep 9, 2025
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.
When
oneOfis specified with multiple types of array, Rust will not compile the resulting code because each enum option is namedArray. This change extends the name of each type with its container type and inner data type, creating names such asArrayVeci32andArrayVecStringunless the user explicitly specifies another name using thetitlefield.Fixes #18527
@jacob-pro
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)