mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 11:55:42 +03:00
Guard against a null Meta property in the scale event API
This commit is contained in:
@@ -20,6 +20,17 @@ export default class Application extends JSONSerializer {
|
||||
*/
|
||||
arrayNullOverrides = null;
|
||||
|
||||
/**
|
||||
A list of keys that are converted to empty objects if their value is null.
|
||||
|
||||
objectNullOverrides = ['Object'];
|
||||
{ Object: null } => { Object: {} }
|
||||
|
||||
@property objectNullOverrides
|
||||
@type String[]
|
||||
*/
|
||||
objectNullOverrides = null;
|
||||
|
||||
/**
|
||||
A list of keys or objects to convert a map into an array of maps with the original map keys as Name properties.
|
||||
|
||||
@@ -90,6 +101,13 @@ export default class Application extends JSONSerializer {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.objectNullOverrides) {
|
||||
this.objectNullOverrides.forEach(key => {
|
||||
if (!hash[key]) {
|
||||
hash[key] = {};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.mapToArray) {
|
||||
this.mapToArray.forEach(conversion => {
|
||||
|
||||
@@ -2,4 +2,5 @@ import ApplicationSerializer from './application';
|
||||
|
||||
export default class ScaleEventSerializer extends ApplicationSerializer {
|
||||
separateNanos = ['Time'];
|
||||
objectNullOverrides = ['Meta'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user