This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/johnzon.git
The following commit(s) were added to refs/heads/master by this push: new 4a5fdee3 adding JSON-Schema to onEnum callback 4a5fdee3 is described below commit 4a5fdee3ab68d38f2af0d53a81f21fb960b4167b Author: Romain Manni-Bucau <rmannibu...@gmail.com> AuthorDate: Wed Aug 10 15:32:32 2022 +0200 adding JSON-Schema to onEnum callback --- .../org/apache/johnzon/jsonschema/generator/PojoGenerator.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java b/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java index e6cb4ab4..2b36e3cd 100644 --- a/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java +++ b/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java @@ -277,7 +277,7 @@ public class PojoGenerator { case "string": final JsonValue enumList = schema.get("enum"); if (enumList != null && enumList.getValueType() == JsonValue.ValueType.ARRAY) { - return onEnum(javaName, enumList); + return onEnum(javaName, enumList, schema); } return "String"; case "number": @@ -331,8 +331,8 @@ public class PojoGenerator { } } - protected String onEnum(final String javaName, final JsonValue enumList) { - final String className = configuration.getClassName() + Character.toUpperCase(javaName.charAt(0)) + javaName.substring(1); + protected String onEnum(final String javaName, final JsonValue enumList, final JsonObject schema) { + final String className = enumName(javaName, schema); final Map<String, String> values = enumList.asJsonArray().stream() .map(JsonString.class::cast) .map(JsonString::getString) @@ -372,6 +372,10 @@ public class PojoGenerator { return className; } + protected String enumName(final String javaName, final JsonObject schema) { + return configuration.getClassName() + Character.toUpperCase(javaName.charAt(0)) + javaName.substring(1); + } + protected String onObjectAttribute(final String javaName, final JsonObject schema) { final JsonValue additionalProperties = schema.get("additionalProperties"); final JsonValue properties = schema.get("properties");