From 64ece5d42c614d4b8a63fb5229d70027c3728ca5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 11:41:36 -0300 Subject: [PATCH] fix: fix wrong behavir with right enum name (#541) (#545) Co-authored-by: Matheus Cruz <56329339+mcruzdev@users.noreply.github.com> --- .../deployment/wrapper/QuarkusJavaClientCodegen.java | 2 +- .../deployment/wrapper/QuarkusJavaClientCodegenTest.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegen.java b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegen.java index 2f62071f..96f13924 100644 --- a/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegen.java +++ b/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegen.java @@ -168,7 +168,7 @@ public String toEnumVarName(String value, String datatype) { // remove _ at start and end enumVarName = enumVarName.replaceAll("^_+|_+$", ""); - enumVarName = enumVarName.replaceFirst("\\d.*", "_".concat(enumVarName)); + enumVarName = enumVarName.replaceFirst("^(\\d).*", "_".concat(enumVarName)); return enumVarName.toUpperCase(Locale.ROOT); } diff --git a/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegenTest.java b/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegenTest.java index 8e56cd2d..c1a871ad 100644 --- a/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegenTest.java +++ b/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/wrapper/QuarkusJavaClientCodegenTest.java @@ -16,7 +16,10 @@ class QuarkusJavaClientCodegenTest { "123456,String,_123456", "quarkus_resources,String,QUARKUS_RESOURCES", "123456,Integer,NUMBER_123456", // old behavior - "123+123,Long,NUMBER_123PLUS_123" // old behavior + "123+123,Long,NUMBER_123PLUS_123", // old behavior, + "M123,String,M123", + "MA456,String,MA456", + "P1,String,P1", }) void toEnumVarName(String value, String dataType, String expectedVarName) {