Configuring the Map policy in the user interface
The assemble view in API Designer provides a visual representation of the relations between the inputs and outputs of your Map policy.
Procedure
To configure your Map policy, complete the following steps:
-
Click the Map policy in the canvas
of the Assemble view.
The property sheet opens.
- Optional: Provide a Title and Description for your Map policy.
-
Click the Edit inputs icon
in the Input column.
-
Add an input variable.
- Click + input.
- In the Context variable field for an input, provide the location of your input variable in the context of the assembly. For a list of context variables, see API Connect context variables.
-
In the Name field for an input, provide a name for your input for use within only the Map policy.
Note:
You must ensure that the name that you provide does not exactly match the value of the Context variable field, or the result might be unpredictable.
- Optional: In the Content type field, specify the type of your input. If None is selected, the content type is treated as JSON.
-
In the Definition field for an input, provide the type of the variable.
The type can be one from a standard set of types, a definition that you have created for your API, or you can select Inline schema to provide a schema as one of the following options:
- YAML
- JSON
Generate from sample JSON
Generate from sample XML
If you select Object or Array,
you can create a schema through the user interface after you have clicked
Done and returned to the main view of the property sheet.
- Optional:
To remove a variable, click the corresponding Remove input icon
.
- After you have added all of your input variables, click Done.
-
Click the Edit outputs icon
in the Output column.
-
Add an output variable.
- Click + output.
- In the Context variable field for an output, provide the location of your output. This location can be a new context or one already established during the assembly. For a list of context variables, see API Connect context variables.
-
In the Name field for an output, provide a name for your variable to use within the Map policy and when it is included in its context at output. Note:
You must ensure that the name that you provide does not exactly match the value of the Context variable field, or the result might be unpredictable.
- Optional: In the Content type field, specify the type of your input. If None is selected, the content type is treated as JSON.
-
In the Definition field for an output, provide the type of the variable.
The type can be one from a standard set of types, a definition that you have created for your API, or you can select Inline schema to provide a schema as one of the following options:
- YAML
- JSON
Generate from sample JSON
Generate from sample XML
If you select Object or Array,
you can create a schema through the user interface after you have clicked
Done and returned to the main view of the property sheet.
- Optional:
To remove a variable, click the corresponding Remove output icon
.
- After you have added all of your output variables, click Done.
- Optional:
If you selected Object or Array for the type of
an input or output, create an inline schema definition through the user interface by completing the
following steps:
-
For an Array, click add item. Provide a type for
the item and then click the Add icon
.
-
For an Object, click add property. Provide a name
and type for the property and then click the Add icon
.
For objects and arrays created in this manner, you can continue to add items and properties, which can themselves be objects and arrays. -
For an Array, click add item. Provide a type for
the item and then click the Add icon
-
To connect an input variable to an output variable, click the circle that is directly on the
right of the input variable and then click the circle that is directly on the left of the output
variable.
A green line is drawn, linking the two variables together. You can connect multiple inputs to a single output, and a single input can be connected to multiple outputs.
-
To configure an output, whether it has inputs connected to it or not, click the circle directly
to the left of the output variable without first clicking on a circle for an input variable.
The Configure mapping window opens.
- Optional:
In the Mapped from section of the window, you can view which inputs are
mapped to the output you are editing. To remove an input, click the Remove
input icon
beside the input.
If the output is part of an array, further configuration options are available.
The array, or levels of array in the case of a multidimensional array, can be created by iterating
over arrays on the input side of the mapping. For each level of your array, select which array on
the input side is to be iterated over. In the Value field, you can use
$(this) to reference elements of an array that are not named within the
array. - Optional:
In the Value field, use GatewayScript to configure how any inputs are
transformed to produce the output.
For more information about valid code, see the Script section of the The Map policy structure topic.
- Optional: In the Default field, provide a static value, or an inline variable reference, to be applied to the output when no input value is provided. For information on inline variable references, see Inline references.
- Optional: To delete all mappings to the output, click Delete.
- When you have configured your outputs, click OK.
- Optional:
To control the XML output of the map policy, click the Settings icon in
the Map column.
-
In the Advanced XML options section, select one or both of the following
options:
- Include empty XML elements
- This option is selected by default and means that empty XML elements are included in the output of the Map policy. Clear the check box if you do not want empty XML elements to be included in the output of the Map policy.
- Inherit XML namespaces
- This option is selected by default and means that XML namespaces are inherited from the parent element. Clear the check box if you want the map policy to use explicit namespaces.
- Inline namespace declarations
- If the check box is selected (the default option), XML namespaces will be inserted into the document where they are first used. Clear the check box if you want namespaces to all be defined on the root element.
Note: These options effect the XML output only and have no effect on the JSON data.
(From API Connect Version 5.0.8.7)
From the Severity level for input data log messages list, select one of the
following options to specify the severity level for log messages that relate to input data: - error
- warn
- info
- Click Done.
-
In the Advanced XML options section, select one or both of the following
options: