diff --git a/README.md b/README.md index 5ac59f9..bf34610 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ client start or on-demand) - list of classes in those packages to exclude - list of fields to exclude - list of custom annotation classes to include in JSON + - whether to output simple or full type names + - the output file name - Servlet offers built-in [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) support ## Use diff --git a/valdr-bean-validation-demo/src/main/resources/valdr-bean-validation.json b/valdr-bean-validation-demo/src/main/resources/valdr-bean-validation.json index 5c85e47..ea6bbf7 100644 --- a/valdr-bean-validation-demo/src/main/resources/valdr-bean-validation.json +++ b/valdr-bean-validation-demo/src/main/resources/valdr-bean-validation.json @@ -4,5 +4,6 @@ "excludedFields": ["com.github.valdr.demo.model.Person#ignoredField"], "customAnnotationClasses": ["org.hibernate.validator.constraints.CreditCardNumber"], "corsAllowOriginPattern": "*", + "outputFullTypeName": false, "outputFile": "${project.build.directory}/${project.build.finalName}/constraints.json" } \ No newline at end of file diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java b/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java index d31acac..fdbae5f 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java @@ -56,7 +56,8 @@ public String parse() { ClassConstraints classValidationRules = new AnnotatedClass(clazz, options.getExcludedFields(), allRelevantAnnotationClasses).extractValidationRules(); if (classValidationRules.size() > 0) { - classNameToValidationRulesMap.put(clazz.getSimpleName(), classValidationRules); + String name = options.getOutputFullTypeName() ? clazz.getName() : clazz.getSimpleName(); + classNameToValidationRulesMap.put(name, classValidationRules); } } } diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/Options.java b/valdr-bean-validation/src/main/java/com/github/valdr/Options.java index ea02942..3c4a08c 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/Options.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/Options.java @@ -59,6 +59,15 @@ public final class Options { */ private String corsAllowOriginPattern = StringUtils.EMPTY; + /** + * Whether the output type name should be the simple name of a type (default) or the full type name (i.e., including + * the package name). + * + * Mandatory: no + * Use: CLI/Servlet + */ + private Boolean outputFullTypeName = Boolean.FALSE; + /** * File to which the validation meta-model (JSON) is written. Missing folders are created automatically. If omitted * the output is sent to system out.