Skip to content

Commit 85ee13f

Browse files
committed
fix(rust): maintain multi-line formatting for serde attributes in oneOf/anyOf enums
- Keep #[serde(untagged)] on separate line from pub enum for better readability - Update test assertions to use two separate checks instead of linearize() - Ensures generated Rust code maintains consistent formatting with existing samples - Preserves the original multi-line attribute style preferred in Rust ecosystem
1 parent 915bd56 commit 85ee13f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

modules/openapi-generator/src/main/resources/rust/model.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ impl Default for {{classname}} {
126126
{{#-first}}
127127
{{! Model with composedSchemas.oneOf - generate enum}}
128128
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
129-
#[serde(untagged)] pub enum {{classname}} {
129+
#[serde(untagged)]
130+
pub enum {{classname}} {
130131
{{/-first}}
131132
{{/oneOf}}
132133
{{/composedSchemas}}

modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ public void testAnyOfSupport() throws IOException {
288288
TestUtils.assertFileExists(modelIdentifierPath);
289289

290290
// Should generate an untagged enum
291-
String enumDeclaration = linearize("#[serde(untagged)] pub enum ModelIdentifier");
292-
TestUtils.assertFileContains(modelIdentifierPath, enumDeclaration);
291+
TestUtils.assertFileContains(modelIdentifierPath, "#[serde(untagged)]");
292+
TestUtils.assertFileContains(modelIdentifierPath, "pub enum ModelIdentifier");
293293

294294
// Should have String variant (for anyOf with string types)
295295
TestUtils.assertFileContains(modelIdentifierPath, "String(String)");

0 commit comments

Comments
 (0)