Skip to content

Commit d68847d

Browse files
committed
Update
1 parent bb922e4 commit d68847d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
9999
public RustAxumServerCodegen() {
100100
super();
101101

102+
// The `#[validate(nested)]` macro relies on an internal field named `errors` to accumulate validation results. Therefore, defining a struct like this will fail:
103+
//
104+
// ```rust
105+
// struct A {
106+
// #[validate(nested)]
107+
// errors: B,
108+
// }
109+
// ```
110+
//
111+
// To avoid this, either rename the field to something other than "errors", or reserve it.
112+
this.reservedWords.add("errors");
113+
102114
modifyFeatureSet(features -> features
103115
.wireFormatFeatures(EnumSet.of(
104116
WireFormatFeature.JSON,
@@ -1192,10 +1204,6 @@ public String toVarName(String name) {
11921204
if (varName.startsWith("r#"))
11931205
return "r_" + varName.substring(2);
11941206

1195-
// Special case: validate(nested) macros has internal field errors, thus, result in compilation error
1196-
if (varName == "errors")
1197-
return "errors_";
1198-
11991207
return varName;
12001208
}
12011209

0 commit comments

Comments
 (0)