Skip to content

Commit

Permalink
v1.3.0: fix for schema definitions handling
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Oct 26, 2018
1 parent ca7d585 commit 9b4446d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/twbschema.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ window.twbschema = (function () {
var counter = 0
// control row colors
var rowBgClass = ''
// handle schema definitions
var defs

var gen = function (json, dotNotation) {
var i
Expand All @@ -25,6 +27,10 @@ window.twbschema = (function () {
if (!dotNotation) {
root = true
dotNotation = ''
// check definitions on root object
if (json.definitions) {
defs = json.definitions
}
}

// start treating schema
Expand All @@ -33,8 +39,6 @@ window.twbschema = (function () {
var req = json.required
// merge all object properties
var props = Object.assign({}, json.properties, json.patternProperties)
// handle schema definitions
var defs = json.definitions

// check each object property
// first row without border
Expand Down Expand Up @@ -66,7 +70,7 @@ window.twbschema = (function () {
var model = prop.$ref.replace('#/definitions/', '')
if (defs.hasOwnProperty(model)) {
// merge definition model to prop object
Object.assign(prop, defs[model])
prop = Object.assign({}, defs[model], prop)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twbschema",
"version": "1.2.0",
"version": "1.3.0",
"description": "Docs with Boostrap 4 for your JSON schema types",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 9b4446d

Please sign in to comment.