From eaca151564c7d723677866b5dfb50f81b081412d Mon Sep 17 00:00:00 2001 From: jgabriels Date: Wed, 7 Feb 2018 21:06:05 -0600 Subject: [PATCH] added support for examples if no default. Also added support for properties when type is not an object --- schema-instantiator.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/schema-instantiator.js b/schema-instantiator.js index 6e03037..b1cefcd 100644 --- a/schema-instantiator.js +++ b/schema-instantiator.js @@ -86,6 +86,9 @@ function instantiatePrimitive (val) { return val.default } + if (val.example) { + return val.example + } return typesInstantiator[type] } @@ -137,7 +140,7 @@ function instantiate (schema, options) { var i var type = obj.type // We want non-primitives objects (primitive === object w/o properties). - if (type === 'object' && obj.properties) { + if (obj && obj.properties) { data[name] = data[name] || { } // Visit each property.