diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index b7ff24208..cd4de1f31 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -632,23 +632,7 @@ function routes() { { queryParams: { credential_store_id: credentialStoreId } }, ) => credentialLibraries.where({ credentialStoreId }), ); - this.get( - '/credential-libraries/:id', - function ({ credentialLibraries }, { params: { id } }) { - const library = credentialLibraries.find(id); - // BE API only updates these fields if there's an update mask, otherwise they remain unmodified - // but we don't need this flow in our mocks, so we are deleting fields with null value - const { credentialMappingOverrides } = library; - if (Object.keys(credentialMappingOverrides || {}).length) { - Object.keys(credentialMappingOverrides).forEach((key) => { - if (credentialMappingOverrides[key] === null) { - delete credentialMappingOverrides[key]; - } - }); - } - return library; - }, - ); + this.get('/credential-libraries/:id'); this.post( '/credential-libraries', function ({ credentialStores, credentialLibraries }) { diff --git a/addons/api/mirage/serializers/credential-library.js b/addons/api/mirage/serializers/credential-library.js index 1d1506f81..66146de29 100644 --- a/addons/api/mirage/serializers/credential-library.js +++ b/addons/api/mirage/serializers/credential-library.js @@ -14,6 +14,17 @@ export default ApplicationSerializer.extend({ arguments, ); json.credential_store_id = model.credentialStoreId; + + // BE API only updates these fields if there's an update mask, otherwise they remain unmodified + // but we don't need this flow in our mocks, so we are deleting fields with null value + + if (json.credential_mapping_overrides) { + Object.keys(json.credential_mapping_overrides).forEach((key) => { + if (json.credential_mapping_overrides[key] === null) { + delete json.credential_mapping_overrides[key]; + } + }); + } return json; }, });