From d14be82d2b549dc5bd252ad0f87b2772447d65e2 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Fri, 6 Nov 2015 16:54:07 -0800 Subject: [PATCH] added null check for #132 --- .../parser/processors/ExternalRefProcessor.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java index 639370675a..50f13f1e1f 100644 --- a/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java +++ b/modules/swagger-parser/src/main/java/io/swagger/parser/processors/ExternalRefProcessor.java @@ -60,14 +60,15 @@ public String processRefToExternalDefinition(String $ref, RefFormat refFormat) { //If this is a new model, then check it for other sub references //Loop the properties and recursively call this method; Map subProps = model.getProperties(); - for(Map.Entry prop: subProps.entrySet()){ - if(prop.getValue() instanceof RefProperty){ - RefProperty subRef = (RefProperty)prop.getValue(); - subRef.set$ref(processRefToExternalDefinition(subRef.get$ref(),subRef.getRefFormat())); - } + if(subProps != null) { + for (Map.Entry prop : subProps.entrySet()) { + if (prop.getValue() instanceof RefProperty) { + RefProperty subRef = (RefProperty) prop.getValue(); + subRef.set$ref(processRefToExternalDefinition(subRef.get$ref(), subRef.getRefFormat())); + } + } } swagger.addDefinition(newRef, model); - } return newRef;