From c70cdfdaed69129c57a4c2e3301ff52ca51e17f2 Mon Sep 17 00:00:00 2001 From: Evdokim Kovach Date: Tue, 29 Dec 2015 14:39:54 +0100 Subject: [PATCH] an additional null check added This additional check prevent invocation of `indexOf()` on possible null `ref` variable and improve therefore error messaging for malformed yaml files. Before: ``` Cannot read property 'indexOf' of null ``` After: ``` Uncaught TypeError: Swagger 2.0 does not support null types ``` --- lib/resolver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/resolver.js b/lib/resolver.js index deb688680..7095a907f 100644 --- a/lib/resolver.js +++ b/lib/resolver.js @@ -540,7 +540,7 @@ Resolver.prototype.resolveTo = function (root, property, resolutionTable, locati var sp, i; var ref = property.$ref; var lroot = root; - if (typeof ref !== 'undefined') { + if ((typeof ref !== 'undefined') && (ref !== null)) { if(ref.indexOf('#') >= 0) { var parts = ref.split('#');