Interface contract optimization adjustment method and device

By optimizing and adjusting the methods and devices for interface contracts, and automating the monitoring and updating of interface protocols, the problem of untimely maintenance of interface protocols has been solved, thereby improving R&D efficiency and testing efficiency.

CN115756667BActive Publication Date: 2026-04-28PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PING AN BANK CO LTD
Filing Date
2022-11-22
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

The lack of automated monitoring and updating of interface protocols in existing technologies leads to low R&D efficiency and low interface protocol testing efficiency, making it impossible to guarantee timely maintenance and the latest version of the interface protocols.

Method used

The utility class is initialized by receiving application startup instructions, the interface model is scanned, interfaces that do not conform to the protocol are automatically covered or reported, and Swagger is used for automated rectification and release to achieve matching between interface data and model data.

Benefits of technology

It enables automated monitoring and updating of interface protocols, improving R&D efficiency and interface protocol testing efficiency, and ensuring timely maintenance and consistency of interface protocols.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115756667B_ABST
    Figure CN115756667B_ABST
Patent Text Reader

Abstract

The application relates to an interface contract optimization adjustment method and device, a terminal and a computer readable storage medium. The interface contract optimization adjustment method comprises the following steps: after a spring bean is initialized, a tool class is used for interception and scanning; if the rest&rpc interface model in the scanning result contains an annotation swagger, the interface protocol on the arena is automatically covered, so that the interface protocol on the arena can be kept consistent with the interface protocol in the code without manual configuration of the interface protocol on the arena; if the rest&rpc interface model in the scanning result does not contain the swagger annotation, the rest&rpc interface model without the swagger annotation is reported to an interface protocol management system for subsequent processing; the interface protocol management system scans an arena interface list according to a preset period, and judges whether the interface data of the arena interface list matches the interface model data; if the interface data of the arena interface list does not match the interface model data, automatic rectification and release are performed in the swagger mode, the automatic monitoring and updating of the interface protocol can be realized, and the research and development efficiency and the interface protocol test efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data interface optimization and processing technology, and in particular to an interface contract optimization and adjustment method and apparatus. Background Technology

[0002] Improving R&D efficiency is a timeless topic. High-efficiency R&D gives manufacturers a natural market advantage, enabling them to deliver products on time and seize market share. Interface contract governance is a crucial aspect of R&D efficiency. It serves as the link between front-end and back-end parallel development and provides input parameters for automated interface testing, significantly saving R&D time and costs and increasing productivity.

[0003] In daily front-end and back-end development, back-end developers maintain the interface protocol on arena or yapi. However, whether it is maintained, how timely it is, and whether the interface protocol is up-to-date are entirely dependent on the subjective judgment of the back-end developers. There is no monitoring tool to verify whether the interface protocol is maintained or up-to-date, which is clearly unreasonable. Furthermore, testers need to double-check with developers to ensure the interface protocol exists and is the latest version before writing automated test cases and completing interface tests, leading to low testing efficiency. Summary of the Invention

[0004] This application provides a method and apparatus for optimizing and adjusting interface contracts, which can not only automate the monitoring and updating of interface protocols, but also improve R&D efficiency and interface protocol testing efficiency.

[0005] The technical solution of this application is as follows:

[0006] According to a first aspect of the embodiments of this application, an interface contract optimization and adjustment method is provided, comprising:

[0007] Receive the application startup command and initialize a specific utility class;

[0008] After the Spring bean is initialized, the aforementioned utility class is used for interception and scanning.

[0009] If the scan results contain Swagger annotations in the REST & RPC interface model, the interface protocol on the arena will be automatically overridden.

[0010] If the REST & RPC interface model in the scan results does not contain the Swagger annotation, the REST & RPC interface model without the Swagger annotation will be reported to the interface protocol governance system for further processing.

[0011] The interface protocol governance system scans the arena interface list at a preset cycle and determines whether the interface data in the arena interface list matches the interface model data.

[0012] If the interface data in the arena interface list does not match the interface model data, an alarm message will be generated to indicate that the interface protocol needs to be changed.

[0013] Swagger is used to automate the rectification and release of alarm interface protocols, so as to achieve matching between the interface data of the arena interface list and the interface model data.

[0014] Optionally, the utility class is used to scan the initialized Spring bean, including scanning REST interfaces with requestMapping, getMapping, and postMapping annotations and RPC interfaces with ESA annotations, while parsing the input parameters and interface types, and saving the parsed input parameters and interface types to the interface model.

[0015] Optionally, determining whether the interface data in the arena interface list matches the interface model data includes:

[0016] Compare whether the interface data in the arena interface list matches the interface model data, wherein the interface data includes a Uniform Resource Locator, interface name, output parameters, input parameters, and parameter types;

[0017] If at least one of the Uniform Resource Locator, Interface Name, Output Parameter, Input Parameter, or Parameter Type does not match the Interface Model Data, then the interface data in the arena interface list is determined to be inconsistent with the interface model data.

[0018] If the Uniform Resource Locator, Interface Name, Output Parameters, Input Parameters, and Parameter Type all match the Interface Model Data, then the interface data in the arena interface list is determined to match the Interface Model Data.

[0019] Optionally, the Swagger annotations include the API annotation, APIOperation annotation, APIImplicitParams annotation, APIImplicitParam annotation, APIResponses annotation, and APIResponse annotation. Among them, the APIImplicitParam annotation includes paramType indicating the location of the parameter, parameter name, parameter type dataType, required indicating whether the parameter is required, parameter comment value, and parameter default value.

[0020] According to a second aspect of the embodiments of this application, an interface contract optimization and adjustment apparatus is provided, comprising:

[0021] The receiving module is used to receive application startup commands and initialize a specific utility class.

[0022] The scanning module is used to intercept and scan Spring beans after they are initialized using the utility class.

[0023] The overriding module is used to automatically override the interface protocol on the arena if the REST & RPC interface model in the scan results contains the Swagger annotation.

[0024] The reporting module is used to report the REST & RPC interface model without Swagger annotation to the interface protocol governance system for further processing if the scan results show that the REST & RPC interface model does not contain Swagger annotation.

[0025] The judgment module is used by the interface protocol governance system to scan the arena interface list at a preset period and determine whether the interface data in the arena interface list matches the interface model data.

[0026] The alarm module is used to generate alarm information to indicate that the interface protocol needs to be changed if the interface data in the arena interface list does not match the interface model data.

[0027] The processing module is used to automate the rectification and release of alarm interface protocols using Swagger, so as to achieve the matching of interface data in the arena interface list with interface model data.

[0028] Optionally, the utility class is used to scan the initialized Spring bean, including scanning REST interfaces with requestMapping, getMapping, and postMapping annotations and RPC interfaces with ESA annotations, while parsing the input parameters and interface types, and saving the parsed input parameters and interface types to the interface model.

[0029] Optionally, the determination module is specifically used for:

[0030] Compare whether the interface data in the arena interface list matches the interface model data, wherein the interface data includes a Uniform Resource Locator, interface name, output parameters, input parameters, and parameter types;

[0031] If at least one of the Uniform Resource Locator, Interface Name, Output Parameter, Input Parameter, or Parameter Type does not match the Interface Model Data, then the interface data in the arena interface list is determined to be inconsistent with the interface model data.

[0032] If the Uniform Resource Locator, Interface Name, Output Parameters, Input Parameters, and Parameter Type all match the Interface Model Data, then the interface data in the arena interface list is determined to match the Interface Model Data.

[0033] Optionally, the Swagger annotations include the API annotation, APIOperation annotation, APIImplicitParams annotation, APIImplicitParam annotation, APIResponses annotation, and APIResponse annotation. Among them, the APIImplicitParam annotation includes paramType indicating the location of the parameter, parameter name, parameter type dataType, required indicating whether the parameter is required, parameter comment value, and parameter default value.

[0034] According to a third aspect of the embodiments of this application, a terminal is provided, comprising: a processor, and a memory communicatively connected to the processor;

[0035] The memory stores computer-executed instructions;

[0036] The processor executes computer execution instructions stored in the memory to implement the method provided in the first aspect.

[0037] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein computer-executable instructions are stored in the computer-readable storage medium, and the computer-executable instructions are executed by a processor to implement the method provided in the first aspect.

[0038] Beneficial effects:

[0039] This application discloses an interface contract optimization and adjustment method and apparatus. Upon receiving an application startup command, a specific utility class is initialized. After the Spring bean is initialized, this utility class is used for interception and scanning. If the scan result shows a REST & RPC interface model containing the Swagger annotation, the interface protocol on the arena is automatically overridden, thus maintaining consistency with the interface protocol in the code without requiring manual configuration on the arena. If the scan result shows a REST & RPC interface model without the Swagger annotation, the REST & RPC interface model without the Swagger annotation is reported to the interface protocol governance system for further processing. The interface protocol governance system scans the arena interface list according to a preset period and determines whether the interface data in the arena interface list matches the interface model data. If the interface data in the arena interface list does not match the interface model data, an alarm message is generated indicating that the interface protocol needs to be changed. The alarmed interface protocol is automatically rectified and released using Swagger to achieve matching between the interface data in the arena interface list and the interface model data. This not only enables automated monitoring and updating of the interface protocol but also improves development efficiency and interface protocol testing efficiency.

[0040] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application, and do not constitute an undue limitation of this application.

[0042] Figure 1 This is a flowchart illustrating an interface contract optimization and adjustment method provided by this application according to an exemplary embodiment;

[0043] Figure 2 This is a schematic diagram illustrating the structure of an interface contract optimization and adjustment device according to an exemplary embodiment;

[0044] Figure 3 This is a schematic diagram of the structure of a terminal according to an exemplary embodiment. Detailed Implementation

[0045] To enable those skilled in the art to better understand the technical solutions of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0046] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0047] Figure 1 A flowchart illustrating an interface contract optimization and adjustment method provided for an exemplary embodiment of this application. Figure 1 As shown, the specific steps of this interface contract optimization and adjustment method are as follows:

[0048] Step S110: Receive the application startup command and initialize a specific utility class.

[0049] When the application starts according to the received application startup command, a specific utility class is initialized. This utility class can then be used to intercept and scan the initialized Spring beans. In Spring, objects that constitute the backbone of the application and are managed by the Spring IoC container are called beans. A Spring bean is an object that is instantiated, assembled, and managed by the Spring IoC container.

[0050] Step S120: After the Spring bean is initialized, the utility class is used for interception and scanning.

[0051] After a Spring bean is initialized, a utility class is used for interception and scanning. This specific utility class intercepts and scans all initialized Spring beans. The scanning of initialized Spring beans by the utility class includes scanning REST interfaces with requestMapping, getMapping, and postMapping annotations, as well as RPC interfaces with ESA annotations. At the same time, the input parameters and interface types are parsed out, and the parsed input parameters and interface types are saved to the interface model.

[0052] Step S130: If the REST & RPC interface model in the scan results contains the Swagger annotation, automatically override the interface protocol on the arena.

[0053] If the REST & RPC interface model in the scan results contains the Swagger annotation, there's no need to manually configure the interface protocol on the arena; it will automatically override the arena's interface protocol, maintaining consistency with the interface in the code. Swagger annotations include the API annotation, APIOperation annotation, APIImplicitParams annotation, APIImplicitParam annotation, APIResponses annotation, and APIResponse annotation. The APIImplicitParam annotation includes `paramType` indicating the parameter's location, `name` indicating the parameter's name, `dataType` indicating the parameter's type, `required` indicating whether the parameter is required, the parameter's comment `value`, and the parameter's default value `defaultValue`.

[0054] The `@Api` annotation is used on the controller to annotate it; the `@ApiOperation` annotation is used on the API method to annotate the API and explain its function; the `@ApiImplicitParams` annotation is used to contain a group of API parameter annotations, which can be simply understood as a collection declaration of parameter annotations; the `@ApiImplicitParam` annotation is used within the `@ApiImplicitParams` annotation, or can be used alone, to describe various aspects of a request parameter. Common options for this annotation include `paramType` indicating the parameter's location, `name`, `dataType`, `required` indicating whether the parameter is required, the parameter's comment `value`, and the parameter's default value `defaultValue`. `paramType` indicating the parameter's location includes `query`, `header`, `path`, `body`, and `form`, with the first four being the most commonly used. The `@ApiResponses` annotation is typically used to contain a group of API response annotations, which can be simply understood as a collection declaration of response annotations; the `@ApiResponse` annotation is used within `@ApiResponses` and is generally used to express an error response message.

[0055] Step S140: If the REST & RPC interface model in the scan results does not contain the Swagger annotation, report the REST & RPC interface model without the Swagger annotation to the interface protocol governance system for further processing.

[0056] Step S150: The interface protocol governance system scans the arena interface list according to a preset cycle and determines whether the interface data in the arena interface list matches the interface model data.

[0057] The interface protocol governance system scans the arena interface list at preset intervals. The pre-screening interval can be either 10 seconds or one minute. This means the system automatically scans the arena interface list periodically and compares the interface data with the interface model data. It primarily determines whether the interface data in the arena interface list matches the interface model data by comparing the Uniform Resource Locator (URL), interface name, output parameters, input parameters, and parameter types. Specifically, if at least one of the URL, interface name, output parameters, input parameters, or parameter types does not match the interface model data, then the interface data in the arena interface list is considered to be mismatched. If all of these match, then the interface data in the arena interface list is considered to match the interface model data.

[0058] Step S160: If the interface data in the arena interface list does not match the interface model data, an alarm message is generated to remind that the interface protocol needs to be changed.

[0059] Step S170: Use Swagger to automatically rectify and publish the alarm interface protocols in order to achieve matching between the interface data in the arena interface list and the interface model data.

[0060] Specifically, for interface models that do not match the arena interface list data, an alert is generated to notify application owners and developers to promptly rectify such interface models. Furthermore, if the interface data in the arena interface list matches the interface model data, but the REST & RPC interface model does not include Swagger annotations, Swagger annotations must be added promptly. Swagger is used to automatically rectify and release non-compliant interface protocols, ensuring that the arena interface list data matches the interface model data. Developers then rectify and release non-compliant interface protocols using Swagger, achieving automated governance.

[0061] This application discloses an interface contract optimization and adjustment method and apparatus. Upon receiving an application startup command, a specific utility class is initialized. After the Spring bean is initialized, this utility class is used for interception and scanning. If the scan result shows a REST & RPC interface model containing the Swagger annotation, the interface protocol on the arena is automatically overridden, thus maintaining consistency with the interface protocol in the code without requiring manual configuration on the arena. If the scan result shows a REST & RPC interface model without the Swagger annotation, the REST & RPC interface model without the Swagger annotation is reported to the interface protocol governance system for further processing. The interface protocol governance system scans the arena interface list according to a preset period and determines whether the interface data in the arena interface list matches the interface model data. If the interface data in the arena interface list does not match the interface model data, an alarm message is generated indicating that the interface protocol needs to be changed. The alarmed interface protocol is automatically rectified and released using Swagger to achieve matching between the interface data in the arena interface list and the interface model data. This not only enables automated monitoring and updating of the interface protocol but also improves development efficiency and interface protocol testing efficiency.

[0062] Figure 2 This is a schematic diagram of an interface contract optimization and adjustment device provided for an exemplary embodiment of this application. The interface contract optimization and adjustment device provided in this embodiment can execute the processing flow provided in an embodiment of an interface contract optimization and adjustment method. Figure 2 As shown, the interface contract optimization and adjustment device 20 provided in this application includes a receiving module 201, a scanning module 202, a coverage module 203, a reporting module 204, a judgment module 205, an alarm module 206, and a processing module 207.

[0063] The receiving module 201 is used to receive the application startup command and initialize a specific utility class.

[0064] The scanning module 202 is used to intercept and scan the Spring bean after it is initialized using the utility class.

[0065] The overriding module 203 is used to automatically override the interface protocol on the arena if the REST & RPC interface model in the scan results contains the Swagger annotation.

[0066] The reporting module 204 is used to report the REST & RPC interface model without Swagger annotation to the interface protocol governance system for further processing if the scan results show that the REST & RPC interface model does not contain Swagger annotation.

[0067] The judgment module 205 is used by the interface protocol governance system to scan the arena interface list according to a preset period and determine whether the interface data in the arena interface list matches the interface model data. The interface data includes a Uniform Resource Locator (URI), interface name, output parameters, input parameters, and parameter types. If at least one of the URI, interface name, output parameters, input parameters, or parameter types does not match the interface model data, then the interface data in the arena interface list is determined to be mismatched with the interface model data. If all of the URI, interface name, output parameters, input parameters, and parameter types match the interface model data, then the interface data in the arena interface list is determined to match the interface model data.

[0068] The alarm module 206 is used to generate an alarm message to indicate that the interface protocol needs to be changed if the interface data in the arena interface list does not match the interface model data.

[0069] Processing module 207 is used to automatically rectify and publish alarm interface protocols using Swagger, so as to achieve matching between interface data in the arena interface list and interface model data.

[0070] Optionally, the utility class is used to scan the initialized Spring bean, including scanning REST interfaces with requestMapping, getMapping, and postMapping annotations and RPC interfaces with ESA annotations, while parsing the input parameters and interface types, and saving the parsed input parameters and interface types to the interface model.

[0071] Optionally, the Swagger annotations include the API annotation, APIOperation annotation, APIImplicitParams annotation, APIImplicitParam annotation, APIResponses annotation, and APIResponse annotation. Among them, the APIImplicitParam annotation includes paramType indicating the location of the parameter, parameter name, parameter type dataType, required indicating whether the parameter is required, parameter comment value, and parameter default value.

[0072] The apparatus provided in this application embodiment can be specifically used to perform the above-described... Figure 1 The specific functions and technical effects of the solutions provided in the corresponding method embodiments will not be elaborated here.

[0073] like Figure 3 The present invention also provides a terminal 30 including a processor 301 and a memory 302 communicatively connected to the processor.

[0074] Memory 302 is used to store computer-executed instructions;

[0075] The processor 301 is used to execute computer execution instructions stored in the memory to implement the interface contract optimization and adjustment method provided in any of the above method embodiments. The specific functions and technical effects that can be achieved will not be elaborated here.

[0076] This application also provides a computer-readable storage medium storing computer-executable instructions. When executed by a processor, the computer-executable instructions are used to implement the solution provided in any of the above method embodiments. The specific functions and technical effects to be achieved are not described here.

[0077] This application also provides a computer program product, which includes a computer program stored in a readable storage medium. At least one processor of the electronic device can read the computer program from the readable storage medium. The at least one processor executes the computer program to cause the electronic device to perform the solution provided in any of the above method embodiments. The specific functions and technical effects that can be achieved are not described here.

[0078] The application scenarios described in this application are for the purpose of more clearly illustrating the technical solutions of this application, and do not constitute a limitation on the technical solutions provided in this application. As those skilled in the art will know, with the emergence of new application scenarios, the technical solutions provided in this application are also applicable to similar technical problems.

[0079] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0080] In some possible implementations, the electronic device according to this application may include at least one processor and at least one memory. The memory stores program code that, when executed by the processor, causes the processor to perform the operational data management methods according to the various exemplary embodiments of this application described above. For example, the processor may perform steps such as those in the operational data management method.

[0081] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0082] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0083] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0084] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable image scaling device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable image scaling device, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0085] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable image scaling device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0086] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0087] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for optimizing and adjusting an interface contract, characterized in that, The interface contract optimization and adjustment method includes: Receive the application startup command and initialize a specific utility class; After the Spring bean is initialized, the aforementioned utility class is used for interception and scanning. If the scan results contain Swagger annotations in the REST & RPC interface model, the interface protocol on the arena will be automatically overridden. If the REST & RPC interface model in the scan results does not contain the Swagger annotation, the REST & RPC interface model without the Swagger annotation will be reported to the interface protocol governance system for further processing. The interface protocol governance system scans the arena interface list at a preset cycle and determines whether the interface data in the arena interface list matches the interface model data. If the interface data in the arena interface list does not match the interface model data, an alarm message will be generated to indicate that the interface protocol needs to be changed. Swagger is used to automate the rectification and release of alarm interface protocols, so as to achieve matching between the interface data of the arena interface list and the interface model data.

2. The interface contract optimization and adjustment method as described in claim 1, characterized in that, The utility class is used to scan the initialized Spring bean, including scanning REST interfaces with requestMapping, getMapping, and postMapping annotations and RPC interfaces with ESA annotations. At the same time, the input parameters and interface types are parsed out and saved to the interface model.

3. The interface contract optimization and adjustment method as described in claim 1, characterized in that, The step of determining whether the interface data in the arena interface list matches the interface model data includes: Compare whether the interface data in the arena interface list matches the interface model data, wherein the interface data includes a Uniform Resource Locator, interface name, output parameters, input parameters, and parameter types; If at least one of the Uniform Resource Locator, Interface Name, Output Parameter, Input Parameter, or Parameter Type does not match the Interface Model Data, then the interface data in the arena interface list is determined to be inconsistent with the interface model data. If the Uniform Resource Locator, Interface Name, Output Parameters, Input Parameters, and Parameter Type all match the Interface Model Data, then the interface data in the arena interface list is determined to match the Interface Model Data.

4. The interface contract optimization and adjustment method as described in claim 1, characterized in that, The Swagger annotations include the API annotation, APIOperation annotation, APIImplicitParams annotation, APIImplicitParam annotation, APIResponses annotation, and APIResponse annotation. Among them, the APIImplicitParam annotation includes the paramType indicating the location of the parameter, the parameter name, the parameter type dataType, the required indicating whether the parameter is required, the parameter comment value, and the parameter default value.

5. An interface contract optimization and adjustment device, characterized in that, The interface contract optimization and adjustment device includes: The receiving module is used to receive application startup commands and initialize a specific utility class. The scanning module is used to intercept and scan Spring beans after they are initialized using the utility class. The overriding module is used to automatically override the interface protocol on the arena if the REST & RPC interface model in the scan results contains the Swagger annotation. The reporting module is used to report the REST & RPC interface model without Swagger annotation to the interface protocol governance system for further processing if the scan results show that the REST & RPC interface model does not contain Swagger annotation. The judgment module is used by the interface protocol governance system to scan the arena interface list at a preset period and determine whether the interface data in the arena interface list matches the interface model data. The alarm module is used to generate alarm messages to indicate that the interface protocol needs to be changed if the interface data in the arena interface list does not match the interface model data. The processing module is used to automate the rectification and release of alarm interface protocols using Swagger, so as to achieve the matching of interface data in the arena interface list with interface model data.

6. The interface contract optimization and adjustment device as described in claim 5, characterized in that, The utility class is used to scan the initialized Spring bean, including scanning REST interfaces with requestMapping, getMapping, and postMapping annotations and RPC interfaces with ESA annotations. At the same time, the input parameters and interface types are parsed out and saved to the interface model.

7. The interface contract optimization and adjustment device as described in claim 5, characterized in that, The judgment module is specifically used for: Compare whether the interface data in the arena interface list matches the interface model data, wherein the interface data includes a Uniform Resource Locator, interface name, output parameters, input parameters, and parameter types; If at least one of the Uniform Resource Locator, Interface Name, Output Parameter, Input Parameter, or Parameter Type does not match the Interface Model Data, then the interface data in the arena interface list is determined to be inconsistent with the interface model data. If the Uniform Resource Locator, Interface Name, Output Parameters, Input Parameters, and Parameter Type all match the Interface Model Data, then the interface data in the arena interface list is determined to match the Interface Model Data.

8. The interface contract optimization and adjustment device as described in claim 5, characterized in that, The Swagger annotations include the API annotation, APIOperation annotation, APIImplicitParams annotation, APIImplicitParam annotation, APIResponses annotation, and APIResponse annotation. Among them, the APIImplicitParam annotation includes the paramType indicating the location of the parameter, the parameter name, the parameter type dataType, the required indicating whether the parameter is required, the parameter comment value, and the parameter default value.

9. A terminal, characterized in that, The terminal includes: a processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Method and system for quickly and automatically testing based on swagger

    CN111930635A

  • Interface document generation method and system based on big data

    CN114327615A