Prism · Transform

$renameKeys

Renames keys of an object where they stand, so the order of the keys is kept. A key that is not there is passed over.

The source
{
  endpoint: {
    url: '/api/todos',
    body: { done: false },
    transform: 'rows',
  },
}
The config
{
  $renameKeys: {
    from: { $ref: '$.endpoint' },
    map: {
      body: 'request',
      transform: 'response',
      headers: 'meta',
    },
  },
}
What comes out
{
  url: '/api/todos',
  request: { done: false },
  response: 'rows',
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.