extract
Use the extract policy to extract and transform data from fields in the API context.
Gateway support
Gateway | Policy version |
---|---|
DataPower® API Gateway | 2.0.0 |
This topic describes how to configure the policy in your OpenAPI source; for details on how to configure the policy in the assembly user interface, see Extract.
About
The extract policy specifies the data source that contains the content to transform, the fields that contain the content, and expressions that define how to transform the content. You use a subset of JSONata notation to specify the fields to extract and transform. For more information, see Constructing JSONata expressions to extract and transform data.
The input to the extract policy must be parsed data. One way to produce parsed data is to add a parse policy before the extract policy in your assembly.
- extract:
version: 2.0.0
title: title
root: data source
extracts:
- capture: path expression that identifies the field
transform: expression that defines how to transform the content
.
.
.
description: description
Apply this policy by adding an
assembly
extension with an execute
field to your OpenAPI
definition file.Properties
Property label | Required | Description | Data type |
---|---|---|---|
version | Yes | The policy version number. You must specify a version for the policy that is compatible with the gateway that you are using. When the API is published, if the version is incompatible with the gateway, a validation error is thrown that specifies the available versions. |
string |
title | Yes | The title of the policy. The default value is |
string |
description | No | A description of the policy. | string |
root | Yes | The data source that contains the content to transform. The default value is |
string |
capture | Yes | The path expression that identifies the field. The default setting is |
string |
transform | Yes | The expression that defines how to transform the content. | string |
Example
account
field to include only
the last 4 characters.- extract:
version: 2.0.0
title: extract
root: message.body
extracts:
- capture: $.members.policy.**.account
transform: $substring($,-4)
description: Include only the last 4 characters of the account field.