Merge pull request #979 from hashicorp/chore-normalize-non-array-filters

chore: support `filters` when it is a string by converting to an array
This commit is contained in:
Randall Morey authored and GitHub committed 2022-02-16 17:03:57 -05:00
commit cb22248fc8
1 file changed
+16
+16
View File
@@ -1,4 +1,5 @@
import ApplicationSerializer from './application';
import { copy } from 'ember-copy';
const fieldByType = {
aws: ['preferred_endpoints', 'filters'],
@@ -69,4 +70,19 @@ export default class HostSetSerializer extends ApplicationSerializer {
}
return value;
}
/**
* Temporarily converts `filters` to an array if it is a string. This is a
* quirk of the API.
*
* TODO: remove once API consistently returns arrays.
*/
normalize(typeClass, hash, ...rest) {
const normalizedHash = copy(hash, true);
if (typeof normalizedHash?.filters === 'string') {
normalizedHash.filters = [normalizedHash.filters];
}
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
return normalized;
}
}