# Overview

The interface list function is used to maintain the aggregate interface. The aggregate interface is a simple interface from the perspective of the external caller. The response results are obtained through parameter input requests. The internal implementation will call multiple underlying back-end services and aggregate and convert the multiple call results into The data format desired by the external caller. For more details, please see the service orchestration introduction. The following describes the operation of the interface list function.

# Interface list

Menu location: Service Orchestration > Interface List. Click the menu to enter the interface list page, as shown in the figure.

manager_aggregate_list_query

# Add new interface

Click the Add button to pop up the new window, as shown in the figure.

manager_aggregate_add_1

# Basic information

manager_aggregate_add_2

Belonging service: The service to which the interface belongs. For more details, please see the service management function introduction. This is required;

Interface name: Interface name, used for display, cannot exceed 200 characters in length, required;

Method: interface request method type, optional GET|POST, required;

Path: interface request path suffix, the length cannot exceed 2000 characters, required;

Developer: The developer responsible for the interface, the length cannot exceed 200 characters;

Description: Interface function description, the length cannot exceed 2000 characters;

For example, the service is set to my-test-service, the method is set to POST, the path is set to test-aggregate-post, and the corresponding aggregation interface request is POST http://{FizzGate integration platform ip address}:{port port}/proxy /my-test-service/test-aggregate-post.

# Configuration input

Most of the input parameters of the aggregation interface are defined through JSON Schema. Let’s briefly introduce JSON Schema below.

# Introduction to JSON Schema

JSON Schema is actually JSON data and is used to annotate and verify JSON documents. It can be compared to XML Schema. The latest version is 2019-09.

As ordinary users, we do not need to understand the specification content of JSON Schema, as long as we can build JSON Schema.

To understand JSON Schema, you must first understand what JSON is. JSON is the abbreviation of JavaScript Object Notation, a simple data exchange format. Originally JSON was based on JavaScript and was widely used on the World Wide Web. Due to its concise and clear hierarchical structure and ease of reading, it is used in more and more scenarios.

JSON contains the following data structure:

  • object:
{ "key1": "value1", "key2": "value2" }
  • array:
[ "first", "second", "third" ]
  • number:
42
3.1415926
  • string:
"This is a string"
  • boolean:
true
false
  • null:
null

Through the above simple data types, complex structured data can be constructed. Here are two examples:

{
"name": "George Washington",
"birthday": "February 22, 1732",
"address": "Mount Vernon, Virginia, United States"
}
{
"first_name": "George",
"last_name": "Washington",
"birthday": "1732-02-22",
"address": {
"street_address": "3200 Mount Vernon Memorial Highway",
"city": "Mount Vernon",
"state": "Virginia",
"country": "United States"
}
}

The above two examples are valid JSON data and contain the same valid information. However, when the program reads the data, it needs to know exactly how the data is organized, such as which fields are required and what types these fields are. This is when JSON Schema comes in handy. See the following JSON Schema example:

{
"type": "object",
"properties": {
"first_name": { "type": "string" },
"last_name": { "type": "string" },
"birthday": { "type": "string", "format": "date" },
"address": {
"type": "object",
"properties": {
"street_address": { "type": "string" },
"city": { "type": "string" },
"state": { "type": "string" },
"country": { "type" : "string" }
}
}
}
}

When verifying the first example using the above JSON Schema, the verification fails; but the verification of the second example passes.

JSON Schema itself is also written through JSON, which is also data itself. It is not a computer program, but a declaration format that "describes the structure of other data". This is both a strength and a weakness. JSON Schema can concisely describe the structure of data and automatically validate the data, but it is unable to express the relationship between data elements.

For more JSON Schema knowledge, you can read Understanding JSON Schema (opens new window).

# Request header

Define the request header parameters of the aggregate interface.

manager_aggregate_add_3

For example:

{
   "type": "object",
   "properties": {
     "headerParam1": {
       "type": "string",
       "title": "Request header parameter 1",
       "titleEn": "headerParam1"
     }
   },
   "required": [
     "headerParam1"
   ]
}

The above example defines the required request header parameter headerParam1.

The title field is used to prompt when verification fails. For example, if no request header is passed when requesting the interface, it will prompt "Request header parameter 1 cannot be empty" (the error prompt output is configured by the verification result, please see the following introduction for details). as the picture shows.

manager_aggregate_add_input_header_1

When the language configuration is defined (for details, please see the language configuration introduction later), when the option is English, the titleEn field will be used to prompt when the verification fails. For example, when the request header is not passed when requesting the interface, it will prompt "headerParam1 is missing but it is required" (the error prompt output is configured through the verification result, please see the following introduction for details), as shown in the figure.

manager_aggregate_add_input_header_2

# Request body

Define the request body parameters of the aggregate interface.

manager_aggregate_add_4

For example:

{
   "type": "object",
   "properties": {
     "bodyParam1": {
       "type": "string",
       "title": "Request body parameter 1",
       "titleEn": "bodyParam1"
     }
   },
   "required": [
     "bodyParam1"
   ]
}

The above example defines the required request body parameter bodyParam1.

The title field is used to prompt when verification fails. For example, when the request body parameter is not passed when requesting the interface, it will prompt "Request body parameter 1 cannot be empty" (the error prompt output is configured through the verification result, please see the following introduction for details) ,as the picture shows.

manager_aggregate_add_input_body_1

When the language configuration is defined (for details, please see the language configuration introduction later), when the option is English, the titleEn field will be used to prompt when verification fails. For example, when the request body parameter is not passed when requesting the interface, it will prompt "bodyParam1 is missing" but it is required” (the error prompt output is configured through the verification result, please see the following introduction for details), as shown in the figure.

manager_aggregate_add_input_body_2

# Query parameters

Define the Query parameters of the aggregate interface.

manager_aggregate_add_5

For example:

{
   "type": "object",
   "properties": {
     "queryParam1": {
       "type": "string",
       "title": "query parameter 1",
       "titleEn": "queryParam1"
     }
   },
   "required": [
     "queryParam1"
   ]
}

The above example defines the required Query parameter queryParam1.

The title field is used to prompt when verification fails. For example, if the Query parameter is not passed when requesting the interface, it will prompt "query parameter 1 cannot be empty" (the error prompt output is configured through the verification result, please see the following introduction for details), such as As shown in the figure.

manager_aggregate_add_input_query_1

When the language configuration is defined (for details, please see the introduction to language configuration later) option is in English, the titleEn field will be used to prompt when verification fails. For example, if the Query parameter is not passed when requesting the interface, it will prompt "queryParam1 is missing but it is required" (the error prompt output passes the verification result configuration, details Please see the introduction below), as shown in the figure.

manager_aggregate_add_input_query_2

# Script verification

For verification scenarios that cannot be covered by the JSON Schema specification, you can use scripts to process input parameters more flexibly.

manager_aggregate_add_6

After clicking the Add button, the script configuration window pops up, as shown in the figure.

manager_aggregate_add_7

Script type: optional javascript|groovy, required;

Script content: Input parameter verification script written in the selected script type language, required.

For example:

//The javascript script function name cannot be modified
function dyFunc(paramsJsonStr) {
   //Context, please refer to context.js for data structure
   var context = JSON.parse(paramsJsonStr)['context'];
   // common is a built-in context convenient operation tool class. For details, please refer to common.js; for example:
   // var data = common.getStepRespBody(context, 'step2', 'request1', 'data');

   // do something
   var headerParam1 = common.getInputReqHeader(context, 'headerParam1');
   var bodyParam1 = common.getInputReqBody(context, 'bodyParam1');
   var queryParam1 = common.getInputReqParam(context, 'queryParam1');
   var result = new Array();
   if (headerParam1 != bodyParam1) {
     result.push("headerParam1 is inconsistent with bodyParam1");
   }
   if (queryParam1 != bodyParam1) {
     result.push("queryParam1 is inconsistent with bodyParam1");
   }
   if (headerParam1 != queryParam1) {
     result.push("headerParam1 is inconsistent with queryParam1");
   }

   // When the return result is Array or Object, it must be converted into a json string first.
   return JSON.stringify(result);
}

The above example uses JavaScript to write parameter verification and restricts the input parameters headerParam1, bodyParam1, and queryParam1 to be consistent. If they are inconsistent, an error message will be prompted (the error message output is configured through the verification result, please see the following introduction for details), such as As shown in the figure.

manager_aggregate_add_input_script

# Language configuration

By default, the aggregation interface uses Chinese to respond to verification failure prompts. Different prompt languages can be selected through input parameters through configuration. Currently, Chinese and English prompts are supported (this has met our business usage scenarios, and partners with other language requirements can contact us to add them) .

manager_aggregate_add_8

Field: input parameter field value, for example, input.request.body.languageCode uses the value of the request body parameter languageCode to determine which language to use;

Chinese: The mapping relationship between Chinese and the input parameter field value, for example, configure 0, and when the requested input parameter field value is 0, use the Chinese prompt to verify the result;

English: The mapping relationship between English and the input parameter field value. For example, configure 1. When the requested input parameter field value is 1, use English to prompt the verification result.

# Configuration steps

The aggregation interface calls the underlying service through multiple steps. Multiple steps are executed serially. Each step contains multiple requests (calls to the underlying service interface). Multiple requests in the same step are executed in parallel, and the last one is executed. step can obtain the execution result of the executed step. For more details, please see the introduction of the service orchestration article. The following describes the use of configuration steps.

manager_aggregate_add_9

Whether to end after executing this step: After checking, the actual request will only respond with the result after executing this step, and will not execute subsequent steps. It is used for debugging;

Request method: request type for calling the underlying service interface, optional GET|POST, required;

Service name: Whether you choose service discovery or HTTP, you can select a group of servers by selecting the service name.

Timeout (milliseconds): The timeout for calling the underlying service interface. An exception is thrown when the timeout occurs. The unit is milliseconds;

Fallback: optional stop|continue, controls whether to continue to perform subsequent operations when calling the underlying service interface fails;

Request preprocessing: After checking, you can configure the preprocessing script. The underlying service interface will be called only when the preprocessing script returns true.

manager_aggregate_add_10

Configuration input parameters: configure the request parameters for calling the underlying service interface;

Configure response: Configure the response content for calling the underlying service interface.

manager_aggregate_add_11

Configuration step result: Configure the response content after the step execution is completed.

# Configure output

Configure the response content of the aggregation interface call completion. Simple response fixed values and response reference values can be configured in the response body and response header configuration. Responses that require logical processing to obtain results can be flexibly processed through script configuration, as shown in the figure.

manager_aggregate_add_12

manager_aggregate_add_13

# Verification results

Configure the response content after the aggregation interface input parameter verification fails. In the response body and response header configuration, you can configure simple response fixed values and response reference values. Responses that require logical processing to obtain results can be flexibly processed through script configuration, as shown in the figure shown.

manager_aggregate_add_14

The verification result has a dedicated reference value validateMsg, which is used to store the parameter verification error message.

# Save interface

After all configurations are completed, click the Save button to complete the configuration of the aggregate interface.

manager_aggregate_add_15

# Export interface

The export function exports the aggregation interface in the form of a configuration file. The exported file can be re-imported into the system through the import function. When our system is divided into multiple environments, we can use the export-import function to achieve rapid synchronization of the aggregation interface. The export function is introduced below.

manager_aggregate_export_1

Check the interface you want to export, and click the Export button to pop up a confirmation window, as shown in the figure.

manager_aggregate_export_2

Click the OK button and the browser saves the configuration file, as shown in the figure.

manager_aggregate_export_3

# Import interface

The import function converts the aggregation interface in the configuration file into background persistent storage. The imported file can be obtained through the export function or converted from the prepared aggregation configuration JSON file (contact us for the conversion tool). When our system is divided into multiple environments, we can use the export and import function to achieve rapid synchronization of the aggregate interface. The export function is introduced below.

manager_aggregate_import_1

Click the Import button to pop up the import configuration window, as shown in the figure.

manager_aggregate_import_2

Click the Select File button and select the configuration file to be imported;

Forced coverage: An aggregate interface can be uniquely determined by request type (GET|POST) and request path (/proxy/{service}/{apiPath}). When the aggregate interface already exists, the aggregate interface will be ignored if this option is not checked. Import, when this option is checked, the existing aggregate interface configuration will be overwritten;

Click the OK button to import the aggregate interface configuration.

# Debug mode

The debug mode is used for debugging during the interface development process. When the debug mode is turned on, the FizzGate integration platform will print the request response information of the aggregate interface calling the underlying service interface as well as the time consumption, aggregate results, and step context to the log. Through the log You can clearly understand the actual implementation of the aggregate interface. The debugging mode will affect the performance of the gateway. Therefore, it is not recommended to turn on the debugging mode in the production environment. When the debugging is completed, turn off the debugging mode promptly to avoid printing too many logs and causing a waste of resources. The following describes the use of debugging mode.

Check the interface you want to turn on debugging mode, and click the Turn on debugging mode button to pop up a confirmation window, as shown in the figure.

manager_aggregate_debug_mode_1

Click the OK button to confirm turning on debugging mode.

manager_aggregate_debug_mode_2

Check the interface for which you want to turn off debugging mode, and click the Turn off debugging mode button to pop up a confirmation window, as shown in the figure.

manager_aggregate_debug_mode_3

Click the OK button to confirm turning off debugging mode.

manager_aggregate_debug_mode_4

# Edit interface

Click the Edit button to pop up the editing window, as shown in the figure.

manager_aggregate_edit_1

manager_aggregate_edit_2

# Delete interface

Click the Delete button to pop up the deletion confirmation window, as shown in the figure.

manager_aggregate_delete_1

manager_aggregate_delete_2

Click the OK button to delete the interface. The interface in the published state cannot be deleted and must be offline before deletion can be performed.

# Release|Offline application

Publish|Offline application is used to publish or offline the aggregation interface. Only through Only after review by the reviewer can the applicant perform the release|offline operation to avoid misoperations and ensure the security of the interface.

Click the Publish|Offline Application button to pop up the Publish|Offline Application window, as shown in the figure.

manager_aggregate_apply_1

manager_aggregate_apply_2

After clicking the Add button, the interface list will pop up. Check the interfaces that need to be operated and click OK to add them to the application.

manager_aggregate_apply_3

Title: The title of the application. The length cannot exceed 200 characters and is required;

Type: application type, optional release|offline, required;

Reason for application: Reason for application, the length cannot exceed 2000 characters;

Select reviewer: Select a person with review authority to review the application. The list changes dynamically according to the interface that needs to be operated (the list is empty when no interface is added. People with service permissions and menu permissions to be reviewed, or people with the operation administrator role can Select reviewer), required;

Click the OK button to submit the application. The selected reviewer will receive an application review email (the reviewer's email address is set through user management. For more details, please see the user management function introduction), as shown in the figure.

manager_aggregate_apply_4

# Interface testing

The background provides a visual interface calling interface. After the aggregation interface is created, the interface can be called and tested through this interface. Open the interface test page by clicking the Test button on the interface details page, as shown in the figure.

manager_aggregate_test_1

When jumping to the page, the background will push the latest current configuration of the interface to the FizzGate integration platform to generate a test interface. The request path is /proxytest/{service}/{apiPath}.

manager_aggregate_test_2

Click the Send button to send a request to the specified interface. The Response result area displays the result of calling the interface, as shown in the figure.

manager_aggregate_test_3

manager_aggregate_test_4

The request body tab is used to configure the request body parameters of the request.

manager_aggregate_test_5

The request header tab is used to configure the request header parameters of the request.

manager_aggregate_test_6

Query parameters are used to configure the Query parameters of the request.

manager_aggregate_test_7

Return to Context: A Context object will be held internally during an aggregation interface request in the FizzGate integration platform. This object saves the input parameter information, underlying service interface call information, and response information of this request process. By checking this option, The interface will return the Context along with the interface response. By viewing the Context, you can clearly understand the actual calling process of the interface.

When the Return to Context option is unchecked, the interface responds according to the settings output by the configuration, as shown in the figure.

manager_aggregate_test_8

After checking the Return Context option, the interface will return the Context along with the interface response, as shown in the figure.

manager_aggregate_test_9

Test interface: call the test interface, the request path is /proxytest/{service}/{apiPath};

Formal interface: Call the formal interface, the request path is /proxy/{service}/{apiPath};

manager_aggregate_test_10

Clicking the Save button will save the test request data. You can quickly restore the request data by selecting the saved test record, as shown in the figure.

manager_aggregate_test_11

Title: The title used when saving this test data. The length cannot exceed 2000 characters. After saving, it will be displayed in the historical test record list, as shown in the figure.

manager_aggregate_test_12