Skip to content

Commit

Permalink
add enum name mapping feature to the rust generators (#17290)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Dec 4, 2023
1 parent b19bc59 commit ac45e3d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bin/configs/rust-reqwest-petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: petstore-reqwest
enumNameMappings:
delivered: shipped
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,12 @@ public String toModelDocFilename(String name) {
}

//// Enum naming ////

@Override
public String toEnumVarName(String name, String datatype) {
if (enumNameMapping.containsKey(name)) {
return enumNameMapping.get(name);
}

// Empty strings need to be mapped to "Empty"
// https://github.com/OpenAPITools/openapi-generator/issues/13453
if (Strings.isNullOrEmpty(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub enum Status {
#[serde(rename = "approved")]
Approved,
#[serde(rename = "delivered")]
Delivered,
shipped,
}

impl Default for Status {
Expand Down

0 comments on commit ac45e3d

Please sign in to comment.