From 6ee42bebe686aa0de3b7e82238afbbaec4f98848 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 8 Oct 2015 23:31:57 +0800 Subject: [PATCH] add exception handling for #1267 --- .../java/io/swagger/codegen/DefaultCodegen.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 89cf238fa8dc..69d7cadbf0ad 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -492,10 +492,16 @@ public class DefaultCodegen { } else if (p instanceof DecimalProperty) { datatype = "number"; } else if (p instanceof RefProperty) { - RefProperty r = (RefProperty) p; - datatype = r.get$ref(); - if (datatype.indexOf("#/definitions/") == 0) { - datatype = datatype.substring("#/definitions/".length()); + try { + RefProperty r = (RefProperty) p; + datatype = r.get$ref(); + if (datatype.indexOf("#/definitions/") == 0) { + datatype = datatype.substring("#/definitions/".length()); + } + } catch (Exception e) { + LOGGER.warn("Error obtaining the datatype from RefProperty:" + p + ". Datatype default to Object"); + datatype = "Object"; + e.printStackTrace(); } } else { if (p != null) {