diff --git a/cli.js b/cli.js
index d93e807ef778d048608140974e672b8cf7443b6e..00c108483c8a6f33ed05bf25197af5bee579c321 100755
--- a/cli.js
+++ b/cli.js
@@ -64,7 +64,10 @@ const { argv } = Optimist
   .describe('p', 'A comma separated list with custom properties which should be also in the description of an element.')
   .alias('h', 'header')
   .describe('h', 'if the value is false the header will be skipped')
-  .default('h', true);
+  .default('h', true)
+  .alias('u', 'definitions')
+  .describe('u', 'folder containing definition file(s)')
+  .default('u', './');
 
 const docs = _.fromPairs(
   _.toPairs(argv)
diff --git a/lib/schema.js b/lib/schema.js
index 2869a943500b124382fc938afa3476616d89a4c0..d00fda4b9f4a628a234bd5ed82ed12eb4fc3f33c 100644
--- a/lib/schema.js
+++ b/lib/schema.js
@@ -34,6 +34,7 @@ const absUrlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
 
 let smap; // TODO remove global
 let sPath;
+let definitionsDir;
 const wmap = {};
 function get$refType(refValue) {
   let startpart = '';
@@ -122,6 +123,22 @@ const resolve$ref = Promise.method((val, base$id) => {
       return processISchema(ischema, refArr.startpart);
     }
   }
+  const $ref = val.$ref.split('#');
+  if ($ref[0].length) {
+    const uri = $ref[0];
+    const raw = fs.readFileSync(definitionsDir + uri.split('/').pop(-1));
+    const definitions = JSON.parse(raw);
+    console.log('defitinitons.$id', definitions.$id, 'uri', uri);
+    if (definitions.$id !== uri) return undefined;
+
+    const keys = $ref[1].split('/');
+    let ref = definitions;
+    keys.forEach((key) => {
+      if (key.length) ref = ref[key];
+    });
+    return ref;
+  }
+
   return undefined;
 });
 const processFurther = Promise.method((val, key, $id) => {
@@ -438,6 +455,7 @@ Schema.setSchemaPathMap = function (schemaMap) {
  */
 Schema.process = (schemaMap, schemaPath, docDir, schemaDir,
   metaElements, readme, docs, consoleArgs) => {
+  definitionsDir = consoleArgs.u;
   smap = schemaMap;
   const keys = Object.keys(schemaMap);
   return Promise.mapSeries(keys, (schemaKey) => {
@@ -461,6 +479,7 @@ Schema.process = (schemaMap, schemaPath, docDir, schemaDir,
           mSchema.metaElements = metaElements;
           if (mSchema.properties) {
             Object.keys(mSchema.properties).forEach((method) => {
+              if (!mSchema.properties[method].properties) return;
               const { input } = mSchema.properties[method].properties;
               const { output } = mSchema.properties[method].properties;
               if (input) {