From b695b681ee0d136e09d67257184d5d6b6780e377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Fri, 3 Jan 2025 11:41:59 +0100 Subject: [PATCH] fix a typo and remove the r# generated to the paramName when we create the identifier --- .../codegen/languages/AbstractRustCodegen.java | 2 +- .../codegen/languages/RustClientCodegen.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java index 977c4359ae79..7da93b288de1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java @@ -21,7 +21,7 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code private final Logger LOGGER = LoggerFactory.getLogger(AbstractRustCodegen.class); - protected static final String VENDOR_EXTENTION_PARAM_IDENTIFIER = "x-rust-param-identifier"; + protected static final String VENDOR_EXTENSION_PARAM_IDENTIFIER = "x-rust-param-identifier"; protected List charactersToAllow = Collections.singletonList("_"); protected Set keywordsThatDoNotSupportRawIdentifiers = new HashSet<>( diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index af1a5e257431..d871a75071a3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -612,10 +612,14 @@ public void postProcessParameter(CodegenParameter parameter) { if (this.useSingleRequestParameter) { in_function_identifier = "params." + parameter.paramName; } else { - in_function_identifier = "p_" + parameter.paramName; + if (parameter.paramName.startsWith("r#")) { + in_function_identifier = "p_" + parameter.paramName.substring(2); + } else { + in_function_identifier = "p_" + parameter.paramName; + } } - if (!parameter.vendorExtensions.containsKey(this.VENDOR_EXTENTION_PARAM_IDENTIFIER)) { // allow to overwrite this value - parameter.vendorExtensions.put(this.VENDOR_EXTENTION_PARAM_IDENTIFIER, in_function_identifier); + if (!parameter.vendorExtensions.containsKey(this.VENDOR_EXTENSION_PARAM_IDENTIFIER)) { // allow to overwrite this value + parameter.vendorExtensions.put(this.VENDOR_EXTENSION_PARAM_IDENTIFIER, in_function_identifier); } }