Application program interface visual configuration method and related equipment
By providing a visual configuration method for application program interface, displaying the configuration interface and associating exception operation codes and events, the complex problems of customized development, joint debugging optimization and maintenance in the API implementation solution are solved, and more efficient API development and maintenance are achieved.
Patent Information
- Application Number
- CN202411432573.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-02-07
AI Technical Summary
The existing API implementation solutions have problems such as strong code customization development, long joint debugging and optimization, weak API readability, and complex API maintenance.
It provides a visual configuration method for application program interface, which displays the application program interface configuration interface, displays the exception handling policy configuration interface in response to operation instructions, and associates the exception operation code of the target application program interface with exception events to realize exception handling operations.
This method solves the problem of customizing API code development, shortens the API joint debugging cycle, reduces the difficulty of API maintenance, and reduces the requirements for API developers.
Smart Images

Figure CN119396509A_ABST
Abstract
Description
Background Art
[0002] API (Application Program Interface) is a set of definitions, programs and protocols that enable computer software to communicate with each other through the API interface. One of the main functions of API is to provide a common set of functions. By calling API functions to develop applications, programming tasks can be reduced. API is also a kind of middleware that provides data sharing for various platforms. Summary of the invention
[0003] The embodiment of the present disclosure provides a method for visually configuring an application program interface, the method comprising: displaying an application program interface configuration interface, the application program interface configuration interface including an application program interface list; in response to a first operation instruction on a target application program interface in the application program interface list, displaying an exception handling policy configuration interface of the target application program interface, the exception handling policy configuration interface including adding an exception handling policy control; in response to a triggering operation on the exception handling policy control, associating an exception operation code of the target application program interface with a corresponding exception event, so that when the exception operation code appears during the operation of the target application program interface, a corresponding exception handling operation is performed according to the associated exception event.
[0004] An embodiment of the present disclosure provides an application interface visualization configuration device, the device comprising: a display unit, used to display an application interface configuration interface, the application interface configuration interface including an application interface list; the display unit is also used to respond to a first operation instruction to a target application interface in the application interface list, and display an exception handling policy configuration interface of the target application interface, the exception handling policy configuration interface including adding an exception handling policy control; a processing unit, used to respond to a trigger operation to the exception handling policy control, and associate an exception operation code of the target application interface with a corresponding exception event, so that when the exception operation code appears during the operation of the target application interface, the corresponding exception handling operation is performed according to the associated exception event.
[0005] An embodiment of the present disclosure provides an electronic device, the electronic device comprising: a processor; and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the method in any embodiment of the present disclosure by executing the executable instructions.
[0006] An embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method in any embodiment of the present disclosure is implemented.
[0007] An embodiment of the present disclosure provides a computer program product, including a computer program. When the computer program is executed, the method in any embodiment of the present disclosure is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 A schematic diagram of the structure of a system in an embodiment of the present disclosure is shown.
[0009] Figure 2 A flowchart of a method for visually configuring an application program interface in an embodiment of the present disclosure is shown.
[0010] Figure 3 A schematic diagram showing an application program interface design interface and an application program interface configuration interface in an embodiment of the present disclosure is shown.
[0011] Figure 4 A schematic diagram showing a new application interface page in an embodiment of the present disclosure.
[0012] Figure 5 A schematic diagram showing another application program interface configuration interface in an embodiment of the present disclosure.
[0013] Figure 6 A schematic diagram showing yet another application program interface configuration interface in an embodiment of the present disclosure.
[0014] Figure 7 A schematic diagram of a parameter configuration interface in an embodiment of the present disclosure is shown.
[0015] Figure 8 A schematic diagram showing a scripting language writing interface in an embodiment of the present disclosure.
[0016] Fig. 9 A schematic diagram showing an execution policy configuration interface, a security policy configuration interface, and an exception handling policy configuration interface in an embodiment of the present disclosure is shown.
[0017] Fig.10 A schematic diagram showing yet another application program interface configuration interface in an embodiment of the present disclosure.
[0018] Fig.11 A schematic diagram of a test interface in an embodiment of the present disclosure is shown.
[0019] Fig.12 A schematic diagram of a log monitoring center in an embodiment of the present disclosure is shown.
[0020] Fig.13 A schematic diagram of an application program interface modification page in an embodiment of the present disclosure is shown.
[0021] Fig.14 A schematic diagram showing another parameter configuration interface in an embodiment of the present disclosure.
[0022] Fig.15 A schematic diagram showing another scripting language writing interface in an embodiment of the present disclosure.
[0023] Fig.16 A schematic diagram showing another test interface in an embodiment of the present disclosure.
[0024] Fig.17 A schematic diagram showing an application program interface running process and a passive calling process in an embodiment of the present disclosure is shown.
[0025] Fig.18 A schematic diagram showing an application program interface running process and an active calling process in an embodiment of the present disclosure is shown.
[0026] Fig.19 A schematic diagram of a technical architecture for implementing a method for visually configuring an application program interface in an embodiment of the present disclosure is shown.
[0027] Fig. 20 A functional architecture diagram of an application program interface visualization configuration method in an embodiment of the present disclosure is shown.
[0028] Fig.21 An application program interface design specification in an embodiment of the present disclosure is shown.
[0029] Fig. 22 for Fig.21 A partial enlarged view of the .
[0030] Fig.23 for Fig. 22 Another enlarged view of the part.
[0031] Fig.24 A structural block diagram of an application program interface visualization configuration device in an embodiment of the present disclosure is shown.
[0032] Fig.25 A structural block diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0033] In the software development process of the related technology, when it involves the scenario of the system providing an interface (such as an API) or calling an external interface, the interface function is often implemented by customized development hardcoding. Hardcoding refers to the process of writing certain data (such as configuration information, parameter values, element positioning of the user interface, etc.) directly into the source code during the software development process, rather than dynamically obtaining it from external files, databases, environment variables or user input. This practice reduces the maintainability, scalability and flexibility of the code. When the hard-coded data needs to be modified, the source code must be modified directly, and then the entire application must be recompiled and deployed (which can correspond to a certain engineering project or one or more directories of a certain engineering project). This increases the cost of modification and may lead to the introduction of new errors. Hardcoding also limits the ability of the application to handle different environments or changes in requirements. For example, if the application needs to support multiple languages, hard-coding the language strings in the code makes it difficult to add new languages. In addition, hard-coded data is tightly coupled with the application code, making it more difficult to reuse or modularize the code. At the same time, hard-coding sensitive information (such as passwords, keys, etc.) may lead to security vulnerabilities because once the source code is leaked, this information will be exposed to potential attackers.
[0034] Specifically, the method adopted by the relevant technology includes the following steps:
[0035] 1) After determining the interface input and output parameters (including input parameters (abbreviated as input parameters) and output parameters (abbreviated as output parameters)), the interface service must be built first. The construction of the interface service includes designing the service architecture and selecting the technology stack.
[0036] 2) Then write the interface service code according to business needs. For the interface provided to the outside, first you need to receive and parse the input parameters, then store the data, build and return the interface output parameters, etc. For calling the external interface, first you need to splice the input parameter message, write the parameter value logic, write the corresponding interface protocol call, and parse and store the interface return parameters.
[0037] 3) After the interface is written, use the interface tool to call the test. If there is a problem with the test, modify the code, restart the deployment, call the test again, and repeat this process until the test passes.
[0038] 4) After the test passes, package and deploy it online until the test passes.
[0039] From the above process, it can be seen that the API implementation solutions in related technologies have problems such as strong code customization development, long time-consuming joint debugging and optimization, weak API readability, and complex API maintenance.
[0040] 1) Strong code customization: It is implemented entirely with high-code. Any new API or optimization of existing APIs requires new code development or modification of the original code, which requires high developer capabilities. Customized development often requires a deep understanding of business needs and the corresponding programming skills to achieve these needs.
[0041] 2) Joint debugging and optimization takes a long time: Each optimization, adjustment, and retest of the API requires the code service to be restarted and deployed before the API can take effect, which greatly prolongs the testing time and affects the overall demand progress.
[0042] 3) API readability is poor and maintenance is complex: The hard-coding method cannot intuitively view the API input and output parameters and the logical processing of the input and output parameters through a visual page, and the subsequent maintenance cost of the API is high.
[0043] exist Figure 1 In the system shown, a user accesses services provided by a server 20 via a network through a client (eg, a browser or an application (APP)) installed on a terminal 10 .
[0044] The terminal 10 may also be referred to as a terminal device, a user device, a mobile station, a mobile terminal, etc. The terminal can be widely used in various scenarios, for example, device-to-device (D2D), vehicle to everything (V2X) communication, machine-type communication (MTC), Internet of Things (IOT), virtual reality, augmented reality, industrial control, automatic driving, telemedicine, smart grid, smart furniture, smart office, smart wear, smart transportation, smart city, etc. The terminal may be a mobile phone, a tablet computer, a computer with wireless transceiver function, a wearable device, a vehicle, a drone, a helicopter, an airplane, a ship, a robot, a mechanical arm, a smart home device, etc. The embodiments of the present disclosure do not limit the specific technology and specific device form adopted by the terminal.
[0045] Those skilled in the art will know that Figure 1 The number of terminals and servers in the example is only illustrative, and any number of terminals and servers may be provided according to actual needs. This disclosure embodiment does not limit this.
[0046] Under the above system architecture, an application interface visualization configuration method is provided in the embodiments of the present disclosure, and the method can be executed by any electronic device with information processing capabilities. In some embodiments, the application interface visualization configuration method provided in the embodiments of the present disclosure can be executed by a terminal of the above system architecture; in other embodiments, the application interface visualization configuration method provided in the embodiments of the present disclosure can be implemented by a server in the above system architecture. In some other embodiments, the application interface visualization configuration method provided in the embodiments of the present disclosure can be implemented by the terminal and server in the above system architecture through interaction.
[0047] Figure 2 The method provided in the embodiment may be executed by a terminal, but the present disclosure is not limited thereto. In some steps, the terminal and the server may be interactively executed and finally presented on the terminal. Figure 2 As shown, the method provided by the embodiment of the present disclosure includes the following steps.
[0048] In S210, an application program interface configuration interface (API configuration interface) is displayed, wherein the application program interface configuration interface includes an application program interface list (API list).
[0049] The API configuration interface in the embodiments of the present disclosure refers to a visual interface for configuring any relevant information of the API, and the relevant information of the API to be designed (such as basic information, etc.) can be implemented on the visual interface through forms and / or drag components. In some embodiments, the configuration of the relevant information of the API can be implemented directly in the API configuration interface. In other embodiments, other new interfaces can be displayed by triggering the controls configured in the API configuration interface to implement the configuration of the relevant information of the API. In the following examples, the latter case is used as an example, but the present disclosure is not limited to this.
[0050] In an embodiment of the present disclosure, an API list can be displayed in the API configuration interface, and the API list includes relevant information of APIs that have been configured and / or are being configured, such as one or more of the API name, API description, API category, API type, current version of the API, status, creation time, creator, status time, link name, etc.
[0051] In S220, in response to a first operation instruction on a target application program interface in the application program interface list, an exception handling policy configuration interface of the target application program interface is displayed, wherein the exception handling policy configuration interface includes an add exception handling policy control.
[0052] In the embodiment of the present disclosure, the user can select an API from the API list as the target API through a first operation instruction, that is, configure the information of the target API, such as adding new information or modifying the original existing information. The specific form of the first operation instruction is not limited in the present disclosure, such as single-clicking or double-clicking the target API in the API list, or issuing a voice instruction or gesture instruction to select the target API, or right-clicking the target API in the API list, and then various options pop up, one of which is to trigger the exception handling policy configuration. After the option is selected, the exception handling policy configuration interface of the target API is displayed.
[0053] In the embodiment of the present disclosure, the exception handling strategy configuration interface refers to a visual interface for configuring strategies for handling different exception situations when the target API encounters an exception situation during operation. The exception handling strategy configuration interface displays an exception handling strategy control. The exception handling strategy control is used to configure a corresponding exception handling strategy for the target API in response to a trigger operation on it.
[0054] In S230, in response to the triggering operation of the exception handling policy control, the exception operation code of the target application interface is associated with the corresponding exception event, so that when the exception operation code appears during the operation of the target application interface, the corresponding exception handling operation is performed according to the associated exception event.
[0055] The present disclosure does not limit the triggering operation of the exception handling strategy control, such as clicking the exception handling strategy control. In the embodiment of the present disclosure, standardized exception operation codes are set in advance for various abnormal situations that the target API may encounter during operation, each exception operation code corresponds to an abnormal event, and an abnormal event library or abnormal event pool is set. Each abnormal event in the abnormal event library is configured with a corresponding exception handling operation. In this way, after an abnormal operation code of the target API is associated with an abnormal event, if the abnormal operation code is encountered during the operation of the target API, the corresponding exception handling operation can be automatically executed.
[0056] The method provided in the embodiment of the present disclosure, on the one hand, defines a method for API visual configuration, solves the problem of API code customization development, and also shortens the API joint debugging cycle and reduces the difficulty of API maintenance to a certain extent. On the other hand, the API visualization implementation scheme also takes into account the configuration of the API exception handling strategy, reduces the amount of code writing required in API design in actual applications, and reduces the requirements for API developers.
[0057] In an exemplary embodiment, in response to a trigger operation on the exception handling strategy control, the exception operation code of the target application program interface is associated with the corresponding exception event, including: if the exception event is a business exception, then the corresponding exception handling strategy is associated according to the type of the business exception to perform the corresponding exception handling operation. The exception handling strategy includes at least one of rollback, compensation, and ignore.
[0058] In an exemplary embodiment, the service anomaly includes local parameter anomaly and / or peer data anomaly; the local parameter anomaly includes parameter missing and / or parameter error; the peer data anomaly includes data duplication and / or data non-existence.
[0059] In an exemplary embodiment, if the abnormal event is a network abnormality, the abnormality handling operation is a general handling method.
[0060] In an exemplary embodiment, the network anomaly includes interface timeout and / or service downtime.
[0061] The design of the API exception strategy or exception handling strategy in the embodiment of the present disclosure supports the classification of abnormal information or abnormal situations that may be generated during the execution of the API. The design of the API exception strategy or exception handling strategy includes the following contents: the exceptions are mainly divided into network exceptions (also called IT (Internet Technology) exceptions) and business exceptions. IT exceptions are mainly caused by system-level problems, such as database connection failures, network timeouts, insufficient resources, etc. These exceptions are generally unpredictable and are not directly caused by business logic. For example, IT exceptions include interface timeouts, service downtime, etc. Business exceptions are caused by problems that arise during the business logic processing process, such as parameter verification failures, data inconsistencies, business rule violations, etc. These exceptions can be predicted and classified by business logic. For example, business exceptions include local parameter exceptions (parameters missing or wrong, etc.) and peer data exceptions (data duplication, data non-existence, etc.).
[0062] In the disclosed embodiments, abnormal operations or abnormal operation codes or abnormal error codes are sorted out for IT exceptions and business exceptions, standardized as IT events / abnormal events embedded in the system, and in the API design interface (such as the exception handling policy configuration interface displayed by subsequent triggering), a strategy for associating the API's abnormal error code with the abnormal events in the abnormal event library is configured to achieve automatic handling of at least some exceptions.
[0063] In the disclosed embodiments, IT anomalies (i.e., IT anomalies) are handled in a general manner (i.e., a general processing method is adopted), that is, for IT anomalies, a set of general processing strategies are designed to ensure that the system can operate stably when facing such anomalies. For example, for interface timeout anomalies, a limited number of retries are configured, and manual operation is switched to service downtime. That is, for certain recoverable IT anomalies (such as network timeout / interface timeout), an automatic retry mechanism can be designed to reduce service interruptions caused by temporary problems. When system resources are tight or certain services are unavailable, a degradation strategy is adopted to provide simplified services or return predefined responses.
[0064] In the disclosed embodiment, the business exceptions (i.e., business exceptions) can be classified according to the exceptions, and an exception strategy can be designed for each type of exception, that is, the corresponding exception handling strategy is associated with the type of business exception to execute the corresponding exception handling operation, including at least one of rollback, compensation, and ignore. For example, if the local end parameter is abnormal, an automatic rollback operation is performed; if the opposite end data is abnormal, the data can be restored by configuring the compensation API, and then the API can be executed.
[0065] In some embodiments, business exceptions are carefully classified according to business logic and requirements, and specific processing strategies are designed for each type of exception: 1) Strategy for parameter verification exceptions: immediately return an error, indicate which specific parameter is illegal, and prompt the user to modify it; 2) Strategy for data inconsistency exceptions: depending on the importance of the business, you can choose to roll back the operations that have been performed (such as transaction management), or record the error and notify relevant personnel to handle it manually; 3) Strategy for business rule violation exceptions: return a clear error message to indicate which business rule has been violated, and guide the user on how to modify the request; 4) Strategy for insufficient resources exceptions (such as insufficient inventory): provide alternative options (such as recommending similar products), or inform the user to wait for resources to be replenished before trying again; 5) Strategy for third-party service exceptions: implement a service degradation or failure retry mechanism, and record detailed logs to analyze the stability of third-party services.
[0066] The disclosed embodiment defines a unified error code standard by standardizing error codes (i.e., abnormal operation codes) to ensure that the error codes used by all APIs have the same meaning. At the same time, by establishing an abnormal event library, high-frequency abnormal manual processing operations are IT-ized, and embedded in the abnormal event library to realize the automatic execution of abnormal processing operations, such as API abnormality ignoring, API rollback, API re-execution, execution compensation API, etc. Then, through the visual abnormal handling strategy configuration interface, the abnormal strategy configuration is realized, and the error code is bound to the corresponding abnormal event in the API design interface, that is, the strategy of associating the two is that when the API executes abnormally, the abnormal operation event or abnormal handling operation is matched by the error code, and most of the abnormalities are automatically processed, thereby improving the abnormal management and control capabilities of the API. The abnormal management and control capabilities of the API are one of the key factors to ensure the stability and reliability of applications in the production environment. When designing and implementing the API, the handling of abnormal situations must be fully considered to ensure that the system can keep running even in the face of unexpected situations and minimize the impact on the production environment. The method provided by the disclosed embodiment can build a comprehensive and flexible API abnormal handling strategy through the above steps to ensure that the system can make appropriate responses when facing various abnormal situations, protect the stable operation of the system and improve the user experience.
[0067] In an exemplary embodiment, the method provided by the embodiment of the present disclosure also includes: in response to a second operation instruction on a target application interface in the application interface list, displaying a security policy configuration interface of the target application interface, wherein the security policy configuration interface includes adding a security policy control; in response to the operation instruction to add the security policy control, configuring security call information of the target application interface so that when the target application interface is called, the caller is allowed to call the target application interface if the caller satisfies the security call information.
[0068] The specific form of the second operation instruction is not limited in the present disclosure, such as single-clicking or double-clicking the target API in the API list, or issuing a voice command or gesture command to select the target API, or right-clicking the target API in the API list, and then various options pop up, one of which is to trigger security policy configuration. After the option is selected, the security policy configuration interface of the target API is displayed.
[0069] In the disclosed embodiment, the security policy configuration interface refers to a visual interface for configuring the security control policy or security policy of the target API, and the security control policy refers to a related policy for improving the security of the target API or improving the security of the caller of the target API or improving the security of the target API when it is called. Specifically, the security call information of the target API can be configured, and when a call request to the target API is received, the call request is first verified, and the caller is allowed to call the target API only if it meets the configured security call information.
[0070] In an exemplary embodiment, the secure call information includes at least one of a communication protocol, an allowed call system identifier, a trusted address, and an authentication code.
[0071] In the embodiments of the present disclosure, the API's secure calling mechanism can be configured through a visual interface. For example, in the API design interface (such as the security policy configuration interface that is subsequently triggered and displayed), the communication protocol (such as HTTP (Hypertext Transfer Protocol) / HTTPS (Hypertext Transfer Protocol Secure)), the allowed calling system identification, the trusted IP (Internet Protocol, i.e., the trusted address), the authentication code and other security control information / security calling information can be configured to improve the access security of the API.
[0072] The following are some examples of API call security control strategies:
[0073] 1. System Authentication: API callers are required to provide valid authentication credentials (such as access tokens) and verify them on the API gateway or server side; multiple authentication methods are supported (such as client credentials, password authorization, authorization code authorization, etc.) to meet security requirements in different scenarios.
[0074] 2. Authorization: After verifying the identity of the caller, authorization is performed based on the caller's permissions to ensure that the caller can only access resources that he or she is authorized to access. For example, policies such as role-based access control and claim-based access control are implemented to flexibly manage permissions and roles. Another example is to support fine-grained permission control, such as resource-level permissions and operation-level permissions.
[0075] 3. IP restriction: Allow or deny API call requests from specific IP addresses or IP address segments to limit access sources; implement IP whitelist (i.e. trusted addresses) or blacklist mechanism, add trusted client IP addresses to the whitelist, and deny access from other IP addresses; API key verification: assign a unique API key to each API caller and require the key to be provided each time a call is made. Verify the provided API key on the server side to verify its validity and association with the caller. Support key creation, distribution, revocation, and expiration management to ensure key security and controllability.
[0076] 4. Data encryption and transmission security: Encrypt API request and response data to prevent data from being stolen or tampered with during transmission. Use HTTPS protocol as the standard protocol for data transmission to ensure the security of data transmission. Encrypt sensitive data (such as user passwords, personal information, etc.) for storage and transmission.
[0077] The API security management and control capabilities in related technologies are weak. Security is the premise and foundation of all work, and current software applications are paying more and more attention to security. There are also security management issues for each API. The disclosed embodiment includes the management and control of API call security. The API call management and control issues are considered at the beginning of the design, including support for API call system authentication (for example, by allowing the call system identifier), API call IP restriction (for example, by trusted address), API key verification (for example, by authentication code), etc.
[0078] In an exemplary embodiment, the method provided by the embodiment of the present disclosure also includes: in response to a third operation instruction on a target application interface in the application interface list, displaying an execution policy configuration interface of the target application interface; and in response to an operation instruction on the execution policy configuration interface, configuring execution policy information of the target application interface.
[0079] The specific form of the third operation instruction is not limited in the present disclosure, such as single-clicking or double-clicking the target API in the API list, or issuing a voice command or gesture command to select the target API, or right-clicking the target API in the API list, and then various options pop up, one of which is the execution policy configuration. After the option is selected, the execution policy configuration interface of the target API is displayed.
[0080] The execution policy configuration interface in the embodiment of the present disclosure refers to a visual interface for configuring the execution policy of the target API. The execution policy may include relevant information when the target API is called and executed.
[0081] In an exemplary embodiment, the execution strategy information includes at least one of a call timeout, whether to retry, a retry interval, a retry count, whether to support idempotence, and a request action. However, the present disclosure is not limited thereto. In other embodiments, developers are also allowed to define the business logic flow of the API in a visual interface, including conditional branches, loops, etc., so that developers can build complex business logic.
[0082] In an exemplary embodiment, the application program interface configuration interface also includes a parameter configuration control. The method further includes: in response to a fourth operation instruction for the target application program interface in the application program interface list, displaying the version information of the target application program interface in the application program interface configuration interface; in response to a selection operation for a target version in the version information of the target application program interface, and a trigger operation for the parameter configuration control, displaying a parameter configuration interface, the parameter configuration interface including an add input parameter control and an add output parameter control; in response to the operation instructions for the add input parameter control and the add output parameter control, configuring the input and output parameter information of the target application program interface.
[0083] In the embodiments of the present disclosure, the parameter configuration control refers to a control for triggering a parameter configuration interface. The parameter configuration interface refers to a visual interface for configuring various parameters of a target API, and examples are given here for configuring output parameters and / or output parameters of the target API. Input and output parameter information may include output parameter information and / or input parameter information. Output parameter information refers to information related to the output parameters of the target API. Input parameter information refers to information related to the input parameters of the target API.
[0084] In an exemplary embodiment, the parameter configuration interface further includes an add output parameter strategy control and / or an add input parameter strategy control. The method further includes: in response to adding an output parameter strategy control or adding an input parameter strategy control, displaying a scripting language writing interface; and writing the logic processing code of the input and output parameter information in the scripting language writing interface using a scripting language.
[0085] In the disclosed embodiment, adding an output parameter strategy control and / or adding an input parameter strategy control can be used to trigger a scripting language writing interface, which provides a user with a visual interface for inputting logical processing code for processing the input and output parameter information.
[0086] In the following embodiments, the scripting language is Groovy language for example, but the present disclosure is not limited thereto, and other suitable programming languages may also be used to implement the logic processing code of the input and output parameter information of the target API.
[0087] Groovy is an agile development language based on JVM (Java Virtual Machine). It combines many powerful features of Python, Ruby and Smalltalk. Groovy code can be well combined with Java code and can also be used to expand existing code. Due to its feature of running on JVM, Groovy can also use libraries written in other non-Java languages.
[0088] The disclosed embodiment solves the problem of API code customization development by redefining a method for implementing API visual configuration parsing based on the Groovy language, and also shortens the API joint debugging cycle and reduces the difficulty of API maintenance to a certain extent. On the one hand, through visual configuration, developers can intuitively define various aspects of the API without going deep into the underlying code. This greatly reduces the difficulty and cost of customized development, allowing non-professional developers to participate in the design and implementation of the API. The concise syntax and dynamic characteristics of Groovy make it easy to write a small amount of code to handle complex logic when necessary, thereby retaining the flexibility of customization. That is, while ensuring the flexibility and ease of use of visual configuration, it also provides the ability to write custom code to handle complex business logic or integration requirements, achieving a balance between rapid development and flexible customization. On the other hand, the visual configuration interface makes the definition and modification of the API faster and more intuitive. Developers can see the effects of configuration changes instantly without the need for tedious code compilation and deployment. This method also promotes the collaboration of front-end and back-end developers because they can configure and test on the same platform, thereby speeding up the joint debugging process. In addition, visual configuration makes it easier to change and upgrade the API. Developers can adapt to changes in business needs by modifying the configuration instead of modifying the code. Due to the simplicity and readability of Groovy, even if you need to write code to handle complex logic, the code is easier to understand and maintain.
[0089] In an exemplary embodiment, the application program interface configuration interface also includes a simulation test control. The method further includes: in response to a selection operation of a target version in the version information of the target application program interface and a trigger operation of the simulation test control, displaying a test interface of the target application program interface; and in response to an operation instruction on the test interface, executing a simulation test of the target application program interface.
[0090] In the embodiment of the present disclosure, after the target API is selected in the API list in the API configuration interface, the various version information of the target API can be displayed in the API configuration interface (if all version information is displayed, it is called full version information). Then, a certain version can be selected as the target version from the various version information of the displayed target API, and then the simulation test control in the API configuration interface is triggered, and the test interface of the target API can be displayed, and the simulation test can be performed on the target API in the test interface of the target API. That is, the method provided by the embodiment of the present disclosure also provides a testing tool, allowing developers to test the API in a visual interface to ensure the correctness and stability of the API.
[0091] In an exemplary embodiment, an application program interface configuration interface is displayed, including: displaying an application program interface design interface, the application program interface design interface including directory information of an engineering project; in response to a selection operation on a target directory in the directory information, displaying the application program interface configuration interface, the application program interface configuration interface including a new control; in response to a trigger instruction for the new control, displaying an application program interface new page; in response to an operation instruction on the application program interface new page, configuring basic information of the target application program interface.
[0092] In the disclosed embodiment, the API design interface refers to a visual interface for designing an API, which can display the directory information of the engineering project, that is, the required API can be designed for the engineering project or the target directory selected in the engineering project, thereby enabling the engineering project to provide an API interface to the outside world or call an externally provided API.
[0093] In an exemplary embodiment, the basic information includes at least one of an application program interface name, an application program interface code, an application program interface version, an application program interface type, an application program interface provider, an application program interface consumer, an application program interface host address, an application program interface consumption path (such as the URL (uniform resource locator) path of the API), whether to retry, the number of retries, the retry interval, the timeout limit, the data format, the application program interface interaction mode, the application program interface service protocol, the HTTP request action / request method (such as GET, POST, etc.), and an application program interface description.
[0094] The API visualization implementation solution provided by the embodiments of the present disclosure can realize the visualization design of the basic information and input and output parameters of the API, and can also fully cover the overall operation process of the API, especially key aspects such as exception handling and safe calling mechanism. The visualization design of these aspects means that in actual applications, developers no longer need to rely on a large amount of high-level code or manual coding to supplement and improve the design of the API.
[0095] The method provided by the embodiment of the present disclosure realizes the visual configuration analysis of the API interface without a large amount of hard coding process. Figures 3 to 16 The method provided in the embodiment of the present disclosure is described by way of example, and its main process steps are as follows:
[0096] 1) Propose API requirements and complete the preparation of API requirement documents.
[0097] The API requirements document describes in detail the key information of the API, such as its functions, behaviors, parameters, response formats, and security requirements. The API requirements document can describe the name and version of the API; explain the purpose and audience of writing this document; define the scope of the API covered by the document, including which interfaces and which versions; record the revision date, reviser, and revision content of the document; introduce the background, purpose, and importance of the API; list the professional terms used in the document and their definitions; list other documents or resources referenced when writing this document; give a general introduction to the API, including its main functions, application scenarios, etc.; list all interfaces in the API, including interface name, request method (GET, POST, etc.), URL path, etc.; explain the version control strategy of the API, including the naming rules of the version number, upgrade strategy, etc.
[0098] 2) API online design: Complete the API design through the API requirement document on the visual page provided by the system, including API basic information configuration, API input / output parameter template configuration, API input / output parameter parsing logic Groovy script writing, etc.
[0099] like Figure 3 As shown, open the API design interface 310. The left side of the API design interface 310 displays the directory tree of the project, that is, the directory information of the project is displayed in a tree format. First, select the corresponding directory as the target directory in the directory tree on the left. Here, "Risk Operation Process" is taken as an example. After determining the directory classification, the API configuration interface 320 is displayed. The API configuration interface 320 includes a new control 321 (for example, it can be a "New" button). Click the "New" button and a pop-up window will appear. Figure 4 The new API page 400 is shown. On the new API page 400, basic information entry of the API (here, the target API, which can be any API) is completed.
[0100] like Figure 4 As shown, in the new API page 400 in the form of a pop-up window, enter the API name (a brief description of the API's function), API code, API version (a version number that identifies the API, which is convenient for version control and iteration and can be automatically generated), API type (such as query class, operation class, process class), API provider (the name of the organization or department that provides the API), API consumer (i.e., the caller), API host address (the server address where the API service is located), API consumption path (after the host address, used to locate the specific path of the API), whether to retry (indicates whether to retry when the request fails), number of retries (the number of retries when the request fails), retry interval (the time interval between each retry), timeout limit (the maximum time to wait for an API response), data format (the data format of the API request and response, such as JSON / json (JavaScript Object Notation, a lightweight data exchange format), XML (Extensible Markup Language, a markup language), etc., here JSON format is used as an example), API interaction mode, API service protocol (the protocol followed by the API service, such as HTTP, HTTPS, etc., here HTTP / http is used as an example), HTTP request action (the type of operation performed on the API, also known as request action or request method, such as GET, POST, PUT, DELETE, etc.), API description (description of API functions, uses or restrictions), and other information.
[0101] In the disclosed embodiments, the API interaction mode is divided into asynchronous or synchronous. Synchronous API requires that after the client initiates a request, it must wait until a response is received before continuing to perform other operations. In this mode, there is a direct blocking relationship between the client and the server. Asynchronous API allows the client to return immediately after sending a request, and can continue to perform other tasks without waiting for the server to complete the processing. The client will receive a response from the server at an appropriate time.
[0102] The visual interface in the disclosed embodiment can use Web technologies (such as HTML, CSS, JavaScript, etc.) to build a form page, including all the above configuration items as input fields. Front-end frameworks (such as React, Vue, Angular, etc.) can be used to enhance the user experience. The back-end service receives the form data sent by the front-end, verifies and stores it. A database or configuration file can be used to save API information.
[0103] The new page 400 may also include a submit control 410. The submit control 410 is triggered to complete the configuration of the basic information of the API, and the following is displayed: Figure 5 The API configuration interface 320 is shown. At this time, in addition to the original API "GIS automatic PING test" in the API list, the relevant information of the above configured API, namely "test API001" will be added.
[0104] like Figure 6 As shown, after the basic information of the API is configured, click the API "Test API001" in the API list, and the full version information of the API will appear, such as API name, version number, status, creator, status time, and link name. Here, the API "Test API001" is created for the first time, that is, version v1.0.0. Select the corresponding version as the target version, click the parameter configuration control 322 of the API configuration interface 320 (for example, it can be a "Parameter Configuration" button), and a pop-up window will appear as shown below. Figure 7 The parameter configuration page / parameter configuration interface 700 shown constructs a corresponding parameter list (ie, including input parameters and / or output parameters) and writes input and output parameter scripts (ie, writes the logic processing code of input parameters and / or output parameters in a scripting language).
[0105] like Figure 7 As shown, the parameter configuration interface 700 includes an add input parameter control 710 and an add output parameter control 720. In response to the operation instruction of the add input parameter control, the template of the input (request) parameter of the API can be configured, such as at least one of the serial number, parameter name (parameter identifier), parameter encoding, whether there is an old value, old value strategy, new value strategy, operation, etc. Optionally, the data type of the parameter (such as string, integer, object, etc.) can also be configured; whether it is required: mark whether the parameter is required for the request; description: detailed description of the parameter.
[0106] In response to the operation instruction to add the output parameter control, the template of the output (response) parameters of the API can be configured, such as at least one of the serial number, parameter name, parameter encoding, whether there is an old value, whether to add to the cache, operation, etc., to define the data that should be included in the API response.
[0107] In the visualization page, these parameters can be presented in the form of a table or form, allowing developers to easily add, edit and delete parameters.
[0108] Continue to refer Figure 7 , the parameter configuration interface 700 may also include an add output parameter strategy control 730 and / or an add input parameter strategy control (not shown in the figure). Click "Add input parameter strategy" or "Add output parameter strategy" to pop up the following Figure 8 The scripting language writing interface 800 shown here takes the Groovy scripting language writing interface as an example to complete the logical processing of parameters (input parameters and / or output parameters).
[0109] Figure 8 The specific script content shown in is as follows:
[0110]
[0111]
[0112]
[0113] The above script code example is used to convert the output parameters of the API into JSON format, and then extract the desired response data, that is, the target data returned to the caller.
[0114] In the disclosed embodiments, the scripting language writing interface can be used to write code to implement the complex business logic of the API, such as writing business logic code for processing requests, including data verification, business rule processing, database operations, etc.
[0115] The method provided by the embodiment of the present disclosure can write a Groovy (or other supported language) script for complex APIs to process input parameters, execute business logic and generate output responses. This allows the design of personalized parts / personalized logic / personalized business logic of different APIs to be implemented through the Groovy scripting language. For example, the design of input and output parameters of the API (such as the above-mentioned logical processing of input and output parameters), the design of the execution strategy of the API, and the design of the exception strategy of the API. The configuration of the input and output parameters is personalized logic because different API parameters are different, and the processing logic of the parameters is also different. Other parts such as the basic information of the API, the security control information of the API (i.e., the security call information), etc., all APIs are common code logic (i.e., the public processing logic of the API, and can also include viewing the call log of the API, etc.), and only a set of common design pages needs to be provided. This can reduce the workload of hard coding and high code, and only part of the work needs to be implemented by coding. At the same time, for the Groovy scripting language, it is a lightweight coding. It has low requirements for users, does not require too much programming accumulation, and is simple to get started and easy to use.
[0116] In the disclosed embodiment, after completing the basic information design and input and output parameter information design of the API, the system supports further design of the API, including execution strategy design, exception strategy design, and security management strategy design. Fig. 9 The execution policy configuration interface 910, security policy configuration interface 920, and exception handling policy configuration interface 930 shown can be integrated on the same visualization interface, or can be two or three independent visualization interfaces. The solution provided in the embodiment of the present disclosure can adopt one, two, or three of the three interfaces.
[0117] The execution policy configuration interface 910 can configure the calling mechanism of the API, such as the calling timeout, whether to retry, the retry interval, the number of retries, whether to support idempotency, the request action, etc. Among them, the effect of executing the same idempotent request once is the same as executing it multiple times in succession. The idempotent design ensures that certain operations of the API are idempotent, that is, the results of executing the same operation multiple times are the same as the results of executing it once. This can be achieved by adding a unique identifier (such as a request ID) to the API request and verifying it on the server side. If a duplicate request is detected, you can choose to ignore or return the processed result, thereby avoiding unnecessary rollback operations.
[0118] The security policy configuration interface 920 may include an add security policy control 921 for configuring the API's security call information, such as at least one of the serial number, communication protocol, system identifier, access role, access IP, authentication code, operation, etc. API security control design supports the design of API call control to ensure the security of API calls. This includes API call system authorization, call IP restriction, API key verification, etc. Changed access rights can be modified online.
[0119] The disclosed embodiment has carried out the design of API security management and control. For each API that is "manufactured", security is guaranteed from the design source, and the API calling scenarios in daily use are fully considered. The API caller, calling IP, and API key are verified to ensure the security of each call. The API security solution supports single and combined verification. That is, for the API produced by the system, the source system, source IP, and authentication code can be set for verification separately, or these options can be combined and set as needed, so as to achieve all-round security verification. Single verification: For example, only the call to the API from the system source is verified. Combined verification: The system source, IP source, and API authentication code are verified at the same time, and the call can be passed only if they meet the requirements.
[0120] The exception handling strategy configuration interface 930 may include an add exception handling strategy control 931 to configure comprehensive exception handling logic to ensure that clear error information (such as processing action, target link, exception cause, operation, etc.) is given when an exception occurs, and recovery or rollback operations are performed as much as possible. The rollback strategy is intended to restore the system to a stable state to deal with potential problems caused by errors or exceptions during API execution.
[0121] like Fig. 9As shown, the exception handling strategy configuration interface 930 may also include a compensation mechanism control 932 for designing a compensation strategy for the API. The compensation strategy is used to restore the stability and data consistency of the system by other means when it is not possible to roll back directly to the previous state. For example, a retry mechanism: for API calls that may fail due to temporary errors (such as network fluctuations, temporary unavailability of services, etc.), an automatic retry mechanism is implemented. Different retry strategies and timeouts can be set according to the error type during the retry. Another example is asynchronous processing: asynchronousizing API calls that may cause long waits or high risks. During asynchronous processing, if an error occurs, the data can be repaired or restored by a compensation task. The compensation task can be designed to be executed in the background to reduce interference with the main business process. Another example is data repair: when data is damaged due to API execution errors, a data repair strategy is designed to restore the integrity and consistency of the data. This may include restoring data from backups, using data checksums to detect and repair errors, etc. For complex problems that cannot be solved by automated means, a manual intervention process is designed. Consider fault tolerance in API design, and improve system availability and stability through redundant deployment, load balancing, failover and other technical means. When some services or components fail, the system can automatically switch to backup resources and continue to provide services.
[0122] By properly designing rollback and compensation strategies, you can ensure that the system can recover quickly and continue to operate stably when faced with errors and exceptions.
[0123] The disclosed embodiment takes into account the design of API exception strategy. For API design information, not only normal scenarios are considered, but also the design of abnormal scenarios is included. For general IT exceptions, a general method is used to handle them. For business exceptions, customized design is supported. The design is based on the type of exception and on demand to ensure business rationality.
[0124] In the method provided by the embodiment of the present disclosure, the API information design not only includes the input and output parameter information of the API, but also includes the management information of the API, the abnormal mechanism information of the API, the flow control information of the API, the security information of the API, etc. Compared with the traditional interface development mode, the whole process information of the API from design to application to maintenance is more abundantly defined, ensuring the security, flexibility and efficiency of the actual use of the API. Among them, the management information of the API includes but is not limited to the name of the API, the API code, the API version, the API status, and the creator, creation time, change time and other information of the recorded API. The flow control information of the API includes but is not limited to the priority of the API, the API call control (call timeout setting, whether to retry, the number of retries, the retry interval, etc.). At the same time, the embodiment of the present disclosure realizes the visual configuration of API parsing. For the parsing process of API input and output parameters, the hard-coded mode in the traditional mode is avoided, and the Groovy scripting language is used to realize online editing and real-time effectiveness, and the readability of the later business logic is strong, which reduces the maintenance cost of the API.
[0125] like Fig.10 As shown, after the API information is configured online, you can perform a simulation test on the API configuration page 320. Click the corresponding version of the API (here, "power cutover test" is used as an example), select the simulation test control 323 (for example, a "simulation test" button) on the API configuration page 320, and the following is displayed: Fig.11 Test interface 1100 is shown.
[0126] like Fig.11 As shown, you can directly fill in the URL address 1101 of the tested API in the test interface 1100, complete the input 1102 of the API parameters, and verify the correctness of the API by simulating the call interface (for example, clicking the "Send" button). Monitor the API operation process. The API implemented in this way provides a complete set of API operation monitoring methods to monitor various types of API operation log information, including execution results, execution time, call volume, etc. In the later stage, through the data analysis and optimization, the operation efficiency of the API can be continuously improved, and the stability of the API operation can be further ensured.
[0127] Fig.11Form-data is used to upload files, JSON / XML is used to build the request body, and Header is used to build the request header. Form-data is an HTTP content type used to send files. It is also used to send form data, especially when files need to be uploaded. In this case, the request body is divided into multiple parts, each of which can contain different content types (such as text or binary files). This type of request can be used for APIs for file uploads. HTTP request headers contain various metadata about the request, rather than directly as data in the request body. They provide additional information about the request, such as the type of client, the content type of the request (Content-Type, used to specify the data format in the request body), authentication information, etc. The input parameters of the API can be provided through the request body (Body, such as JSON or XML format) or the request header (Headers).
[0128] The API joint debugging test of the disclosed embodiment uses the test interface in the API design page to simulate the input parameters to complete the API business logic test, and the test problem optimization is directly modified online, and the test is continued until the test passes. Simulate the input parameters to first prepare the test data: prepare the test data according to the requirements of the API, including normal data and abnormal data. Normal data is used to verify the performance of the API under normal circumstances. Abnormal data is used to test the boundary conditions and error handling capabilities of the API. Then construct the request: enter the test data on the test page to construct a request that meets the requirements of the API. Ensure that the header information (such as Content-Type), request method, URL, etc. of the request are correct. Then execute the test, send the request, observe and record the return result of the API. Compare the return result of the API with the expected result to verify whether the API works as expected. Check whether the return result contains the expected data structure and fields. If the return result of the API does not meet expectations, it means that there is a problem. Record the problems found, including descriptions of the problems, conditions for occurrence, possible causes, etc. Depending on the nature of the problem, it may be necessary to modify the test page or the source code of the API. If it is a problem with the test page, you can modify the test page directly. If it is a problem with the API, modify the API. After the modification is completed, re-run the test to verify whether the problem is solved. When all test cases pass the verification and no new problems are found, the API joint debugging test can be considered to have passed. Through the above steps, the API joint debugging test can be effectively performed to ensure that the business logic of the API is correct and improve its stability and reliability.
[0129] In the disclosed embodiment, after the API is designed and tested, by clicking the release control 324 (for example, a "release" button) in the API configuration page 320, the background logic of the button is to load the entire design information of the API into the corresponding different caches. During the operation of the API, the corresponding cache information is read, so that it can be published online without stopping and take effect in real time, so as to achieve the real-time effectiveness of the online deployment of the API. After completing the design and scripting of the API, if everything is normal, the API can be published to the production environment for other systems or applications to call.
[0130] like Fig.12 As shown, you can view API call logs through the log monitoring center to assist in result verification and troubleshooting. Logging can record detailed information about interface calls, including request parameters, response results, call time, etc., to facilitate troubleshooting and performance analysis.
[0131] The disclosed embodiment provides a method for implementing visual configuration of API based on Groovy language, which is an innovative solution that provides effective improvements for problems such as customization, joint debugging cycle and maintainability in API development. The method utilizes the flexibility and dynamism of Groovy language, combined with the visual configuration interface, allowing developers to configure API parameters, request methods, response formats, etc. through a graphical interface without writing a large amount of underlying code. The Groovy script engine is integrated into the configuration interface so that Groovy code can be executed when needed to handle complex logic. Predefined API templates and libraries are provided so that developers can quickly create and configure common API types. Testing tools are also provided to verify whether the configured API works as expected. The deployment process is automated so that the configured API can be quickly deployed to the production environment. The visual configuration method of API based on Groovy language has brought significant improvements to API development by simplifying the development process, shortening the joint debugging cycle and reducing the difficulty of maintainability.
[0132] As the business develops, the API may need to be maintained and iterated. Figure 3 As shown, the API configuration page 320 also includes a modification control 325. When the modification control 325 is triggered, the following may be displayed: Fig.13 The API modification page 1300 shown can modify the basic information of the API, so that the API online design system should support API modification, version control and historical record viewing, so that developers can easily manage and update the API.
[0133] Fig.14Taking the "GIS Traffic and Baseline Instant Query" (the name of the API) API as an example, a schematic diagram of another parameter configuration interface is given to configure the API input and output parameter information, such as the parameter field name, field code, field type, default value and operation, etc. The API input and output parameter information can be selected online.
[0134] Fig.15 The given visual interface can integrate the parameter configuration interface and the script language writing interface at the same time, and the parameter configuration interface and the script language writing interface can be switched in the visual interface.
[0135] In the disclosed embodiment, the writing of API input and output parameter parsing scripts can be realized through the scripting language writing interface. Through the visual editing interface, the Groovy scripting language is used to complete the business logic processing of API input and output parameters. The processing of output and input parameters, for example, can include the conversion of the format of output and / or input parameters; the calculation and processing of parameter values, such as the conversion of enumeration values of return parameters according to the requirements of the upstream system; the generation of third-party parameters through one or more parameter calculations, etc.
[0136] Fig.16 Taking the "GIS traffic and baseline real-time query" API as an example, a schematic diagram of the test interface is shown.
[0137] The following example uses the solution provided by the embodiment of the present disclosure to apply to the operation and dispatch center system (cloud network operation and dispatch center) of the telecommunications industry. As a comprehensive dispatch system for internal personnel, affairs, and objects (i.e., the group comprehensive dispatch system, referred to as the comprehensive dispatch system), the operation and dispatch center system undertakes a large number of complex businesses and has many interfaces with peripheral systems (such as upstream dispatch systems, peripheral systems (including mobile phone APPs), etc.). The API interface in Table 1 below has been implemented using the solution provided by the embodiment of the present disclosure.
[0138] Table 1 Partial API List
[0139]
[0140]
[0141] Passive API calls refer to the system itself as the API provider, receiving API calls from external systems. The API design here is mainly to complete the logical processing after the API is received. Fig.17 In the example, it means that the integrated control system provides API for the upstream system to call.
[0142] Fig.17In the embodiment, the integrated dispatching system provides a payment API through the above solution, and then registers the payment API in Nacos / Dcoos. After that, the integrated dispatching system itself and the upstream system can call the payment API from Nacos / Dcoos when creating orders on the page. That is, payment includes the API dispatch of the upstream system and the page issuance of the integrated dispatching system itself.
[0143] Dcoos is an internal gateway system responsible for API authentication and other operations. If the application is not in an internal system, the work is completed by the application system, which will involve the API security control design module. Nacos is a dynamic service discovery, configuration management and service management platform that is easy to build cloud native applications. API capability registration, complete API interface registration through Nacos or other capability opening platforms. After registration, service applications and production can be provided to the outside world.
[0144] Fig.17 In the embodiment, receiving (entering the cache) refers to generating a log record for the received API, and the log record is first entered into the cache, and then asynchronously entered into the relational database through the queue. Script parsing (entering the cache) refers to parsing the API key information through the script to generate the work order information, and the work order information is first entered into the cache, and then entered into the relational database through the asynchronous queue. The script parsing can parse the script format, and may include the cache parameter information and the storage sql (Structured Query Language), and the storage sql may include business order information, business order attributes, customer information, product information, resource information, etc. Message parsing (entering the cache) refers to parsing the parameters carried by the API through the message, first putting the parameters into the cache, and then entering the relational database through the asynchronous queue. In the embodiment of the present disclosure, the reception of the API, the script parsing of the API, and then the parsing of the message parameters are completed by different services. In order to ensure the processing efficiency of the API, the services are completed by queue decoupling, so queue transmission is adopted.
[0145] Fig.17 In the embodiment, some API processing logic is complex, and the internal logic is processed by the process mode, so it is necessary to start the process engine, that is, Fig.17 "Start a process" in. Message storage refers to saving API message information to a relational database. Business order information storage refers to saving business order information to a relational database. Asynchronous storage refers to completing asynchronous storage through a queue.
[0146] Fig.17In the embodiment, the message transmission queue after the order is collected is multi-queue transmission, and the queue priority is distinguished; the API with high priority is stored in the queue with high priority; the queue with high priority is received and processed first. Different API requests are distinguished by urgency and priority according to the business scenario. When the system call volume is relatively large, the priority processing of important and urgent APIs can be completed by setting the priority. The queue is established in advance according to the business scenario, and the priority of the API is set after the API is received.
[0147] In the disclosed embodiment, for the interface provided to the outside, the input parameter reception and parsing are first performed: the request parsing function provided by the framework is used to receive the request data sent by the client; the received data is verified to ensure the integrity and correctness of the data. This includes data type checking, required item checking, length restrictions, etc. Then the data is stored in the database: the verified data is mapped to the database model or entity class. Exceptions that may be caused by database operations are handled. The interface output parameter construction and return are then performed: according to business needs, the data that needs to be returned is queried from the database. The query results are mapped to the response object. The response construction function provided by the framework is used to convert the response object into JSON format and send it to the client, which is the API return.
[0148] Fig.18 The schematic diagram of an API operation process and an active calling process is shown. The active API calling here refers to the integrated debugging system calling the API provided by the peripheral system. Fig.18 In general, the peripheral system registers an API to Dcoos / Nacos, opens the API to the integrated debugging system, and implements API configuration, that is, writes an API output parameter parsing script. The integrated debugging system locates the API through the API code, and then calls the API to obtain the returned result (output parameter), parses the result using the output parameter parsing script written in the API configuration step, extracts the desired data, caches the desired data first, and then saves it to the database through the asynchronous queue. In this way, the API operation process is mainly calculated and processed through data caching to ensure efficiency; API entry into the database is mainly for data landing storage.
[0149] Important steps in the API call process: input parameter conversion, output parameter parsing script conversion, and unified parsing of output parameters. Input parameter conversion includes matching the API to be called, converting the value from the cache according to the variable in the input parameter template, and converting it into a formal input parameter. That is, the parameter parsed from the message will first be put into the cache, and the subsequent processing of the parameter is all through the operation of the cache, in order to ensure efficiency. Value conversion is that some scenarios will have enumeration value conversion. For example, the upstream transmission rate is 1M, which needs to be converted to 1024 by numerical value before processing. Output parameter parsing script conversion includes, when the API returns, converting the output parameter into a fixed format (such as JSON) according to the output parameter parsing script to facilitate unified parsing. Unified parsing of output parameters includes, after all output parameters are parsed into a unified format, they are parsed by the unified parsing service. After parsing, the data is cached or asynchronously stored, and the process can be operated at the same time.
[0150] Fig.19 The technical architecture diagram of the solution provided for the embodiment of the present disclosure adopts a distributed architecture, microservices, containerized deployment, de-IOE (i.e., removing the dependence on traditional enterprise software and hardware products), Swagger management API (i.e., reading and managing the designed API in a visual way), queue decoupling (through queue decoupling to achieve the stability of API services, prevent the impact of "peak" orders on services, and achieve buffering through queues), off-database operation (mainly used to improve system performance. Traditional databases are only used as database landing storage and do not participate in the calculation of system processes. All process operations are quickly calculated and processed through caching), call chain (mainly for process-based APIs, the internal process of the entire API call is visualized, and the call details inside the API are fully and clearly displayed). The overall principle is to unify PAAS, de-IOE, and integrate development and operation, efficiency, reliability, and security. Unified open source technology components: All technical components used in the system are selected based on the principles of open source, mainstream, security, maturity, and simplified maintenance. Unified data storage service: The unified use of group-defined data access and storage components UDAL (a distributed database system) + TeleDB (a self-developed cloud database based on MySQL), data cache Ctg-Cache (a distributed cache component), Ctg-MQ (a distributed message queue system) message components, etc., reduces the complexity of technical maintenance. Unified cloud technology architecture: The basic implementation layer uses a self-built private cloud (the headquarters system is in a resource pool somewhere), containerized deployment, and easy migration and expansion. That includes the technical components used from the unified facility layer (infrastructure layer) to the data storage layer, data service layer, and Web interaction layer.
[0151] The following describes the technical components used at different levels according to the bottom-up architecture. The unified facility layer mainly refers to the basic resources of this solution; the data storage layer refers to the various ways of data storage used by the system: database, cache, queue. The data service layer mainly refers to the open source components used in this solution and the application services provided by these open source components. The web interaction layer is mainly the user presentation layer, that is, the design page, including the various visual interfaces mentioned above.
[0152] For example, the Web interaction layer can be implemented through Vue, etc., that is, a visual configuration interface is provided, so that developers can configure the basic information of the API (API name, API description, API classification, API type, API version, API status, etc.), input and output parameter information (API input parameter structure, API input parameter list, API output parameter structure, API output parameter list), write input and output parameter parsing groovy scripts (API input parameter processing logic, API output parameter processing logic), API call control information (call timeout, whether to retry after timeout, retry interval, number of retries, etc.), API execution strategy information (set API execution conditions. Some APIs are not directly called externally but internally, and execution conditions need to be set), API exception strategy information (operation settings to be performed after the API encounters an exception), API security management information (some parameter configurations for API security), that is, on this configuration interface, most of the API information is basically fully configured online. In the above configuration process, following a concept, the common logic (public processing logic) is implemented in a fixed unified code, such as: API basic information, API call control information, API security management information; personalized logic is implemented by embedding the Groovy scripting language, such as: API input and output parameter information, API execution strategy information, API exception strategy information.
[0153] In the actual production activities of executing the API, the program will first load the full design information of the API into the memory, and directly execute the referenced Groovy script in the module involving the Groovy scripting language, so as to realize the dynamic execution of personalized logic online design.
[0154] The specific content of the API input and output parameter parsing process provided by the embodiment of the present disclosure is implemented using the Groovy scripting language:
[0155] 1) In order to enhance the flexibility of API instantiation, templates are created for each API type (query class, operation class, process class). For example, for the query class, necessary format conversion and numerical processing are performed on the output parameters; the operation class does not require complex output parameter processing; the process class is mainly to cope with the extremely complex processing logic inside the API, which is implemented by calling multiple atomic API combinations. Templates provide an abstract way to define a set of common functions or behaviors, while allowing customization according to specific needs during instantiation. Therefore, creating templates can enhance the flexibility of API instantiation.
[0156] 2) The template defines the input and output parameters, and sets the rules for obtaining parameter values during the instantiation process. The first is the rule for obtaining the value of which node in the message; the second is to determine whether the parameter value needs to be converted after obtaining the value, such as the conversion of enumeration values or calculating the value of another parameter through one or more parameters.
[0157] 3) Use the Groovy scripting language to pre-process the input and output parameter value sets, including conversion, transformation, direct acquisition or special logic processing. These processing methods ensure that the API input and output parameter templates have a highly static design. The input and output parameter value sets refer to all the output parameter list values and input parameter list values. The essence of the Groovy scripting language is to complete personalized logic processing by writing code online, rather than hard-coding it directly in the engineering project. After the application is started, the design content will first be loaded into the cache. When the API executes to the parameter instantiation stage, it will call the Groovy script in the cache to directly run and get the result of the script running, thus completing the input and output parameter processing operations.
[0158] The disclosed embodiment divides the entire information of the API into several different parts, such as basic information, input and output parameter information, execution strategy, exception strategy, security control strategy, etc. The common part implements universal processing, and the personalized part adopts the method of introducing scripting language to implement customized processing, thereby ensuring that the input and output parameter templates of the API have a high degree of static design, and can be dynamically released without stopping the machine.
[0159] 4) Precompile the Groovy scripting language and store the compiled rules for quick access when the API is instantiated. Precompile the Groovy script into Java bytecode or other forms for fast loading and execution. The Groovy compiler can compile Groovy scripts directly at runtime, but precompiling can improve performance and security.
[0160] 5) When instantiating an API, the compiled Groovy script is combined with dynamic assignment to make the input and output parameter assignment methods very flexible, which is more suitable for the instantiation process involving a large number of different types of APIs.
[0161] Instantiating an API can be understood as a specific call to the API. Write a Groovy script for each API type or for specific needs to preprocess input and output parameters. The Groovy script will be used as a rule definition to convert, calculate, or process other special logic for parameter values. During the API instantiation process, the input and output parameters are processed dynamically according to the stored Groovy script rules. In this way, by using Groovy scripts, great flexibility and dynamism can be provided for the input and output parameter processing of the API, while also maintaining the maintainability and scalability of the code.
[0162] Fig. 20 A functional architecture diagram of an API visual configuration method is shown. API (interface) design includes API configuration, unified acquiring service, and unified calling service; API zero-code development is achieved through API configuration and unified services.
[0163] Among them, API configuration can include API basic information configuration, input / output parameter configuration (input / output parameter template configuration, converting the variables in the input parameters according to the specified format (such as JSON)), and input / output parameter parsing configuration (converting the received input / output parameters according to a unified format, and converting the values in the received message into variables in the parsed message according to a unified format). "Converting the values in the received message into variables in the parsed message according to a unified format" means that after all APIs are received, they will first be uniformly converted into a unified standard JSON format message, in order to ensure the consistency of subsequent logical processing. This layer is used to shield API call requests of different upstream protocols. For example: converting a webservice+XML message into an HTTP+JSON message.
[0164] The API service includes a server and a client. After receiving the API, the server first stores the message asynchronously, then converts the message into a unified format according to the message parsing script template, and finally performs unified parsing of the message into the cache, queue, operation process, etc. The specific operations performed by the server in the API service are to identify the API, parse the API parameters, and process the execution logic of the API. API reception refers to receiving API calls from upstream systems and storing and recording API request records. Messages refer to API request information. The purpose of storing messages is to request record retention and provide a basis for subsequent problem troubleshooting. The message parsing template is a script written in advance.
[0165] The client first locates the specified API (target API), then takes out the parameters from the cache and replaces them with the variables in the input parameter template, then calls the server API, and finally receives the output parameters and parses them according to the server's steps.
[0166] In this way, the public logic and personalized logic of the API are effectively separated, which not only ensures the scalability and maintainability of the system, but also provides flexible configuration and deployment capabilities.
[0167] Fig.21 An API design specification in an embodiment of the present disclosure is shown. Fig. 22 for Fig.21 A partial enlarged view of area A in FIG. Fig.23 for Fig. 22 A partial enlarged view of area B in the diagram. This mainly shows the scope of API design. The disclosed embodiment can configure new interface services through a visual interface according to the needs of the business and surrounding systems, making the service flexible and configurable, and quickly supporting the launch of new businesses.
[0168] Specifically, API design includes definition (defining basic attributes of capabilities: such as capability name, type, description, version, priority, etc., i.e. basic information of API), input parameters (setting capability input parameters: such as product instance ID, service serial number, standard address), output parameters (setting capability output parameters: such as pass, fail, satisfaction), management (defining the management functions of the capability itself: such as creation, modification, online, offline, etc., API version, API status and other information), exception mechanism (defining the processing mechanism when capability calls are abnormal, such as: retry mechanism, ignore mechanism, compensation mechanism, i.e. setting API exception strategy information), flow control setting (setting the flow control strategy of capability, i.e. setting API call mechanism information, such as: when QPS>600, whether to fail quickly or queue) and security setting (setting the access security strategy of capability, i.e. API security management information, such as: transmission protocol: http / https; access role: group / province). Input parameters / output parameters refer to the input and output parameter information of API. The "capability" mentioned above refers to "API". Capability name, type, description, version and priority refer to API name, API type, API description, API version and API priority. Capability input parameters refer to API input parameters. Product instance ID, service serial number and standard address are specific example fields of input parameters. Capability output parameters refer to API output parameters. The solution provided by the embodiment of the present disclosure supports lifecycle management functions such as API launch, release, and offline; it also supports multi-version management functions for the same API. An automatic exception handling mechanism is implemented by means of API re-calling, exception ignoring, API rollback, API compensation and other means. When the system detects that the current work order traffic is too large and affects the application itself or the downstream production system, the current call will be directly handled as a failure and will no longer occupy system resources. The source calling system, source IP and authentication code of the API are verified to ensure that only call requests that meet the requirements can implement the API call.
[0169] The solution provided by the embodiments of the present disclosure, on the one hand, reduces the capability requirements for developers. Through the online editing method of the scripting language, business personnel can directly use the API design platform to efficiently complete the API design. On the other hand, it achieves comprehensive coverage of basic API information, including not only basic API information, but also adds exception information, security information, and execution information (i.e., the execution strategy of the designed API. For process-type APIs, they are implemented by assembling multiple atomic combination APIs, and different atomic API executions require different execution conditions to be set). The all-round online design further ensures the high security, high compatibility, and high operability of the API implemented using this technical solution.
[0170] The disclosed embodiment completes the full design of the basic information, security information, exception information, and execution information of the API in a visual way to ensure the security, stability, and efficiency of the API operation. By introducing the Groovy scripting language, the online editing of the API background business logic is realized, which takes effect in real time and is separated from the hard-coding method, greatly improving the implementation efficiency of the business API. The input and output parameters of the API and the input and output parameter parsing are visually edited. The back-end processing process of the entire API does not need to be implemented in traditional ways such as hard coding and high code. The public processing logic of the API is extracted, and the personalized business logic of the API is independent. The personalized logic is designed one-to-one according to the API, and different APIs have independent input and output parameter design, execution strategy design, exception strategy design, and security control strategy design. The back-end business processing logic of the API is visually edited using the Groovy scripting language to ensure that the APIs do not affect each other, and the online deployment takes effect in real time. In this way, the complexity of API development can be simplified, and most of the hard coding is converted to online configuration mode; the API joint debugging cycle is greatly reduced, shortening the business launch cycle; the later API maintenance is visualized to reduce the difficulty of maintenance.
[0171] The disclosed embodiment introduces the Groovy scripting language to implement API online configuration and analysis, avoiding the "hard coding" in the traditional interface development process. According to the needs of the business and surrounding systems, new API services are configured through a visual interface, making the service flexible and configurable, and quickly supporting the launch of new businesses.
[0172] In the traditional software development process, when it comes to providing or calling external interface scenarios, customized development and hard coding are often used to implement interface functions. This method requires high developer capabilities, a long joint debugging cycle, and high subsequent maintenance costs. Based on this background, the disclosed embodiment proposes a method for implementing API visual configuration parsing based on the Groovy language. The common logic of the API is uniformly abstracted, and the personalized logic of the API is extracted and implemented independently through the Groovy scripting language without affecting each other, visual editing, and real-time online deployment. The present invention can greatly reduce the difficulty of API development, improve the efficiency of business delivery, and support the rapid development of new businesses.
[0173] The solution provided by the embodiments of the present disclosure can be applied to the following scenarios: full interaction between the operation and dispatch center system and peripheral systems; IT interaction between operator industry systems. Create a new API implementation model, realize business logic code visualization, improve API development efficiency, and assist in loading new businesses. Through comprehensive design coverage, including basic information, input and output parameter information, execution information, security information, flow control information, etc., the security, efficiency, stability, and maintainability of API operation are further improved. By standardizing the output of API in a "factory"-like manner and providing a complete set of API operation log analysis, the API design can be continuously improved, improved, and optimized, thereby facilitating high-quality business development.
[0174] like Fig.24 As shown, the application interface visualization configuration device 100 includes a display unit 110 and a processing unit 120. The display unit 110 is used to display an application interface configuration interface, and the application interface configuration interface includes an application interface list. The display unit 110 is also used to respond to a first operation instruction to a target application interface in the application interface list, and display an exception handling policy configuration interface of the target application interface, and the exception handling policy configuration interface includes adding an exception handling policy control. The processing unit 120 is used to respond to a trigger operation to the exception handling policy control, and associate the exception operation code of the target application interface with the corresponding exception event, so that when the exception operation code appears during the operation of the target application interface, the corresponding exception handling operation is performed according to the associated exception event.
[0175] Fig.24 For other contents of the embodiment, reference can be made to the above embodiment and will not be repeated here.
[0176] Furthermore, an embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the method described in any embodiment of the present disclosure by executing the executable instructions.
[0177] Furthermore, an embodiment of the present disclosure also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described in any embodiment of the present disclosure is implemented.
[0178] Furthermore, an embodiment of the present disclosure also provides a computer program product, which includes a computer program. When the computer program is executed, the method described in any embodiment of the present disclosure is executed.
[0179] It should be noted that the above modules / units as part of the device can be executed in a computer system such as a set of computer executable instructions.
[0180] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0181] Refer to the following Fig.25 The electronic device 200 according to this embodiment of the present disclosure is described. Fig.25 The electronic device 200 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0182] like Fig.25 As shown, the electronic device 200 is in the form of a general computing device. The components of the electronic device 200 may include but are not limited to: at least one processing unit 210, at least one storage unit 220, and a bus 230 connecting different system components (including the storage unit 220 and the processing unit 210).
[0183] The storage unit 220 stores program codes, which can be executed by the processing unit 210, so that the processing unit 210 executes the steps described in the above “Exemplary Method” section of this specification according to various exemplary embodiments of the present disclosure.
[0184] The storage unit 220 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 2201 and / or a cache memory unit 2202 , and may further include a read-only memory unit (ROM) 2203 .
[0185] The storage unit 220 may also include a program / utility 2204 having a set (at least one) of program modules 2205, such program modules 2205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0186] Bus 230 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0187] The electronic device 200 may also communicate with one or more external devices 240 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 200, and / or communicate with any device that enables the electronic device 200 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 250. Furthermore, the electronic device 200 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 260. As shown, the network adapter 260 communicates with other modules of the electronic device 200 via a bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 200, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
Claims
1. A method for visual configuration of an application program interface, characterized in that: include: Displaying an application program interface configuration interface, wherein the application program interface configuration interface includes an application program interface list; In response to a first operation instruction on a target application program interface in the application program interface list, displaying an exception handling policy configuration interface of the target application program interface, wherein the exception handling policy configuration interface includes an add exception handling policy control; In response to a triggering operation on the exception handling policy control, the exception operation code of the target application program interface is associated with a corresponding exception event, so that when the exception operation code appears during the operation of the target application program interface, a corresponding exception handling operation is performed according to the associated exception event.
2. The method according to claim 1, characterized in that: In response to a triggering operation on the exception handling strategy control, associating the exception operation code of the target application program interface with a corresponding exception event, including: If the abnormal event is a business abnormality, then the corresponding exception handling strategy is associated with the type of business abnormality to perform the corresponding exception handling operation; The exception handling strategy includes at least one of rollback, compensation, and ignore.
3. The method according to claim 2, characterized in that The service anomaly includes a local end parameter anomaly and / or a peer end data anomaly; Parameter anomalies on the local end include missing parameters and / or parameter errors; Peer data anomalies include data duplication and / or data non-existence.
4. The method according to claim 1, characterized in that: If the abnormal event is a network abnormality, the abnormality handling operation is a general handling method.
5. The method according to claim 4, characterized in that The network anomaly includes interface timeout and / or service downtime.
6. The method according to claim 1, characterized in that Also includes: In response to a second operation instruction on a target application program interface in the application program interface list, displaying a security policy configuration interface of the target application program interface, wherein the security policy configuration interface includes adding a security policy control; In response to the operation instruction to add the security policy control, the security calling information of the target application program interface is configured so that when the target application program interface is called, the caller is allowed to call the target application program interface if it meets the security calling information.
7. The method according to claim 6, characterized in that The security call information includes at least one of a communication protocol, an allowed call system identifier, a trusted address, and an authentication code.
8. The method according to claim 1, characterized in that Also includes: In response to a third operation instruction on a target application program interface in the application program interface list, displaying an execution policy configuration interface of the target application program interface; In response to an operation instruction on the execution policy configuration interface, execution policy information of the target application program interface is configured.
9. The method according to claim 8, characterized in that The execution strategy information includes at least one of a call timeout, whether to retry, a retry interval, the number of retries, whether to support idempotence, and a request action.
10. The method according to claim 1, characterized in that The application program interface configuration interface also includes a parameter configuration control; wherein the method further includes: In response to a fourth operation instruction on the target application program interface in the application program interface list, displaying version information of the target application program interface in the application program interface configuration interface; In response to a selection operation of a target version in the version information of the target application program interface and a trigger operation of the parameter configuration control, a parameter configuration interface is displayed, wherein the parameter configuration interface includes an add input parameter control and an add output parameter control; In response to the operation instructions for adding the input parameter control and the adding the output parameter control, the input and output parameter information of the target application program interface is configured.
11. The method according to claim 10, characterized in that The parameter configuration interface also includes adding an outgoing parameter strategy control and / or adding an incoming parameter strategy control; wherein the method further includes: In response to adding an outgoing parameter strategy control or adding an incoming parameter strategy control, a scripting language writing interface is displayed; The logic processing code of the input and output parameter information is written in the script language writing interface using a script language.
12. The method according to claim 10, characterized in that The application program interface configuration interface also includes a simulation test control; wherein the method further includes: In response to a selection operation of a target version in the version information of the target application program interface and a trigger operation of the simulation test control, a test interface of the target application program interface is displayed; In response to the operation instruction of the test interface, a simulation test of the target application program interface is performed.
13. The method according to claim 1, characterized in that Displays the application interface configuration interface, including: Displaying an application program interface design interface, wherein the application program interface design interface includes directory information of the engineering project; In response to a selection operation of a target directory in the directory information, displaying the application program interface configuration interface, the application program interface configuration interface including a new creation control; In response to a trigger instruction for the newly created control, a new application program interface page is displayed; In response to an operation instruction to create a new page for the application program interface, basic information of the target application program interface is configured.
14. The method according to claim 13, characterized in that The basic information includes at least one of the following: application program interface name, application program interface code, application program interface version, application program interface type, application program interface provider, application program interface consumer, application program interface host address, application program interface consumption path, whether to retry, number of retries, retry interval, timeout limit, data format, application program interface interaction mode, application program interface service protocol, HTTP request action, and application program interface description.
15. An application program interface visual configuration device, characterized in that: include: A display unit, used to display an application program interface configuration interface, wherein the application program interface configuration interface includes an application program interface list; The display unit is further configured to respond to a first operation instruction on a target application program interface in the application program interface list and display an exception handling strategy configuration interface of the target application program interface, wherein the exception handling strategy configuration interface includes an addition exception handling strategy control; A processing unit is used to respond to the triggering operation of the exception handling policy control, associate the exception operation code of the target application interface with the corresponding exception event, so that when the exception operation code appears during the operation of the target application interface, the corresponding exception handling operation is performed according to the associated exception event.
16. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 14 by executing the executable instructions.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 14 is implemented.
18. A computer program product, comprising a computer program, which executes the method according to any one of claims 1 to 14 when the computer program is executed.
Citation Information
Cited By
Abnormal interaction service compensation method and system in medical data exchange, electronic equipment and storage medium
CN121333776A