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:

  1. Click the Map policy in the canvas of the Assemble view.
    The property sheet opens.
  2. Optional: Provide a Title and Description for your Map policy.
  3. Click the Edit inputs icon The Edit inputs icon in the Input column.
  4. Add an input variable.
    1. Click + input.
    2. 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.
    3. 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.

    4. Optional: In the Content type field, specify the type of your input. If None is selected, the content type is treated as JSON.
    5. 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
      • [V5.0.4 or later]Generate from sample JSON
      • [V5.0.4 or later]Generate from sample XML
      .

      [V5.0.3 or later]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.

  5. Optional: To remove a variable, click the corresponding Remove input icon The Remove input icon.
  6. After you have added all of your input variables, click Done.
  7. Click the Edit outputs icon The Edit outputs icon in the Output column.
  8. Add an output variable.
    1. Click + output.
    2. 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.
    3. 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.

    4. Optional: In the Content type field, specify the type of your input. If None is selected, the content type is treated as JSON.
    5. 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
      • [V5.0.4 or later]Generate from sample JSON
      • [V5.0.4 or later]Generate from sample XML

      [V5.0.3 or later]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.

  9. Optional: To remove a variable, click the corresponding Remove output icon The Remove output icon.
  10. After you have added all of your output variables, click Done.
  11. Optional: [V5.0.3 or later] 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:
    1. For an Array, click add item. Provide a type for the item and then click the Add icon The Add icon.
    2. For an Object, click add property. Provide a name and type for the property and then click the Add icon 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.
  12. 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.
  13. 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.
  14. 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 The Remove input icon beside the input.

    [V5.0.3 or later]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.

  15. 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.
  16. 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.
  17. Optional: To delete all mappings to the output, click Delete.
  18. When you have configured your outputs, click OK.
  19. Optional: [V5.0.4 or later] To control the XML output of the map policy, click the Settings icon in the Map column.
    1. 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.
    2. [V5.0.8 or later] (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
    3. Click Done.

Results

You have configured a Map policy to transform and map variables in your assembly flow.