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

commit e70c27e5c0f0b8cb93a2cf3b64ecdb790c625686
Author: Romain Manni-Bucau <rmannibu...@gmail.com>
AuthorDate: Mon Aug 8 16:12:41 2022 +0200

    [JOHNZON-387] ensure ref has enclosing name
---
 .../johnzon/jsonschema/generator/PojoGenerator.java       | 15 ++++++++++++---
 1 file changed, 12 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 7625a2fb..7f058ad9 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
@@ -209,7 +209,8 @@ public class PojoGenerator {
     protected String asType(final String javaName, final JsonObject schema, 
final boolean required) {
         final JsonValue ref = schema.get("$ref");
         if (ref != null && ref.getValueType() == JsonValue.ValueType.STRING) {
-            final String name = onRef(new 
Ref(JsonString.class.cast(ref).getString(), imports, attributes, nested));
+            final String name = onRef(new Ref(
+                    JsonString.class.cast(ref).getString(), 
configuration.getClassName(), imports, attributes, nested));
             if (name != null) {
                 return name;
             }
@@ -441,7 +442,9 @@ public class PojoGenerator {
     protected String onItemSchema(final String javaName, final JsonObject 
schema) {
         final JsonValue ref = schema.get("$ref");
         if (ref != null && ref.getValueType() == JsonValue.ValueType.STRING) {
-            final String name = onRef(new 
Ref(JsonString.class.cast(ref).getString(), imports, attributes, nested));
+            final String name = onRef(new Ref(
+                    configuration.getClassName(),
+                    JsonString.class.cast(ref).getString(), imports, 
attributes, nested));
             if (name != null) {
                 return name;
             }
@@ -659,18 +662,24 @@ public class PojoGenerator {
 
     public static class Ref {
         private final String ref;
+        private final String enclosingClass;
         private final Set<String> imports;
         private final List<Attribute> attributes;
         private final Map<String, String> nested;
 
-        private Ref(final String ref, final Set<String> imports,
+        private Ref(final String ref, final String enclosingClass, final 
Set<String> imports,
                     final List<Attribute> attributes, final Map<String, 
String> nested) {
             this.ref = ref;
+            this.enclosingClass = enclosingClass;
             this.imports = imports;
             this.attributes = attributes;
             this.nested = nested;
         }
 
+        public String getEnclosingClass() {
+            return enclosingClass;
+        }
+
         public String getRef() {
             return ref;
         }

Reply via email to