Interface code automatic synchronization method and device and storage medium

By defining API attributes in the interface description file to generate interface code and automatically synchronizing it, the problems of tedious and inconsistent interface synchronization are solved, improving development efficiency and software stability.

CN111367547BActive Publication Date: 2026-01-30SAI ANDY TECHNOLOGY (HONG KONG) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010122958.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-02-27
Publication Date
2026-01-30
Estimated Expiration
2040-02-27

AI Technical Summary

Technical Problem

Existing technologies often employ cumbersome and error-prone methods for interface synchronization, resulting in low development efficiency, high maintenance costs, and a lack of interface version synchronization mechanisms, which can easily lead to online incidents.

Method used

By defining API attributes in the interface description file, interface code for each end is generated and constitutes a code file. The code feature set is extracted to generate a code fingerprint. The fingerprint is compared with the description file for consistency, and inconsistent code is automatically updated.

Benefits of technology

It improves the development efficiency of multi-platform collaboration, avoids the problem of code not being updated in a timely manner due to human error, and enhances the stability of the software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111367547B_ABST
    Figure CN111367547B_ABST
Patent Text Reader

Abstract

This invention relates to the field of development assistance, and proposes a method, apparatus, and computer-readable storage medium for automatic synchronization of interface code. The method includes: defining API attributes in an interface description file; the API attributes include: interface name, request parameters, and return value; generating interface code for each end based on the API attributes in the interface description file, and the interface code for each end uniformly constitutes a code file; extracting code features from the code file to form a code feature set, and generating a code fingerprint based on the interface description file and the code feature set; the code features are extracted using AC (AutoHotkey); comparing the code fingerprint with the API attributes in the description file to determine whether the code has been changed; if the code has been changed, automatically generating new code based on the interface description file and storing the new code on a code server.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the development assistance field, and in particular to an interface code automatic synchronization method and device and a computer readable storage medium. BACKGROUND

[0002] In the case of multiple inheritance between the object of things in the objective world which is not supported by the class in object-oriented program development, the concept of interface is proposed by the program developer in order to overcome the shortcomings of single inheritance and solve the problem of multiple inheritance. In the software development process, the problems such as adding interface parameters, modifying interface return values and modifying interface version numbers will inevitably occur, and therefore all the clients calling the interface need to be modified again to achieve interface compatibility. The biggest problem of this interface synchronization method is that the steps are complicated and prone to errors.

[0003] At present, although there is a way of automatically generating interface code through interface description files, it generally stays in the code generation stage, and the front-end and back-end collaboration is carried out around the defined interface. The existing interaction method has many deficiencies: a lot of time is spent on interface debugging, and the front-end and back-end codes need to be modified and debugged again due to a small adjustment of the interface, such as modifying the interface parameters, which consumes too much unnecessary manpower; the development efficiency is low, the interface maintenance cost is high, and a lot of time is spent on synchronization and communication if the information cannot be synchronized in time, and online accidents may occur due to the inconsistency of the interface versions; there is no interface specification constraint, the interface codes of different ends are inconsistent, and almost every project has its own specification, which increases the learning cost when changing from one project to another; the problem that the interface code of the synchronization end may be modified is not solved, and only manual active synchronization and modification can keep it consistent.

[0004] Therefore, an interface code automatic synchronization method is urgently needed to improve the efficiency of multi-end cooperation in the software development process, avoid the problem that the code is not updated to the latest version in time due to human negligence, and thus improve the stability of the software. SUMMARY

[0005] This invention provides an automatic interface code synchronization method, electronic device, and computer-readable storage medium. Its main objective is to define API attributes in an interface description file, generate interface code for each endpoint using the interface description file, and then unify the interface code of each endpoint into a code file. Code features are then extracted from the code file to form a code feature set. A code fingerprint is generated based on the interface description file and the code feature set. The code features are obtained using an Access Control (AC) mechanism. The code fingerprint is then compared with the interface description file. If they do not match, new code is automatically generated based on the interface description file and stored on a code server. When each endpoint recompiles its code, it directly retrieves the new code from the code server. This improves the efficiency of multi-end collaboration during software development, avoids the problem of code not being updated to the latest version due to human error, and thus improves software stability.

[0006] To achieve the above objectives, the method provided by this invention is applied to electronic devices, and the automatic interface code synchronization method includes:

[0007] Define API attributes in the interface description file; the API attributes include: interface name, request parameters, and return value;

[0008] The interface code for each end is generated based on the API attributes in the interface description file, and then the interface code for each end is unified into a code file.

[0009] Code features are extracted from the code file to form a code feature set, and a code fingerprint is generated based on the code feature set.

[0010] The code fingerprint is compared with the API attributes in the interface description file to determine whether the code has been changed. If the code has been changed, new code is automatically generated based on the interface description file and the new code is saved to the code server.

[0011] Preferably, the interface description file is a JSON or XML file defined based on Open API syntax rules, and the interface description file defines the basic information of all interfaces in accordance with Open API rules; the basic information includes at least API attributes.

[0012] Preferably, the process of generating interface code for each terminal based on the interface description file includes:

[0013] Select the template file for generating code for each platform;

[0014] The API properties of the interface are obtained by parsing the interface description file, and the interface code is generated by combining the template file.

[0015] Preferably, the template file is a Java, Objective-C, or JavaScript template file, and the template file is a mustache format file.

[0016] Preferably, the process of obtaining the API attributes of the interface by parsing the interface description file and generating the interface code by combining the template file is as follows:

[0017] Save the API attributes of the interface in the interface description file as a set of interface variable values, and replace the variables in the code of the template file with the interface variable values ​​in the interface description file to obtain the target code;

[0018] The unique identifier of the interface description file is determined based on the MD5 value or SHA algorithm, and then inserted into the target code of each endpoint. The unique identifier is the MD5 value or SHA algorithm corresponding to the interface description file.

[0019] Preferably, the process of extracting code features from the code file to form a code feature set, and generating a code fingerprint based on the interface description file and the code feature set is as follows:

[0020] Code preprocessing is performed to retain key interface information and remove irrelevant code; the key interface information includes at least: interface class name, function name, parameters, and return value;

[0021] Extract interface code features from the key information of the interface to generate a code feature set;

[0022] Code fingerprints are generated based on the code feature set using specific algorithms; the specific algorithms are: MD5, SHA1, and Karp-Rabin fingerprint algorithms; the code fingerprints are stored in the form of strings.

[0023] Preferably, the method for determining whether the code has been modified by comparing the code fingerprint with the interface description file includes:

[0024] By comparing the code fingerprint with the local code of the interface, it can be determined whether the code has been modified;

[0025] By comparing the unique identifier of the interface description file in the code fingerprint with the identifier of the interface description file that generated the code, it can be determined whether the interface description file has been modified.

[0026] Preferably, the process of comparing the code fingerprint with the API attributes in the interface description file to determine whether the code has been changed is completed by a triggering mechanism for interface version consistency verification.

[0027] To achieve the above objectives, the present invention also provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the aforementioned automatic interface code synchronization method.

[0028] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing an interface code automatic synchronization program, which, when executed by a processor, implements the steps of the aforementioned interface code automatic synchronization method.

[0029] The present invention proposes an automatic interface code synchronization method, electronic device, and computer-readable storage medium. Starting with closed-loop processing, it defines API attributes in the interface description file, then generates interface code for each end based on these API attributes. The interface code from each end is unified into a code file, and code features are extracted from this code file to form a code feature set. A code fingerprint is generated based on the interface description file and this code feature set. This code feature is obtained using an Access Control (AC) mechanism. The code fingerprint is then compared with the interface description file. If they do not match, new code is automatically generated based on the interface description file and stored on a code server. When each end recompiles its code, it directly retrieves the new code from the code server. This improves the efficiency of multi-end collaboration during software development, avoids the problem of code not being updated to the latest version due to human error, and greatly enhances software stability. Attached Figure Description

[0030] Figure 1 This is a flowchart of an interface code automatic synchronization method according to an embodiment of the present invention;

[0031] Figure 2 This is a system framework diagram of the interface code automatic synchronization method according to an embodiment of the present invention;

[0032] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention.

[0033] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0034] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.

[0035] In software development, it's inevitable to encounter issues such as adding interface parameters, modifying interface return values, and changing interface version numbers. All clients calling this interface need to be modified to achieve interface compatibility. The biggest problem with this interface synchronization method is its cumbersome steps and susceptibility to errors. To solve these problems, this invention adopts a closed-loop approach. It defines API attributes in the interface description file and then generates interface code for each client based on this file. The interface code from each client forms a unified code file, from which code features are extracted to form a code feature set. A code fingerprint is generated based on the interface description file and this code feature set. This code feature is obtained through Acquisition and Computation (AC). The code fingerprint is then compared with the interface description file. If they don't match, new code is automatically generated based on the interface description file and stored on a code server. When each client recompiles its code, it directly retrieves the new code from the code server. This improves the efficiency of multi-client collaboration during software development, avoids the problem of code not being updated to the latest version due to human error, and thus improves software stability.

[0036] Specifically, the present invention provides an automatic interface code synchronization method, which is applied to an electronic device 30.

[0037] Figure 1 This is a flowchart of an interface code automatic synchronization method according to an embodiment of the present invention. Figure 1 As shown, in this embodiment, the automatic synchronization method for interface code includes the following steps:

[0038] S110: Prepare the interface description file, which defines the API (Application Programming Interface) properties. These API properties include: interface name, request parameters, and return value.

[0039] Interface description files are generally JSON or YAML files defined based on OpenAPI syntax rules. These files define the basic information of all interfaces, such as their names, parameters, and return values, according to OpenAPI rules. They can be written manually or exported directly through an interface management platform (e.g., YAPI platform).

[0040] S120: Generate interface code for each end based on the API attributes in the interface description file, and then combine the interface code of each end into a code file.

[0041] The process of generating interface code for each end through this interface description file, forming a code file, includes:

[0042] Choose the template file to generate code for each platform; generally, it is a template file for Java, Objective-C, JavaScript, etc. The template file is a file with a fixed format (such as mustache).

[0043] The API properties of the interface are obtained by parsing the interface description file, and the interface code is generated by combining the template file.

[0044] Specifically: ① Save the interface information defined in the interface description file, such as the interface name, method name, parameters, and return value, as a set of interface variable values; ② Replace the variables in the code template with the interface variable values ​​obtained in step 1 to obtain the actual code.

[0045] The front-end, back-end, and client generate code based on a unified interface description file and different code templates, and insert a unique identifier from the interface description file into the code of each end.

[0046] This unique identifier can be the MD5 value or SHA algorithm corresponding to the interface description file.

[0047] S130: Extract code features from the code file to form a code feature set, and generate a code fingerprint based on the code feature set;

[0048] The process of extracting code features from the code file to form a code feature set, and generating a code fingerprint based on the interface description file and the code feature set, includes:

[0049] S131: Code preprocessing, retaining key interface information such as interface class, function name, parameters, and return value, and removing irrelevant code;

[0050] S132: Extract interface code features to generate a code feature set; these interface features generally include: interface class name, method name, parameters, and return value;

[0051] S133: Generate code fingerprints using a specific algorithm based on a set of code features; the specific algorithm is generally MD5, SHA1, or Karp-Rabin fingerprint algorithm; the code fingerprint is stored in the form of a string.

[0052] The code fingerprint includes: ① A unique identifier for the interface description file (e.g., the file's MD5 value), used to ensure that the code is consistent with the interface description file that generated it. ② A set of characteristics for each end's code, such as the interface name, interface parameters, and return values, to ensure that the code interface functionality has not been modified.

[0053] Generally, the code fingerprint corresponding to the interface file is stored in key-value format, with the unique identifier of the interface description file as the key and the code fingerprint as the value.

[0054] S140: Compare the code fingerprint with the API attributes in the interface description file to determine if the code has been changed. If the code has been changed, new code is automatically generated based on the interface description file and stored on the code server. When each end recompiles the code, the new code is directly retrieved from the code server.

[0055] The process of comparing fingerprints in the code with changes in the interface description file and automatically updating inconsistent interface code includes:

[0056] The code fingerprint is generated based on the interface code. If each client modifies the interface code locally after the code is generated, the code fingerprint will be inconsistent with the one initially generated. Therefore, it is necessary to compare whether the fingerprint in the code is consistent with the interface description file.

[0057] The above comparison can be divided into two methods: one is to compare the local code for modifications using code fingerprints, and the other is to compare the interface description file generated by the generated code for modifications using the unique identifier of the interface description file in the fingerprint. Through comparison, the code can be automatically updated in a timely manner, avoiding the problem of the code not being updated to the latest version due to human negligence, thereby improving the stability of the software.

[0058] Automatically update changed interface code: When fingerprint comparison fails, automatically generate code using the latest interface description file.

[0059] The process of automatically updating inconsistent interface code includes: detecting that the interface code has been modified (inconsistent code fingerprints are detected), automatically generating code based on the latest interface description file, saving it on the code server, and pulling the latest version of the code from the server the next time the code is compiled on each end.

[0060] Through automatic code generation and code fingerprinting technology, the interfaces of various terminals can be synchronized and automated, including:

[0061] A mechanism for verifying interface version consistency is inserted into the code compilation process on each end. This mechanism is based on a unified interface description file, compares the code fingerprints on each end, and triggers an automatic script generation in the interface code repository after code changes are detected. The interface code is then generated and pushed to each end of the server to complete the code compilation.

[0062] This invention adopts a closed-loop approach. It defines API attributes in the interface description file, then generates interface code for each platform using the interface description file. The interface code from each platform is unified into a code file, and code features are extracted from this code file to form a code feature set. A code fingerprint is generated based on the interface description file and the code feature set. The code fingerprint is then compared with the interface description file. If they do not match, new code is automatically generated based on the interface description file and stored on a code server. When each platform recompiles its code, it directly retrieves the new code from the code server. This improves the efficiency of multi-platform collaboration during software development, avoids the problem of code not being updated to the latest version due to human error, and thus improves software stability.

[0063] Figure 2 This is a framework diagram of an interface code automatic synchronization system 200 according to an embodiment of the present invention. This system corresponds to an interface code automatic synchronization method and is housed in an interface code automatic synchronization electronic device 30. The system 200 includes a definition module 210, a code generation module 220, a fingerprint generation module 230, a comparison and detection module 240, and an automatic update module 250.

[0064] The definition module 210 is used to define the API attributes in the interface description file. The interface description file defines software API attributes such as interface name, request parameters, and return value. The interface description file is a JSON or XML file defined based on Open API syntax rules. It defines the API attributes of all interfaces according to Open API rules, and the interface information includes at least: name, parameters, and return value. The interface description file can be written manually or exported directly from the interface management platform, which is the YAPI platform.

[0065] The code generation module 220 is used to generate interface code for each end from the interface description file to form a code file;

[0066] The fingerprint generation module 230 is used to extract code features from the code file to form a code feature set, and generate a code fingerprint based on the interface description file and the code feature set. The process of generating interface code for each terminal through the interface description file, and unifying the interface code of each terminal into a code file, includes:

[0067] Prepare the interface description file; select and generate code template files for each client; generate code by parsing the interface description file and combining it with the code templates for each client.

[0068] The comparison and detection module 240 is used to compare the local code for modifications using code fingerprints, and to compare the interface description file of the generated code for modifications using the unique identifier of the interface description file in the fingerprint.

[0069] The automatic update module 250 is used to automatically generate code based on the latest interface description file when it is found that the interface code has been modified (inconsistent code fingerprint is detected), and save it on the code server. Each terminal will pull the latest version of the code from the server the next time it compiles the code.

[0070] Figure 3 This is a schematic diagram of the logical structure of an electronic device according to an embodiment of the present invention. In this embodiment, the electronic device 30 may be a terminal device with computing functions, such as a server, tablet computer, portable computer, or desktop computer.

[0071] The electronic device 30 includes: a processor 31, a memory 32, a computer program 33, a network interface, and a communication bus.

[0072] The electronic device 30 may be a tablet computer, a desktop computer, or a smartphone, but is not limited to these.

[0073] The memory 32 includes at least one type of readable storage medium. The at least one type of readable storage medium can be a non-volatile storage medium such as flash memory, hard disk, multimedia card, card-type memory, etc. In some embodiments, the readable storage medium can be an internal storage unit of the electronic device 30, such as the hard disk of the electronic device 30. In other embodiments, the readable storage medium can also be external storage of the electronic device 30, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device 30.

[0074] In this embodiment, the readable storage medium of the memory 32 is typically used to store computer programs 33, etc., installed on the electronic device 30.

[0075] In some embodiments, processor 31 may be a central processing unit (CPU), microprocessor or other data processing chip, used to run program code stored in memory 32 or process data, such as interface code automatic synchronization program 33, etc.

[0076] The network interface may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface), which is typically used to establish communication connections between the electronic device 30 and other electronic devices.

[0077] The communication bus is used to enable communication between these components.

[0078] Figure 3Only the electronic device 30 with components 31-33 is shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0079] exist Figure 3 In the illustrated electronic device embodiment, the memory 32, which serves as a computer storage medium, may include an operating system and an interface code automatic synchronization program 33; when the processor 31 executes the interface code automatic synchronization program 33 stored in the memory 32, it performs the following steps:

[0080] S110: Define API attributes in the interface description file; API attributes include: interface name, request parameters, and return value;

[0081] S120: Generate interface code for each end based on the API attributes in the interface description file, and then combine the interface code of each end into a code file.

[0082] S130: Extract code features from code files to form a code feature set, and generate a code fingerprint based on the interface description file and the code feature set; code features are extracted using AC.

[0083] S140: Compare the code fingerprint with the API attributes in the interface description file to determine if the code has been changed. If the code has been changed, new code will be automatically generated based on the interface description file and stored on the code server. When each end recompiles the code, the new code will be retrieved directly from the code server.

[0084] The interface description file is a JSON or XML file defined based on the Open API syntax rules. It defines the API attributes of all interfaces according to the Open API rules. The interface information includes at least: name, parameters, and return value. The interface description file can be written manually or exported directly through the interface management platform. The interface management platform is the YAPI platform.

[0085] The process of generating interface code for each client from interface description files, and then unifying the interface code for each client into a single code file, includes:

[0086] Prepare the interface description file;

[0087] Choose to generate code template files for each platform;

[0088] Code is generated by parsing the interface description file and combining it with code templates from various platforms.

[0089] The template files are Java, Objective-C, and JavaScript template files. The template file is a fixed-format file, specifically the Mustache format.

[0090] The process of generating code by parsing the interface description file and combining it with the code templates of each platform is as follows:

[0091] Save the interface information defined in the interface description file as a set of interface variable values, and replace the variables in the template code with the interface variable values ​​in the interface description file to obtain the target code;

[0092] Target code is generated based on the interface description file and different code templates, and a unique identifier of the description file is inserted into the target code of each end. This unique identifier is generated based on the MD5 value or SHA algorithm corresponding to the interface description file.

[0093] The process of extracting code features from code files to form a code feature set, and generating a code fingerprint based on the interface description file and the code feature set is as follows:

[0094] Perform code preprocessing, retain key interface information, and remove irrelevant code; key interface information includes at least: interface class name, function name, parameters, and return value;

[0095] Extract interface code features from key interface information to generate a code feature set;

[0096] Code fingerprints are generated based on a set of code features using specific algorithms; the specific algorithms are: MD5, SHA1, and Karp-Rabin fingerprinting algorithms; the code fingerprints are stored in string format.

[0097] The mapping between interface files and code fingerprints is stored in key-value pairs, with the unique identifier of the interface description file serving as the key and the code fingerprint as the value.

[0098] The process of comparing the code fingerprint with the interface description file includes:

[0099] Methods for comparing code fingerprints with interface description files include: comparing the code fingerprint with local code to determine if the code has been modified; and comparing the unique identifier of the interface description file in the code fingerprint with the identifier of the interface description file used to generate the code to determine if the interface description file has been modified.

[0100] The process of automatically generating new code based on the latest interface description file involves automating the synchronization of interfaces across different platforms through automatic code generation and code fingerprinting technology, including:

[0101] A mechanism for verifying interface version consistency is inserted into the code compilation process on each end. Based on the interface description file, the code fingerprints of each end are compared. If they are inconsistent, the script for automatically generating code in the interface code repository is triggered. After the interface code is generated, the new code is pushed to each end to complete the code compilation.

[0102] Furthermore, embodiments of the present invention also propose a computer-readable storage medium, which includes an interface code automatic synchronization program. When the interface code automatic synchronization program is executed by a processor, it implements the steps of an interface code automatic synchronization method:

[0103] S110: Define API attributes in the interface description file; API attributes include: interface name, request parameters, and return value;

[0104] S120: Generate interface code for each end based on the API attributes in the interface description file, and then combine the interface code of each end into a code file.

[0105] S130: Extract code features from the code file to form a code feature set, and generate a code fingerprint based on the code feature set; the code features are extracted using AC.

[0106] S140: Compare the code fingerprint with the API attributes in the interface description file to determine if the code has been changed. If the code has been changed, new code will be automatically generated based on the interface description file and stored on the code server. When each end recompiles the code, the new code will be retrieved directly from the code server.

[0107] The specific implementation of the computer-readable storage medium of the present invention is largely the same as the interface code automatic synchronization method and the specific implementation of the electronic device, and will not be described again here.

[0108] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0109] The sequence numbers of the above embodiments of the present invention are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases, the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0110] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for automatically synchronizing interface codes, applied to an electronic device, comprising the steps of: The method comprises: defining API attributes in an interface description file; the API attributes comprise: interface name, request parameter and return value; generating interface codes of each end according to the API attributes in the interface description file, and then uniformly constituting the interface codes into a code file; wherein, it comprises: selecting a template file for generating the codes of each end; parsing the interface description file to obtain the API attributes of the interface, and generating the interface codes in combination with the template file; extracting code features in the code file to constitute a code feature set, and generating a code fingerprint according to the code feature set; wherein, it comprises: performing code preprocessing to retain interface key information and eliminate irrelevant codes; the interface key information at least comprises: interface class name, function name, parameter and return value; extracting interface code features in the interface key information to generate the code feature set; generating the code fingerprint by using a specific algorithm according to the code feature set; the specific algorithm is: SHA1 and Karp-Rabin fingerprint algorithm; the code fingerprint is saved in the form of a string; comparing the code fingerprint with the API attributes in the interface description file to determine whether the code is changed, and if the code is changed, automatically generating new code according to the interface description file and saving the new code to a code server.

2. The method of claim 1, wherein, The interface description file is a json or xml format file defined based on Open API syntax rules, and the interface description file defines basic information of all interfaces according to Open API rules; the basic information at least comprises the API attributes.

3. The method of automatic interface code synchronization of claim 2, wherein, The template file is a Java, OC or JavaScript template file, and the template file is a mustache format file.

4. The method of automatic interface code synchronization of claim 3, wherein, The process of obtaining the API attributes of the interface by parsing the interface description file and generating the interface codes in combination with the template file comprises: saving the API attributes of the interface in the interface description file as an interface variable value set, and replacing variable codes in the template file with the interface variable values in the interface description file to obtain target codes; determining a unique identifier of the interface description file according to MD5 value or SHA algorithm, and inserting the unique identifier into the target codes of each end.

5. The method of claim 1, wherein, The method of comparing the code fingerprint with the interface description file to determine whether the code is changed comprises: determining whether the code is modified by comparing the code fingerprint with local codes of the interface; determining whether the interface description file is modified by comparing the unique identifier of the interface description file in the code fingerprint with an identifier of the interface description file for generating codes.

6. The method of claim 1, wherein, The process of comparing the code fingerprint with the API attributes in the interface description file to determine whether the code is changed is completed by a triggering mechanism for performing interface version consistency verification.

7. An electronic device, comprising: The electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps in the interface code automatic synchronization method in any one of claims 1 to 6 when executing the computer program.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores an interface code automatic synchronization method program. When the interface code automatic synchronization method program is executed by the processor, the steps of the interface code automatic synchronization method in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Interface code generation method and terminal device

    CN108268253A

  • Method and device for generating protocol interface code version update notification

    CN110175043A