@@ -148,8 +148,10 @@ private Schema<?> buildObjectSchema(TypeMirror type) {
148148
149149 Schema objectSchema = schemas .get (objectSchemaKey );
150150 if (objectSchema == null ) {
151- objectSchema = createObjectSchema (type );
151+ // Put first to resolve recursive stack overflow
152+ objectSchema = new ObjectSchema ();
152153 schemas .put (objectSchemaKey , objectSchema );
154+ populateObjectSchema (type , objectSchema );
153155 }
154156
155157 Schema ref = new Schema ();
@@ -209,10 +211,7 @@ private String getObjectSchemaName(TypeMirror type) {
209211 return canonicalName ;
210212 }
211213
212- private ObjectSchema createObjectSchema (TypeMirror objectType ) {
213-
214- ObjectSchema objectSchema = new ObjectSchema ();
215-
214+ private <T > void populateObjectSchema (TypeMirror objectType , Schema <T > objectSchema ) {
216215 Element element = types .asElement (objectType );
217216 for (VariableElement field : allFields (element )) {
218217 Schema <?> propSchema = toSchema (field .asType ());
@@ -223,7 +222,6 @@ private ObjectSchema createObjectSchema(TypeMirror objectType) {
223222 setFormatFromValidation (field , propSchema );
224223 objectSchema .addProperties (field .getSimpleName ().toString (), propSchema );
225224 }
226- return objectSchema ;
227225 }
228226
229227 private void setFormatFromValidation (Element element , Schema <?> propSchema ) {
0 commit comments