From b1c995c73d0f8985619fe4beb40d384ea0bbd954 Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Thu, 15 Feb 2024 14:22:17 +0100 Subject: [PATCH] JNG-5527 Fix java reserwed keywords for operations (#25) --- .../judo/psm/generator/jackson/api/JavaNamespaceHelper.java | 2 +- .../src/main/resources/rest/api/rest.service.java.hbs | 6 +++--- .../src/main/resources/rest/impl/rest.service.impl.java.hbs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/judo-psm-generator-jaxrs-api/src/main/java/hu/blackbelt/judo/psm/generator/jackson/api/JavaNamespaceHelper.java b/judo-psm-generator-jaxrs-api/src/main/java/hu/blackbelt/judo/psm/generator/jackson/api/JavaNamespaceHelper.java index 1f58a48..ce7d95c 100644 --- a/judo-psm-generator-jaxrs-api/src/main/java/hu/blackbelt/judo/psm/generator/jackson/api/JavaNamespaceHelper.java +++ b/judo-psm-generator-jaxrs-api/src/main/java/hu/blackbelt/judo/psm/generator/jackson/api/JavaNamespaceHelper.java @@ -53,7 +53,7 @@ public static String safeName(String str) { "public", "requires", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "void", "volatile", "while", "true", "null", "false", "var", "const", "goto", - "class", "Class", "int", "interface").contains(str)) { + "class", "Class", "int", "interface", "default").contains(str)) { return str + "_"; } else { return str; diff --git a/judo-psm-generator-jaxrs-api/src/main/resources/rest/api/rest.service.java.hbs b/judo-psm-generator-jaxrs-api/src/main/resources/rest/api/rest.service.java.hbs index 0dcd0e5..698cf9a 100644 --- a/judo-psm-generator-jaxrs-api/src/main/resources/rest/api/rest.service.java.hbs +++ b/judo-psm-generator-jaxrs-api/src/main/resources/rest/api/rest.service.java.hbs @@ -9,7 +9,7 @@ public interface {{ self.className }} { public void __unbindDispatcher(hu.blackbelt.judo.dispatcher.api.Dispatcher dispatcher); {{# each self.operations as | operation | }} - public javax.ws.rs.core.Response {{ operation.name }}( + public javax.ws.rs.core.Response {{ safeName operation.name }}( @javax.ws.rs.core.Context javax.ws.rs.core.SecurityContext securityContext , @javax.ws.rs.HeaderParam("X-Judo-CountRecords") java.lang.String __countRecords {{# if operation.isBoundOperation }} @@ -17,9 +17,9 @@ public interface {{ self.className }} { {{/ if }} {{# if operation.input }} {{# if operation.input.isMany }} - , java.util.List> {{ operation.input.name.firstToLower }} + , java.util.List> {{ safeName operation.input.name.firstToLower }} {{ else }} - , java.util.Map {{ operation.input.name.firstToLower }} + , java.util.Map {{ safeName operation.input.name.firstToLower }} {{/ if }} {{/ if }} ); diff --git a/judo-psm-generator-jaxrs-impl/src/main/resources/rest/impl/rest.service.impl.java.hbs b/judo-psm-generator-jaxrs-impl/src/main/resources/rest/impl/rest.service.impl.java.hbs index c73766a..fb44e69 100644 --- a/judo-psm-generator-jaxrs-impl/src/main/resources/rest/impl/rest.service.impl.java.hbs +++ b/judo-psm-generator-jaxrs-impl/src/main/resources/rest/impl/rest.service.impl.java.hbs @@ -93,7 +93,7 @@ public class {{ implClassName self }} implements {{ namedElementApiRestFqName se @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "Not found.") @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "422", description = "Business fault") @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "Internal server error.") - public javax.ws.rs.core.Response {{ operation.name }}( + public javax.ws.rs.core.Response {{ safeName operation.name }}( @javax.ws.rs.core.Context javax.ws.rs.core.SecurityContext securityContext, @javax.ws.rs.HeaderParam("X-Judo-CountRecords") java.lang.String __countRecords {{# if operation.isBoundOperation }} , @javax.ws.rs.HeaderParam("X-Judo-SignedIdentifier") java.lang.String __signedIdentifier @@ -115,7 +115,7 @@ public class {{ implClassName self }} implements {{ namedElementApiRestFqName se ) ) ) - java.util.List> {{ operation.input.name.firstToLower }} + java.util.List> {{ safeName operation.input.name.firstToLower }} {{ else }} , @io.swagger.v3.oas.annotations.parameters.RequestBody( @@ -129,7 +129,7 @@ public class {{ implClassName self }} implements {{ namedElementApiRestFqName se ) ) ) - java.util.Map {{ operation.input.name.firstToLower }} + java.util.Map {{ safeName operation.input.name.firstToLower }} {{/ if }} {{/ if }} ) {