* Fix #697 JSON Schema enum dropdown not working inside an array * Make schema in unit test valid by adding `type: 'object'`
This commit is contained in:
parent
f005c437db
commit
3ccdeeec40
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue