@@ -286,6 +286,11 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
286286 if (props != null ) {
287287 for (String propName : props .keySet ()) {
288288 Schema prop = props .get (propName );
289+
290+ if (prop == null ) {
291+ continue ;
292+ }
293+
289294 String schemaName = resolveModelName (prop .getTitle (), modelPrefix + "_" + propName );
290295 // Recurse to create $refs for inner models
291296 gatherInlineModels (prop , schemaName );
@@ -308,13 +313,15 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
308313 if (schema .getAdditionalProperties () != null ) {
309314 if (schema .getAdditionalProperties () instanceof Schema ) {
310315 Schema inner = (Schema ) schema .getAdditionalProperties ();
311- String schemaName = resolveModelName (schema .getTitle (), modelPrefix + this .inlineSchemaOptions .get ("MAP_ITEM_SUFFIX" ));
312- // Recurse to create $refs for inner models
313- gatherInlineModels (inner , schemaName );
314- if (isModelNeeded (inner )) {
315- // If this schema should be split into its own model, do so
316- Schema refSchema = this .makeSchemaInComponents (schemaName , inner );
317- schema .setAdditionalProperties (refSchema );
316+ if (inner != null ) {
317+ String schemaName = resolveModelName (schema .getTitle (), modelPrefix + this .inlineSchemaOptions .get ("MAP_ITEM_SUFFIX" ));
318+ // Recurse to create $refs for inner models
319+ gatherInlineModels (inner , schemaName );
320+ if (isModelNeeded (inner )) {
321+ // If this schema should be split into its own model, do so
322+ Schema refSchema = this .makeSchemaInComponents (schemaName , inner );
323+ schema .setAdditionalProperties (refSchema );
324+ }
318325 }
319326 }
320327 }
@@ -334,10 +341,6 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
334341 if (schema instanceof ArraySchema ) {
335342 ArraySchema array = (ArraySchema ) schema ;
336343 Schema items = array .getItems ();
337- /*if (items.getTitle() != null) {
338- LOGGER.info("schema title {}", items);
339- throw new RuntimeException("getTitle for array item is not null");
340- }*/
341344 if (items == null ) {
342345 LOGGER .error ("Illegal schema found with array type but no items," +
343346 " items must be defined for array schemas:\n " + schema .toString ());
@@ -360,6 +363,9 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
360363 List <Schema > newAllOf = new ArrayList <Schema >();
361364 boolean atLeastOneModel = false ;
362365 for (Object inner : schema .getAllOf ()) {
366+ if (inner == null ) {
367+ continue ;
368+ }
363369 String schemaName = resolveModelName (((Schema ) inner ).getTitle (), modelPrefix + "_allOf" );
364370 // Recurse to create $refs for inner models
365371 gatherInlineModels ((Schema ) inner , schemaName );
@@ -392,6 +398,9 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
392398 if (schema .getAnyOf () != null ) {
393399 List <Schema > newAnyOf = new ArrayList <Schema >();
394400 for (Object inner : schema .getAnyOf ()) {
401+ if (inner == null ) {
402+ continue ;
403+ }
395404 String schemaName = resolveModelName (((Schema ) inner ).getTitle (), modelPrefix + "_anyOf" );
396405 // Recurse to create $refs for inner models
397406 gatherInlineModels ((Schema ) inner , schemaName );
@@ -407,6 +416,9 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
407416 if (schema .getOneOf () != null ) {
408417 List <Schema > newOneOf = new ArrayList <Schema >();
409418 for (Object inner : schema .getOneOf ()) {
419+ if (inner == null ) {
420+ continue ;
421+ }
410422 String schemaName = resolveModelName (((Schema ) inner ).getTitle (), modelPrefix + "_oneOf" );
411423 // Recurse to create $refs for inner models
412424 gatherInlineModels ((Schema ) inner , schemaName );
@@ -423,12 +435,14 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
423435 // Check not schema
424436 if (schema .getNot () != null ) {
425437 Schema not = schema .getNot ();
426- String schemaName = resolveModelName (schema .getTitle (), modelPrefix + "_not" );
427- // Recurse to create $refs for inner models
428- gatherInlineModels (not , schemaName );
429- if (isModelNeeded (not )) {
430- Schema refSchema = this .makeSchemaInComponents (schemaName , not );
431- schema .setNot (refSchema );
438+ if (not != null ) {
439+ String schemaName = resolveModelName (schema .getTitle (), modelPrefix + "_not" );
440+ // Recurse to create $refs for inner models
441+ gatherInlineModels (not , schemaName );
442+ if (isModelNeeded (not )) {
443+ Schema refSchema = this .makeSchemaInComponents (schemaName , not );
444+ schema .setNot (refSchema );
445+ }
432446 }
433447 }
434448 }
@@ -629,6 +643,9 @@ private void flattenComponents() {
629643 List <String > modelNames = new ArrayList <String >(models .keySet ());
630644 for (String modelName : modelNames ) {
631645 Schema model = models .get (modelName );
646+ if (model == null ) {
647+ continue ;
648+ }
632649 if (ModelUtils .isAnyOf (model )) { // contains anyOf only
633650 gatherInlineModels (model , modelName );
634651 } else if (ModelUtils .isOneOf (model )) { // contains oneOf only
0 commit comments