Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 9f64fd6

Browse files
author
Chris Wiechmann
committed
Fixed the way custom properties with a parent are created
1 parent 424f61b commit 9f64fd6

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/src/customProperties.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,9 @@ async function mergeCustomProperties(params, options) {
6666
desiredTemplate.mappings.properties[customPropertiesSettings.parent] = {};
6767
}
6868
if(type == "custom") {
69-
if(customPropertiesSettings.parent) {
70-
desiredTemplate.mappings.properties[customPropertiesSettings.parent][`customProperties.${customPropertyName}`] = { type: "text", norms: false, fields: { "keyword": { type: "keyword"} } };
71-
} else {
72-
desiredTemplate.mappings.properties[`customProperties.${customPropertyName}`] = { type: "text", norms: false, fields: { "keyword": { type: "keyword"} } };
73-
}
69+
desiredTemplate.mappings.properties[`${customPropertiesSettings.parent}customProperties.${customPropertyName}`] = { type: "text", norms: false, fields: { "keyword": { type: "keyword"} } };
7470
} else {
75-
if(customPropertiesSettings.parent) {
76-
desiredTemplate.mappings.properties[customPropertiesSettings.parent][`customProperties.${customPropertyName}`] = { type: "keyword"};
77-
} else {
78-
desiredTemplate.mappings.properties[`customProperties.${customPropertyName}`] = { type: "keyword"};
79-
}
71+
desiredTemplate.mappings.properties[`${customPropertiesSettings.parent}customProperties.${customPropertyName}`] = { type: "keyword"};
8072
}
8173
return true;
8274
}

apibuilder4elastic/custom_flow_nodes/api-builder-plugin-axway-api-management/test/test-customProperties-MappingMerge.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@ describe('Merge custom properties tests', () => {
125125
customProperties: JSON.parse(fs.readFileSync('./test/testInput/customPropertiesConfig.json'), null),
126126
desiredIndexTemplate: JSON.parse(fs.readFileSync('./test/testInput/desiredIndexTemplate.json'), null),
127127
actualIndexTemplate: JSON.parse(fs.readFileSync('./test/testInput/actualIndexTemplate.json'), null),
128-
customPropertiesSettings: { merge: true, parent: "transactionSummary" }
128+
customPropertiesSettings: { merge: true, parent: "transactionSummary." }
129129
});
130130

131131
expect(output).to.equal('next');
132-
expect(value.mappings.properties.transactionSummary['customProperties.customProperty1']).to.be.an('Object');
133-
expect(value.mappings.properties.transactionSummary['customProperties.customProperty1']).to.deep.equal({type: "text", norms: false, fields: {keyword: { type: "keyword"}}});
134-
expect(value.mappings.properties.transactionSummary['customProperties.customProperty2']).to.be.an('Object');
135-
expect(value.mappings.properties.transactionSummary['customProperties.customProperty2'].type).to.equal('keyword');
136-
expect(value.mappings.properties.transactionSummary['customProperties.customProperty3']).to.be.an('Object');
137-
expect(value.mappings.properties.transactionSummary['customProperties.customProperty3'].type).to.equal('keyword');
132+
expect(value.mappings.properties['transactionSummary.customProperties.customProperty1']).to.be.an('Object');
133+
expect(value.mappings.properties['transactionSummary.customProperties.customProperty1']).to.deep.equal({type: "text", norms: false, fields: {keyword: { type: "keyword"}}});
134+
expect(value.mappings.properties['transactionSummary.customProperties.customProperty2']).to.be.an('Object');
135+
expect(value.mappings.properties['transactionSummary.customProperties.customProperty2'].type).to.equal('keyword');
136+
expect(value.mappings.properties['transactionSummary.customProperties.customProperty3']).to.be.an('Object');
137+
expect(value.mappings.properties['transactionSummary.customProperties.customProperty3'].type).to.equal('keyword');
138138
});
139139
});
140140
});

apibuilder4elastic/elasticsearch_config/index_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"name": "traffic-details",
2323
"customProperties": {
2424
"merge": true,
25-
"parent": "transactionSummary"
25+
"parent": "transactionSummary."
2626
}
2727
},
2828
"ilm" : {

0 commit comments

Comments
 (0)