ts-json-schema
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -272,20 +272,23 @@ "use strict"; | ||
var propBuilder; | ||
var rootSchema = this.schema; | ||
var rootSchemaProperty; | ||
if (Array.isArray(path)) { | ||
rootSchemaProperty = path[path.length - 1]; | ||
for (var i = 1; i < path.length; i++) { | ||
var propPath = path[i - 1]; | ||
if (!rootSchema.properties) { | ||
rootSchema.properties = {}; | ||
} | ||
if (!rootSchema.properties[propPath]) { | ||
rootSchema.properties[propPath] = {}; | ||
} | ||
rootSchema = rootSchema.properties[propPath]; | ||
} | ||
var propertyRoot = this.schema; | ||
var propertyKey; | ||
if (typeof path === 'string') { | ||
propertyKey = path; | ||
path = [path]; | ||
} | ||
else { | ||
rootSchemaProperty = path; | ||
propertyKey = path[path.length - 1]; | ||
} | ||
for (var i = 0; i < path.length; i++) { | ||
var curentKey = path[i]; | ||
if (!propertyRoot.properties) { | ||
propertyRoot.properties = {}; | ||
} | ||
if (!propertyRoot.properties[curentKey]) { | ||
propertyRoot.properties[curentKey] = {}; | ||
} | ||
if (i < path.length - 1) { | ||
propertyRoot = propertyRoot.properties[curentKey]; | ||
} | ||
} | ||
if (typeof schema === 'function') { | ||
@@ -295,5 +298,5 @@ cb = schema; | ||
else if (schema) { | ||
rootSchema.properties[rootSchemaProperty] = schema; | ||
propertyRoot.properties[propertyKey] = schema; | ||
} | ||
propBuilder = new JsonSchemaPropertyBuilder(rootSchemaProperty, rootSchema); | ||
propBuilder = new JsonSchemaPropertyBuilder(propertyKey, propertyRoot); | ||
if (cb) { | ||
@@ -300,0 +303,0 @@ cb(propBuilder); |
{ | ||
"name": "ts-json-schema", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A fluent builder for json schemas", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127435
882