es-mapping-to-schema
Advanced tools
Comparing version 3.3.7 to 3.3.8
@@ -67,3 +67,3 @@ const _ = require('lodash'); | ||
_.forEach(localOptions, (value, field) => { | ||
if (options.isArray) { | ||
if (options.isArray && field !== 'optional') { | ||
schema.items[field] = value; | ||
@@ -70,0 +70,0 @@ } else { |
{ | ||
"name": "es-mapping-to-schema", | ||
"version": "3.3.7", | ||
"version": "3.3.8", | ||
"description": "Convert Elasticsearch mappings to Schema Inspector schemas", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
53
test.js
@@ -1477,2 +1477,55 @@ const chai = require('chai'); | ||
it('should NOT nest sanitization in array for individual optional fields', () => { | ||
const mapping = { | ||
properties: { | ||
someString: { | ||
type: 'string' | ||
} | ||
} | ||
}; | ||
const expectedSchema = { | ||
type: 'object', | ||
properties: { | ||
someString: { | ||
type: 'array', | ||
optional: true, | ||
items: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
}; | ||
const schemas = MappingToSchema(mapping, { | ||
arrayPaths: [ | ||
'someString' | ||
], | ||
sanitization: { | ||
all: { | ||
types: [ | ||
'object', | ||
'integer', | ||
'string', | ||
'number', | ||
'array', | ||
'boolean', | ||
'date' | ||
] | ||
}, | ||
paths: { | ||
optional: [ | ||
{ | ||
path: 'someString', | ||
value: true | ||
} | ||
] | ||
} | ||
} | ||
}); | ||
expect(schemas.sanitization).to.eql(expectedSchema); | ||
}); | ||
it('should apply strict sanitization to arrays of objects', () => { | ||
@@ -1479,0 +1532,0 @@ const mapping = { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
189567
6049
12
1