Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

es-mapping-to-schema

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-mapping-to-schema - npm Package Compare versions

Comparing version 3.2.4 to 3.3.0

14

index.js

@@ -29,4 +29,8 @@ const _ = require('lodash');

schema[name] = determineType(mapping[name], {}, schemaType, nextOptions);
result[name] = recurseMappingObjects(mapping[name], schema[name], schemaType, nextOptions, nextLocalOptions);
// if (nextOptions.isArray) {
// console.log('name: ' + name);
// } else {
schema[name] = determineType(mapping[name], {}, schemaType, nextOptions);
result[name] = recurseMappingObjects(mapping[name], schema[name], schemaType, nextOptions, nextLocalOptions);
// }

@@ -41,6 +45,6 @@ return result;

if (mapping.properties || mapping.type === 'object' || mapping.type === 'nested') {
if (mapping.properties || mapping.type === 'object' || mapping.type === 'nested' || options.isArray) {
if (options.isArray) {
schema.items = {};
schema.items.type = 'object';
schema.items.type = determineType(mapping, {}, schemaType, Object.assign({}, options, {isArray: false})).type;

@@ -164,3 +168,3 @@ if (mapping.properties) {

if (_.includes(DIRECT_COPY_TYPES, type)) {
return type === 'object' && isArray ? 'array' : type;
return isArray ? 'array' : type;
} else {

@@ -167,0 +171,0 @@ switch (type) {

{
"name": "es-mapping-to-schema",
"version": "3.2.4",
"version": "3.3.0",
"description": "Convert Elasticsearch mappings to Schema Inspector schemas",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1218,2 +1218,45 @@ const chai = require('chai');

});
it('should allow arrays of simple objects', () => {
const mapping = {
properties: {
arrayOfStrings: {
type: 'string'
}
}
};
const expectedSchema = {
type: 'object',
properties: {
arrayOfStrings: {
type: 'array',
items: {
type: 'string'
}
}
}
};
const schemas = MappingToSchema(mapping, {
arrayPaths: [
'arrayOfStrings'
],
sanitization: {
all: {
types: [
'object',
'string',
'integer',
'number',
'array',
'boolean',
'date'
]
}
}
});
expect(schemas.validation).to.eql(expectedSchema);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc