diff --git a/README.md b/README.md index 7b866909..6d3e513f 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ Then simply include the following code in the POM of the project you wish to gen ### reverseOrderInClassNames (optional, default: false) Reverse order of resource path that will be included in generated class names. If set to false URI will be included in class name from left to right. +### logicForParamsAndMethodsNaming +(optional, default: DEFAULT) Logic used for Java names of arguments and methods generation. Possible values: `DEFAULT`, `DISPLAY_NAME` (`displayName` attribute will be cleaned and used), `ANNOTATION` (value of `javaName` annotation will be used as is). + ### ruleConfiguration (optional) This is a key/value map for configuration of individual rules. Not all rules support configuration. diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiActionMetadata.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiActionMetadata.java index 2c19e506..198fdc2a 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiActionMetadata.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiActionMetadata.java @@ -22,6 +22,7 @@ import java.util.stream.Collectors; import org.raml.v2.api.model.v10.datamodel.JSONTypeDeclaration; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import org.springframework.http.MediaType; import org.springframework.util.StringUtils; @@ -88,10 +89,6 @@ public String toString() { } public Set getPathVariables() { - // FIXME Alex - comment this out! - // if (pathVariables != null) { - // return pathVariables; - // } pathVariables = new LinkedHashSet<>(); RamlResource targetResource = action.getResource(); @@ -385,4 +382,12 @@ public String getRequestBodyMime() { public void setRequestBodyMime(String requestBodyMime) { this.requestBodyMime = requestBodyMime; } + + public String getDisplayName() { + return action.getDisplayName(); + } + + public List getAnnotations() { + return action.getAnnotations(); + } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiParameterMetadata.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiParameterMetadata.java index 7ad5bcd0..89028526 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiParameterMetadata.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiParameterMetadata.java @@ -18,9 +18,13 @@ import java.util.Set; import org.apache.commons.lang.NullArgumentException; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import org.springframework.util.StringUtils; +import com.phoenixnap.oss.ramlplugin.raml2code.helpers.NamingHelper; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.SchemaHelper; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.Config; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.LogicForParamsAndMethodsNaming; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlAbstractParam; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlUriParameter; import com.sun.codemodel.JCodeModel; @@ -223,4 +227,27 @@ public boolean isArray() { public JCodeModel getCodeModel() { return codeModel; } + + public List getAnnotations() { + return ramlParam.getAnnotations(); + } + + public String getJavaName() { + String javaName = null; + if (Config.getLogicForParamsAndMethodsNaming() == LogicForParamsAndMethodsNaming.DISPLAY_NAME + && !StringUtils.isEmpty(this.getDisplayName())) { + javaName = NamingHelper.getParameterName(this.getDisplayName()); + } else if (Config.getLogicForParamsAndMethodsNaming() == LogicForParamsAndMethodsNaming.ANNOTATION) { + for (AnnotationRef annotation : this.getAnnotations()) { + if ("(javaName)".equals(annotation.name())) { + javaName = String.valueOf(annotation.structuredValue().value()); + break; + } + } + } + if (StringUtils.isEmpty(javaName)) { + javaName = NamingHelper.getParameterName(this.getName()); + } + return javaName; + } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java index 9529f60c..009a8832 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java @@ -27,6 +27,7 @@ import java.util.regex.Pattern; import org.jsonschema2pojo.util.NameHelper; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import org.raml.v2.internal.utils.Inflector; import org.springframework.http.MediaType; import org.springframework.util.StringUtils; @@ -34,6 +35,8 @@ import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiActionMetadata; import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiBodyMetadata; import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiParameterMetadata; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.Config; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.LogicForParamsAndMethodsNaming; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlActionType; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlResource; @@ -228,11 +231,11 @@ public static String convertToClassName(String clazz) { */ public static String getResourceName(RamlResource resource, boolean singularize) { String url = resource.getRelativeUri(); - if (StringUtils.hasText(url)) { - if (url.contains("/") && (url.lastIndexOf("/") < url.length())) { - return getResourceName(url.substring(url.lastIndexOf("/") + 1), singularize); - } + + if (StringUtils.hasText(url) && url.contains("/") && (url.lastIndexOf("/") < url.length())) { + return getResourceName(url.substring(url.lastIndexOf("/") + 1), singularize); } + return null; } @@ -394,6 +397,17 @@ private static boolean doesUriEndsWithParam(String uri) { public static String getActionName(ApiActionMetadata apiActionMetadata) { + if (Config.getLogicForParamsAndMethodsNaming() == LogicForParamsAndMethodsNaming.DISPLAY_NAME + && !StringUtils.isEmpty(apiActionMetadata.getDisplayName())) { + return cleanNameForJava(apiActionMetadata.getDisplayName()); + } else if (Config.getLogicForParamsAndMethodsNaming() == LogicForParamsAndMethodsNaming.ANNOTATION) { + for (AnnotationRef annotation : apiActionMetadata.getAnnotations()) { + if ("(javaName)".equals(annotation.name())) { + return String.valueOf(annotation.structuredValue().value()); + } + } + } + String uri = apiActionMetadata.getResource().getUri(); String name = convertActionTypeToIntent(apiActionMetadata.getActionType(), doesUriEndsWithParam(uri)); @@ -416,8 +430,7 @@ public static String getActionName(ApiActionMetadata apiActionMetadata) { name = name + "By"; if (parameterMetadataList.size() == 1) { ApiParameterMetadata paramMetaData = parameterMetadataList.iterator().next(); - name = name + StringUtils.capitalize(cleanNameForJava( - paramMetaData.getDisplayName() != null ? paramMetaData.getDisplayName() : paramMetaData.getName())); + name = name + StringUtils.capitalize(paramMetaData.getJavaName()); } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/ObjectTypeInterpreter.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/ObjectTypeInterpreter.java index 673c05db..2cc66404 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/ObjectTypeInterpreter.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/ObjectTypeInterpreter.java @@ -29,6 +29,7 @@ import com.phoenixnap.oss.ramlplugin.raml2code.helpers.NamingHelper; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlTypeHelper; import com.phoenixnap.oss.ramlplugin.raml2code.plugin.Config; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.LogicForParamsAndMethodsNaming; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlDataType; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlRoot; import com.sun.codemodel.JClass; @@ -154,16 +155,33 @@ public RamlInterpretationResult interpret(RamlRoot document, TypeDeclaration typ List excludeFieldsFromToString = new ArrayList<>(); for (TypeDeclaration objectProperty : objectType.properties()) { + + String fieldName = null; + if (Config.getLogicForParamsAndMethodsNaming() == LogicForParamsAndMethodsNaming.DISPLAY_NAME + && objectProperty.displayName() != null) { + fieldName = NamingHelper.getParameterName(objectProperty.displayName().value()); + } else if (Config.getLogicForParamsAndMethodsNaming() == LogicForParamsAndMethodsNaming.ANNOTATION) { + for (AnnotationRef annotation : objectProperty.annotations()) { + if ("(javaName)".equals(annotation.name())) { + fieldName = String.valueOf(annotation.structuredValue().value()); + break; + } + } + } + if (StringUtils.isEmpty(fieldName)) { + fieldName = NamingHelper.getParameterName(objectProperty.name()); + } + List annotations = objectProperty.annotations(); for (AnnotationRef annotation : annotations) { if ("(isSensitive)".equals(annotation.name()) && Boolean.TRUE.equals(annotation.structuredValue().value())) { - excludeFieldsFromToString.add(objectProperty.name()); + excludeFieldsFromToString.add(fieldName); } } RamlInterpretationResult childResult = RamlInterpreterFactory.getInterpreterForType(objectProperty).interpret(document, objectProperty, builderModel, true); String childType = childResult.getResolvedClassOrBuiltOrObject().fullName(); - builder.withField(objectProperty.name(), childType, RamlTypeHelper.getDescription(objectProperty), childResult.getValidations(), + builder.withField(fieldName, childType, RamlTypeHelper.getDescription(objectProperty), childResult.getValidations(), objectProperty); } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/RamlTypeValidations.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/RamlTypeValidations.java index 9761e9ad..159655ae 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/RamlTypeValidations.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/interpreters/RamlTypeValidations.java @@ -78,10 +78,12 @@ public boolean isRequired() { } /** - * Adds validation annotations to the supplied field + * Adds validation annotations to the supplied method * - * @param field - * to add annotations to + * @param getter + * getter method to add validation annotation to + * @param addValidAnnotation + * if {@code @Valid} annotation dhould be added */ public void annotateFieldJSR303(JMethod getter, boolean addValidAnnotation) { if (isRequired()) { diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/Config.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/Config.java index 3783ebfc..4aff9bd5 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/Config.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/Config.java @@ -1,6 +1,7 @@ package com.phoenixnap.oss.ramlplugin.raml2code.plugin; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.NamingHelper; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.LogicForParamsAndMethodsNaming; public class Config { @@ -26,6 +27,9 @@ public class Config { private static final String DEFAULT_BASE_PACKAGE = "com.gen.test"; private static String basePackage = DEFAULT_BASE_PACKAGE; + private static final LogicForParamsAndMethodsNaming DEFAULT_LOGIC_FOR_PARAMS_AND_METHODS_NAMING = LogicForParamsAndMethodsNaming.DEFAULT; + private static LogicForParamsAndMethodsNaming logicForParamsAndMethodsNaming = DEFAULT_LOGIC_FOR_PARAMS_AND_METHODS_NAMING; + Config() { } @@ -112,6 +116,17 @@ public static String getBasePackage() { return basePackage; } + public static LogicForParamsAndMethodsNaming getLogicForParamsAndMethodsNaming() { + if (springMvcEndpointGeneratorMojo != null) { + return springMvcEndpointGeneratorMojo.logicForParamsAndMethodsNaming; + } + return logicForParamsAndMethodsNaming; + } + + protected static void setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming logicForParamsAndMethodsNaming) { + Config.logicForParamsAndMethodsNaming = logicForParamsAndMethodsNaming; + } + public static String getPojoPackage() { return getBasePackage() + NamingHelper.getDefaultModelPackage(); } @@ -124,5 +139,7 @@ protected static void resetFields() { setResourceTopLevelInClassNames(DEFAULT_RESOURCE_TOP_LEVEL_IN_CLASS_NAMES); setReverseOrderInClassNames(DEFAULT_REVERSE_ORDER_IN_CLASS_NAMES); setSeperateMethodsByContentType(DEFAULT_SEPERATE_METHODS_BY_CONTENTTYPE); + setLogicForParamsAndMethodsNaming(DEFAULT_LOGIC_FOR_PARAMS_AND_METHODS_NAMING); } + } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/SpringMvcEndpointGeneratorMojo.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/SpringMvcEndpointGeneratorMojo.java index 32d3e790..667e0794 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/SpringMvcEndpointGeneratorMojo.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/SpringMvcEndpointGeneratorMojo.java @@ -195,6 +195,15 @@ public class SpringMvcEndpointGeneratorMojo extends AbstractMojo { @Parameter(required = false, readonly = true, defaultValue = "false") protected Boolean reverseOrderInClassNames; + /** + * Logic used for Java names of arguments and methods generation. Possible + * values:
  • DEFAULT
  • DISPLAY_NAME - displayName attribute + * will be cleaned and used
  • ANNOTATION - "javaName" annotation will + * be used as is
+ */ + @Parameter(required = false, readonly = true, defaultValue = "DEFAULT") + protected LogicForParamsAndMethodsNaming logicForParamsAndMethodsNaming; + private ClassRealm classRealm; private String resolvedSchemaLocation; @@ -504,4 +513,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { this.getLog().info("Endpoint Generation Completed in:" + (System.currentTimeMillis() - startTime) + "ms"); } + public enum LogicForParamsAndMethodsNaming { + DEFAULT, DISPLAY_NAME, ANNOTATION + } + } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAbstractParam.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAbstractParam.java index 367b92e7..1b0a8166 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAbstractParam.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAbstractParam.java @@ -13,6 +13,9 @@ package com.phoenixnap.oss.ramlplugin.raml2code.raml; import java.math.BigDecimal; +import java.util.List; + +import org.raml.v2.api.model.v10.declarations.AnnotationRef; /** * Abstract Representation of a Raml Parameter @@ -49,6 +52,8 @@ public abstract class RamlAbstractParam { // extends AbstractParam { public abstract BigDecimal getMaximum(); + public abstract List getAnnotations(); + /** * Convenience method for easier processing. Non supporting parameters are * assumed to be single. diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAction.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAction.java index 8ab53f04..7931bb6f 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAction.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/RamlAction.java @@ -15,6 +15,8 @@ import java.util.List; import java.util.Map; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; + /** * Abstract Representation of a Raml Action * @@ -42,4 +44,6 @@ public interface RamlAction { String getDisplayName(); List getSecuredBy(); + + List getAnnotations(); } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlAction.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlAction.java index f4fb3423..4f26b49a 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlAction.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlAction.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.Map; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import org.raml.v2.api.model.v10.methods.Method; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlTypeHelper; @@ -127,4 +128,9 @@ public String getDisplayName() { public List getSecuredBy() { return ramlModelFactory.createRamlSecurityReferences(method.securedBy()); } + + @Override + public List getAnnotations() { + return this.method.annotations(); + } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlFormParameter.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlFormParameter.java index 9aa91448..29bde02a 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlFormParameter.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlFormParameter.java @@ -13,10 +13,12 @@ package com.phoenixnap.oss.ramlplugin.raml2code.raml.raml10; import java.math.BigDecimal; +import java.util.List; import org.raml.v2.api.model.v10.datamodel.NumberTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.StringTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.TypeDeclaration; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import com.phoenixnap.oss.ramlplugin.raml2code.data.RamlFormParameter; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlTypeHelper; @@ -137,4 +139,9 @@ public BigDecimal getMaximum() { public String getName() { return this.formParameter.name(); } + + @Override + public List getAnnotations() { + return this.formParameter.annotations(); + } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlHeader.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlHeader.java index a4c63bb7..36194e38 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlHeader.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlHeader.java @@ -13,10 +13,12 @@ package com.phoenixnap.oss.ramlplugin.raml2code.raml.raml10; import java.math.BigDecimal; +import java.util.List; import org.raml.v2.api.model.v10.datamodel.NumberTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.StringTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.TypeDeclaration; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlTypeHelper; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlHeader; @@ -123,4 +125,9 @@ public BigDecimal getMaximum() { public String getName() { return this.header.name(); } + + @Override + public List getAnnotations() { + return this.header.annotations(); + } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlMimeType.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlMimeType.java index fe0e8964..848abe01 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlMimeType.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlMimeType.java @@ -73,12 +73,6 @@ private List getList(TypeDeclaration typeDeclaration) { @Override public String getSchema() { return mimeType.type(); - // FIXME Alex - // if (RamlTypeHelper.isSchemaType(mimeType)) { - // return ((ExternalTypeDeclaration) mimeType).schemaContent(); - // } else { - // return null; - // } } @Override diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlQueryParameter.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlQueryParameter.java index 4605ae5c..74af4366 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlQueryParameter.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlQueryParameter.java @@ -13,11 +13,13 @@ package com.phoenixnap.oss.ramlplugin.raml2code.raml.raml10; import java.math.BigDecimal; +import java.util.List; import org.raml.v2.api.model.v10.datamodel.ArrayTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.NumberTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.StringTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.TypeDeclaration; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlTypeHelper; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlDataType; @@ -152,4 +154,9 @@ public RamlDataType getRamlDataType() { public String getName() { return this.queryParameter.name(); } + + @Override + public List getAnnotations() { + return this.queryParameter.annotations(); + } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlUriParameter.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlUriParameter.java index 61e15733..c1c02127 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlUriParameter.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/raml/raml10/RJP10V2RamlUriParameter.java @@ -13,10 +13,12 @@ package com.phoenixnap.oss.ramlplugin.raml2code.raml.raml10; import java.math.BigDecimal; +import java.util.List; import org.raml.v2.api.model.v10.datamodel.NumberTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.StringTypeDeclaration; import org.raml.v2.api.model.v10.datamodel.TypeDeclaration; +import org.raml.v2.api.model.v10.declarations.AnnotationRef; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlTypeHelper; import com.phoenixnap.oss.ramlplugin.raml2code.raml.RamlParamType; @@ -132,4 +134,9 @@ public BigDecimal getMaximum() { public String getName() { return this.uriParameter.name(); } + + @Override + public List getAnnotations() { + return this.uriParameter.annotations(); + } } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java index 577f9e9a..130373fc 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java @@ -109,8 +109,9 @@ public JMethod apply(ApiActionMetadata endpointMetadata, CodeModelHelper.JExtMet protected JVar paramQueryForm(ApiParameterMetadata paramMetaData, CodeModelHelper.JExtMethod generatableType, ApiActionMetadata endpointMetadata) { - String javaName = NamingHelper - .getParameterName(paramMetaData.getDisplayName() != null ? paramMetaData.getDisplayName() : paramMetaData.getName()); + + String javaName = paramMetaData.getJavaName(); + if (addParameterJavadoc) { String paramComment = ""; if (paramMetaData.getRamlParam() != null && StringUtils.hasText(paramMetaData.getRamlParam().getDescription())) { diff --git a/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue177RulesTest.java b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue177RulesTest.java index 35a63572..3d9fef5f 100644 --- a/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue177RulesTest.java +++ b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue177RulesTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiResourceMetadata; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.LogicForParamsAndMethodsNaming; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.TestConfig; import com.phoenixnap.oss.ramlplugin.raml2code.rules.GitHubAbstractRuleTestBase; import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerStubRule; @@ -15,13 +17,26 @@ public class Issue177RulesTest extends GitHubAbstractRuleTestBase { @Test - public void applySpring4ControllerStubRule_shouldCreate_validCode() throws Exception { + public void displayName_not_used_for_naming_logic() throws Exception { loadRaml("issue-177.raml"); rule = new Spring4ControllerStubRule(); Set allControllersMetadata = getAllControllersMetadata(); for (ApiResourceMetadata apiResourceMetadata : allControllersMetadata) { rule.apply(apiResourceMetadata, jCodeModel); } - verifyGeneratedCode("Issue177Spring4ControllerStub", serializeModel()); + verifyGeneratedCode("Issue177-1Spring4ControllerStub", serializeModel()); + } + + @Test + public void displayName_used_for_naming_logic() throws Exception { + TestConfig.setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming.DISPLAY_NAME); + loadRaml("issue-177.raml"); + rule = new Spring4ControllerStubRule(); + Set allControllersMetadata = getAllControllersMetadata(); + for (ApiResourceMetadata apiResourceMetadata : allControllersMetadata) { + rule.apply(apiResourceMetadata, jCodeModel); + } + verifyGeneratedCode("Issue177-2Spring4ControllerStub", serializeModel()); + TestConfig.setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming.DEFAULT); } } diff --git a/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue250RulesTest.java b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue250RulesTest.java new file mode 100644 index 00000000..b9e3cb9f --- /dev/null +++ b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue250RulesTest.java @@ -0,0 +1,43 @@ +package com.phoenixnap.oss.ramlplugin.raml2code.github; + +import org.junit.Test; + +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.LogicForParamsAndMethodsNaming; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.TestConfig; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.GitHubAbstractRuleTestBase; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerDecoratorRule; + +/** + * @author aleksandars + * @since 2.0.1 + */ +public class Issue250RulesTest extends GitHubAbstractRuleTestBase { + + @Test + public void verify_default_naming_logic() throws Exception { + loadRaml("issue-250.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue250-1Spring4ControllerDecorator"); + } + + @Test + public void verify_displayName_naming_logic() throws Exception { + TestConfig.setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming.DISPLAY_NAME); + loadRaml("issue-250.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue250-2Spring4ControllerDecorator"); + TestConfig.setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming.DEFAULT); + } + + @Test + public void verify_annotation_naming_logic() throws Exception { + TestConfig.setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming.ANNOTATION); + loadRaml("issue-250.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue250-3Spring4ControllerDecorator"); + TestConfig.setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming.DEFAULT); + } +} diff --git a/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/TestConfig.java b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/TestConfig.java index c0c6dd55..47973b92 100644 --- a/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/TestConfig.java +++ b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/plugin/TestConfig.java @@ -1,5 +1,6 @@ package com.phoenixnap.oss.ramlplugin.raml2code.plugin; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.SpringMvcEndpointGeneratorMojo.LogicForParamsAndMethodsNaming; import com.phoenixnap.oss.ramlplugin.raml2code.rules.TestPojoConfig; public class TestConfig { @@ -25,4 +26,8 @@ public static void setInjectHttpHeadersParameter(boolean injectHttpHeadersParame Config.setInjectHttpHeadersParameter(injectHttpHeadersParameter); } + public static void setLogicForParamsAndMethodsNaming(LogicForParamsAndMethodsNaming logicForParamsAndMethodsNaming) { + Config.setLogicForParamsAndMethodsNaming(logicForParamsAndMethodsNaming); + } + } diff --git a/src/test/resources/ramls/github/issue-250.raml b/src/test/resources/ramls/github/issue-250.raml new file mode 100644 index 00000000..9dfe7172 --- /dev/null +++ b/src/test/resources/ramls/github/issue-250.raml @@ -0,0 +1,53 @@ +#%RAML 1.0 +title: Better naming control #250 +version: "1.0.0" + +annotationTypes: + javaName: + type: string + allowedTargets: [TypeDeclaration, Method] + +types: + User: + type: object + properties: + firstName: + type: string + displayName: firstNameDisplayName + (javaName): firstNameJavaName + +/test: + /{uriParam}: + uriParameters: + uriParam: + displayName: uriParamDisplayName + (javaName): uriParamJavaName + type: integer + get: + displayName: getMethodDisplayName + (javaName): getMethodJavaName + queryParameters: + queryParam: + type: string + displayName: queryParamDisplayName + (javaName): queryParamJavaName + headers: + headerParam: + type: string + displayName: headerParamDisplayName + (javaName): headerParamJavaName + responses: + 200: + body: + application/json: + type: User + /accept: + put: + displayName: putMethodDisplayName + (javaName): putMethodJavaName + body: + application/json: + type: User + responses: + 200: + \ No newline at end of file diff --git a/src/test/resources/validations/github/Issue177-1Spring4ControllerStub.java.txt b/src/test/resources/validations/github/Issue177-1Spring4ControllerStub.java.txt new file mode 100644 index 00000000..7cd4e09b --- /dev/null +++ b/src/test/resources/validations/github/Issue177-1Spring4ControllerStub.java.txt @@ -0,0 +1,128 @@ +-----------------------------------com.gen.test.AResourceController.java----------------------------------- + +package com.gen.test; + +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/a_resource") +@Validated +public class AResourceController { + + + /** + * No description + * + */ + @RequestMapping(value = "", method = RequestMethod.GET) + public ResponseEntity getObjectByHeaderStringParam( + @RequestHeader(name = "header_string_param") + String headerStringParam) { + return null; //TODO Autogenerated Method Stub. Implement me please. + } + +} +-----------------------------------com.gen.test.BResourceController.java----------------------------------- + +package com.gen.test; + +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/b_resource") +@Validated +public class BResourceController { + + + /** + * No description + * + */ + @RequestMapping(value = "", method = RequestMethod.GET) + public ResponseEntity getObjectByQueryStringParam( + @RequestParam(name = "query_string_param") + String queryStringParam) { + return null; //TODO Autogenerated Method Stub. Implement me please. + } + + /** + * No description + * + */ + @RequestMapping(value = "/str/{uri_string_param}", method = RequestMethod.GET) + public ResponseEntity getObjectByUriStringParam( + @PathVariable("uri_string_param") + String uriStringParam) { + return null; //TODO Autogenerated Method Stub. Implement me please. + } + + /** + * No description + * + */ + @RequestMapping(value = "/int/{uri_int_param}", method = RequestMethod.GET) + public ResponseEntity getObjectByUriIntParam( + @PathVariable("uri_int_param") + Long uriIntParam) { + return null; //TODO Autogenerated Method Stub. Implement me please. + } + +} +-----------------------------------com.gen.test.CResourceController.java----------------------------------- + +package com.gen.test; + +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/c_resource") +@Validated +public class CResourceController { + + + /** + * No description + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createCResource( + @RequestParam(name = "form_string_param") + String formStringParam) { + return null; //TODO Autogenerated Method Stub. Implement me please. + } + +} diff --git a/src/test/resources/validations/github/Issue177Spring4ControllerStub.java.txt b/src/test/resources/validations/github/Issue177-2Spring4ControllerStub.java.txt similarity index 100% rename from src/test/resources/validations/github/Issue177Spring4ControllerStub.java.txt rename to src/test/resources/validations/github/Issue177-2Spring4ControllerStub.java.txt diff --git a/src/test/resources/validations/github/Issue250-1Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/Issue250-1Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..3b2f69a2 --- /dev/null +++ b/src/test/resources/validations/github/Issue250-1Spring4ControllerDecorator.java.txt @@ -0,0 +1,171 @@ +-----------------------------------com.gen.test.model.User.java----------------------------------- + +package com.gen.test.model; + +import java.io.Serializable; +import javax.validation.constraints.NotNull; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class User implements Serializable +{ + + protected String firstName; + + /** + * Creates a new User. + * + */ + public User() { + super(); + } + + /** + * Creates a new User. + * + */ + public User(String firstName) { + super(); + this.firstName = firstName; + } + + /** + * Returns the firstName. + * + * @return + * firstName + */ + @NotNull + public String getFirstName() { + return firstName; + } + + /** + * Set the firstName. + * + * @param firstName + * the new firstName + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public int hashCode() { + return new HashCodeBuilder().append(firstName).toHashCode(); + } + + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if (this.getClass()!= other.getClass()) { + return false; + } + User otherObject = ((User) other); + return new EqualsBuilder().append(firstName, otherObject.firstName).isEquals(); + } + + public String toString() { + return new ToStringBuilder(this).append("firstName", firstName).toString(); + } + +} +-----------------------------------com.gen.test.TestController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import com.gen.test.model.User; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface TestController { + + + /** + * No description + * + */ + public ResponseEntity getUserBy(Long uriParam, String queryParam, String headerParam); + + /** + * No description + * + */ + public ResponseEntity updateUser(Long uriParam, + @Valid + User user); + +} +-----------------------------------com.gen.test.TestControllerDecorator.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import com.gen.test.model.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/test") +@Validated +public class TestControllerDecorator + implements TestController +{ + + @Autowired + private TestController testControllerDelegate; + + /** + * No description + * + */ + @RequestMapping(value = "/{uriParam}", method = RequestMethod.GET) + public ResponseEntity getUserBy( + @PathVariable + Long uriParam, + @RequestParam + String queryParam, + @RequestHeader + String headerParam) { + return this.testControllerDelegate.getUserBy(uriParam, queryParam, headerParam); + } + + /** + * No description + * + */ + @RequestMapping(value = "/{uriParam}/accept", method = RequestMethod.PUT) + public ResponseEntity updateUser( + @PathVariable + Long uriParam, + @Valid + @RequestBody + User user) { + return this.testControllerDelegate.updateUser(uriParam, user); + } + +} diff --git a/src/test/resources/validations/github/Issue250-2Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/Issue250-2Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..3f6cd27a --- /dev/null +++ b/src/test/resources/validations/github/Issue250-2Spring4ControllerDecorator.java.txt @@ -0,0 +1,171 @@ +-----------------------------------com.gen.test.model.User.java----------------------------------- + +package com.gen.test.model; + +import java.io.Serializable; +import javax.validation.constraints.NotNull; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class User implements Serializable +{ + + protected String firstNameDisplayName; + + /** + * Creates a new User. + * + */ + public User() { + super(); + } + + /** + * Creates a new User. + * + */ + public User(String firstNameDisplayName) { + super(); + this.firstNameDisplayName = firstNameDisplayName; + } + + /** + * Returns the firstNameDisplayName. + * + * @return + * firstNameDisplayName + */ + @NotNull + public String getFirstNameDisplayName() { + return firstNameDisplayName; + } + + /** + * Set the firstNameDisplayName. + * + * @param firstNameDisplayName + * the new firstNameDisplayName + */ + public void setFirstNameDisplayName(String firstNameDisplayName) { + this.firstNameDisplayName = firstNameDisplayName; + } + + public int hashCode() { + return new HashCodeBuilder().append(firstNameDisplayName).toHashCode(); + } + + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if (this.getClass()!= other.getClass()) { + return false; + } + User otherObject = ((User) other); + return new EqualsBuilder().append(firstNameDisplayName, otherObject.firstNameDisplayName).isEquals(); + } + + public String toString() { + return new ToStringBuilder(this).append("firstNameDisplayName", firstNameDisplayName).toString(); + } + +} +-----------------------------------com.gen.test.TestController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import com.gen.test.model.User; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface TestController { + + + /** + * No description + * + */ + public ResponseEntity getMethodDisplayName(Long uriParamDisplayName, String queryParamDisplayName, String headerParamDisplayName); + + /** + * No description + * + */ + public ResponseEntity putMethodDisplayName(Long uriParamDisplayName, + @Valid + User user); + +} +-----------------------------------com.gen.test.TestControllerDecorator.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import com.gen.test.model.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/test") +@Validated +public class TestControllerDecorator + implements TestController +{ + + @Autowired + private TestController testControllerDelegate; + + /** + * No description + * + */ + @RequestMapping(value = "/{uriParam}", method = RequestMethod.GET) + public ResponseEntity getMethodDisplayName( + @PathVariable("uriParam") + Long uriParamDisplayName, + @RequestParam(name = "queryParam") + String queryParamDisplayName, + @RequestHeader(name = "headerParam") + String headerParamDisplayName) { + return this.testControllerDelegate.getMethodDisplayName(uriParamDisplayName, queryParamDisplayName, headerParamDisplayName); + } + + /** + * No description + * + */ + @RequestMapping(value = "/{uriParam}/accept", method = RequestMethod.PUT) + public ResponseEntity putMethodDisplayName( + @PathVariable("uriParam") + Long uriParamDisplayName, + @Valid + @RequestBody + User user) { + return this.testControllerDelegate.putMethodDisplayName(uriParamDisplayName, user); + } + +} diff --git a/src/test/resources/validations/github/Issue250-3Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/Issue250-3Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..f1f4207c --- /dev/null +++ b/src/test/resources/validations/github/Issue250-3Spring4ControllerDecorator.java.txt @@ -0,0 +1,171 @@ +-----------------------------------com.gen.test.model.User.java----------------------------------- + +package com.gen.test.model; + +import java.io.Serializable; +import javax.validation.constraints.NotNull; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class User implements Serializable +{ + + protected String firstNameJavaName; + + /** + * Creates a new User. + * + */ + public User() { + super(); + } + + /** + * Creates a new User. + * + */ + public User(String firstNameJavaName) { + super(); + this.firstNameJavaName = firstNameJavaName; + } + + /** + * Returns the firstNameJavaName. + * + * @return + * firstNameJavaName + */ + @NotNull + public String getFirstNameJavaName() { + return firstNameJavaName; + } + + /** + * Set the firstNameJavaName. + * + * @param firstNameJavaName + * the new firstNameJavaName + */ + public void setFirstNameJavaName(String firstNameJavaName) { + this.firstNameJavaName = firstNameJavaName; + } + + public int hashCode() { + return new HashCodeBuilder().append(firstNameJavaName).toHashCode(); + } + + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if (this.getClass()!= other.getClass()) { + return false; + } + User otherObject = ((User) other); + return new EqualsBuilder().append(firstNameJavaName, otherObject.firstNameJavaName).isEquals(); + } + + public String toString() { + return new ToStringBuilder(this).append("firstNameJavaName", firstNameJavaName).toString(); + } + +} +-----------------------------------com.gen.test.TestController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import com.gen.test.model.User; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface TestController { + + + /** + * No description + * + */ + public ResponseEntity getMethodJavaName(Long uriParamJavaName, String queryParamJavaName, String headerParamJavaName); + + /** + * No description + * + */ + public ResponseEntity putMethodJavaName(Long uriParamJavaName, + @Valid + User user); + +} +-----------------------------------com.gen.test.TestControllerDecorator.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import com.gen.test.model.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/test") +@Validated +public class TestControllerDecorator + implements TestController +{ + + @Autowired + private TestController testControllerDelegate; + + /** + * No description + * + */ + @RequestMapping(value = "/{uriParam}", method = RequestMethod.GET) + public ResponseEntity getMethodJavaName( + @PathVariable("uriParam") + Long uriParamJavaName, + @RequestParam(name = "queryParam") + String queryParamJavaName, + @RequestHeader(name = "headerParam") + String headerParamJavaName) { + return this.testControllerDelegate.getMethodJavaName(uriParamJavaName, queryParamJavaName, headerParamJavaName); + } + + /** + * No description + * + */ + @RequestMapping(value = "/{uriParam}/accept", method = RequestMethod.PUT) + public ResponseEntity putMethodJavaName( + @PathVariable("uriParam") + Long uriParamJavaName, + @Valid + @RequestBody + User user) { + return this.testControllerDelegate.putMethodJavaName(uriParamJavaName, user); + } + +} diff --git a/src/test/resources/validations/github/Issue61BaseClient.java.txt b/src/test/resources/validations/github/Issue61BaseClient.java.txt index ac8b6bf0..bde66031 100644 --- a/src/test/resources/validations/github/Issue61BaseClient.java.txt +++ b/src/test/resources/validations/github/Issue61BaseClient.java.txt @@ -35,7 +35,7 @@ public class SampleUnit implements Serializable } /** - * Returns the t_string. + * Returns the tString. * * @return * tString @@ -46,7 +46,7 @@ public class SampleUnit implements Serializable } /** - * Set the t_string. + * Set the tString. * * @param tString * the new tString