diff --git a/HISTORY.md b/HISTORY.md index ba70874..908c18f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,11 @@ https://github.com/josdejong/jsoneditor +## not yet published, version 5.32.6 + +- Fixed #697: JSON Schema enum dropdown not working inside an array. + + ## 2019-04-27, version 5.32.5 - Fixed a bug in the JMESPath query wizard which didn't correctly handle diff --git a/src/js/Node.js b/src/js/Node.js index 3613f03..38ae2c5 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -2659,12 +2659,6 @@ Node._findSchema = function (schema, schemaRefs, path) { } } } - else if (childSchema.items && childSchema.items.properties) { - childSchema = childSchema.items.properties[key]; - if (childSchema) { - foundSchema = Node._findSchema(childSchema, schemaRefs, nextPath); - } - } else if (typeof key === 'string' && childSchema.properties) { if (!(key in childSchema.properties)) { foundSchema = null; diff --git a/test/Node.test.js b/test/Node.test.js index f083454..34243bf 100644 --- a/test/Node.test.js +++ b/test/Node.test.js @@ -27,6 +27,34 @@ describe('Node', function () { assert.strictEqual(Node._findSchema(schema, {}, path), schema.properties.child); }); + it('should find schema inside an array item', function () { + var schema = { + properties: { + job: { + type: 'array', + items: { + type: 'object', + properties: { + company: { + enum: ['test1', 'test2'] + } + } + } + } + } + }; + + assert.strictEqual(Node._findSchema(schema, {}, []), schema); + + assert.strictEqual(Node._findSchema(schema, {}, ['job']), schema.properties.job); + + assert.strictEqual(Node._findSchema(schema, {}, ['job', 0]), + schema.properties.job.items); + + assert.strictEqual(Node._findSchema(schema, {}, ['job', 0, 'company']), + schema.properties.job.items.properties.company); + }); + it('should find schema within multi-level object properties', function () { var schema = { type: 'object',