Interface document updating method, device, electronic device and storage medium

The interface document is detected and automatically updated through the module's timestamp, version number and code line information, which solves the problem of inconsistency between module update speed and interface document update speed, and achieves real-time update of interface documents and accuracy and efficiency of functional verification.

CN110321142BActive Publication Date: 2024-10-15PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910495582.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-05
Publication Date
2024-10-15
Estimated Expiration
2039-06-05

AI Technical Summary

Technical Problem

In the existing technology, the update speed of software system modules is inconsistent with the update speed of interface documents, resulting in low accuracy of test cases and inability to effectively verify module functions.

Method used

Detect module updates in the code database through the module's timestamp, version number and code line information, automatically determine the target module, extract interface information from its updated code, perform format processing and update interface documents.

Benefits of technology

It realizes real-time updating of interface documents, improves the accuracy and efficiency of module function verification, simplifies operations, and reduces the complexity and cost of updating interface documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110321142B_ABST
    Figure CN110321142B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an interface document updating method, device, electronic device and storage medium, wherein the method comprises: determining a target module whose code is updated from at least one module in a code database according to a preset rule, obtaining the updated code in the target module and the interface document of the target module, extracting interface information from the code annotation information corresponding to the updated code, formatting the extracted interface information to obtain the processed interface information, updating the interface document of the target module according to the processed interface information to obtain the updated interface document. The interface document of the module can be updated in real time so that the function of the module can be more accurately verified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an interface document updating method, device, electronic equipment and storage medium. Background Art

[0002] With the continuous development of computer technology, the complexity of software systems is getting higher and higher, and the amount of code is getting larger and larger. Commonly used software systems often require hundreds of thousands or even millions of lines of code. Therefore, when a module of a software system is developed, or when a module is updated, it is usually necessary to use the interface document of the module to generate test cases, and use the test cases to verify whether the functions of the module meet the requirements. In practice, it is found that there is a problem that the update speed of the module is inconsistent with the update speed of the interface document of the module, resulting in the low accuracy of the test cases generated according to the interface document, and the function of the module cannot be verified accurately. Summary of the invention

[0003] The embodiment of the present invention provides an interface document updating method, device, electronic device and storage medium, which can update the interface document of a module in real time so as to more accurately verify the function of the module.

[0004] In a first aspect, an embodiment of the present invention provides an interface document updating method, the method comprising:

[0005] Determine a target module whose code is to be updated from at least one module in the code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module;

[0006] Acquire the updated code in the target module and the interface document of the target module, wherein the updated code is at least one of the deleted code, the newly added code and the replaced code in the target module;

[0007] Extracting interface information from code annotation information corresponding to the updated code, performing format processing on the extracted interface information to obtain processed interface information, wherein the code annotation information is used to explain the updated code;

[0008] The interface document of the target module is updated according to the processed interface information to obtain an updated interface document.

[0009] In a second aspect, an embodiment of the present invention provides an interface document updating device, the device comprising:

[0010] A determination module, used to determine a target module whose code is to be updated from at least one module in the code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module;

[0011] An acquisition module, used to acquire the updated code in the target module and the interface document of the target module, wherein the updated code is at least one of the deleted code, the newly added code and the replaced code in the target module;

[0012] An extraction module, used for extracting interface information from code annotation information corresponding to the updated code;

[0013] A processing module, used for formatting the extracted interface information to obtain the processed interface information, wherein the code annotation information is used for explaining the updated code;

[0014] An updating module is used to update the interface document of the target module according to the processed interface information to obtain an updated interface document.

[0015] In a third aspect, an embodiment of the present invention provides an electronic device, including:

[0016] a processor adapted to implement one or more instructions; and,

[0017] A computer-readable storage medium storing one or more instructions, wherein the one or more instructions are suitable for being loaded and executed by the processor as follows:

[0018] A determination module, used to determine a target module whose code is to be updated from at least one module in the code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module;

[0019] An acquisition module, used to acquire the updated code in the target module and the interface document of the target module, wherein the updated code is at least one of the deleted code, the newly added code and the replaced code in the target module;

[0020] An extraction module, used for extracting interface information from code annotation information corresponding to the updated code;

[0021] A processing module, used for formatting the extracted interface information to obtain the processed interface information, wherein the code annotation information is used for explaining the updated code;

[0022] An updating module is used to update the interface document of the target module according to the processed interface information to obtain an updated interface document.

[0023] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more instructions, wherein the one or more instructions are suitable for being loaded by a processor and executing the following steps:

[0024] A determination module, used to determine a target module whose code is to be updated from at least one module in the code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module;

[0025] An acquisition module, used to acquire the updated code in the target module and the interface document of the target module, wherein the updated code is at least one of the deleted code, the newly added code and the replaced code in the target module;

[0026] An extraction module, used for extracting interface information from code annotation information corresponding to the updated code;

[0027] A processing module, used for formatting the extracted interface information to obtain the processed interface information, wherein the code annotation information is used for explaining the updated code;

[0028] An updating module is used to update the interface document of the target module according to the processed interface information to obtain an updated interface document.

[0029] In the embodiment of the present invention, the electronic device detects whether the module in the code database is updated through the timestamp, version number and code line number of the module. When a module is updated, the updated module is determined as the target module, so that the updated module can be automatically obtained. The interface document of the target module is updated in real time according to the interface information corresponding to the updated code in the target module, so that the function of the module can be verified more accurately, the operation is simple and convenient, and the efficiency of updating the interface document is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0031] Figure 1 It is a flowchart of an interface document updating method provided by an embodiment of the present invention;

[0032] Figure 2 It is a flowchart of another interface document updating method provided by an embodiment of the present invention;

[0033] Figure 3 It is a structural diagram of an interface document updating device provided by an embodiment of the present invention;

[0034] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0036] Based on the prior art, when an application is developed and put into use, it is usually necessary to continuously update one or more modules in the application to make the application have better performance, higher security, etc. When the module of the application is updated, the interface document of the module also needs to be updated synchronously, so that it is possible to accurately verify whether the function of the updated module meets the requirements based on the interface document. At present, R&D engineers are required to manually update the interface document of the module. There are cases where the R&D engineers resign or forget to update the interface document, resulting in the module update speed being inconsistent with the update speed of the interface document of the module, and it is impossible to accurately verify whether the function of the module meets the requirements. In addition, this interface document update method is relatively complicated, time-consuming, and labor-intensive.

[0037] Based on the problems existing in the current interface document update method, an interface document update method is proposed in an embodiment of the present invention. The method can be executed by an electronic device, which can refer to a device that can be used for storage, such as an intelligent terminal, a server or a computer. The specific implementation process of the method includes: the electronic device detects whether the module in the code database is updated through the timestamp, version number and number of code lines of the module. When a module is updated, the updated module is determined as the target module, and the updated code in the target module is obtained. The interface information is extracted from the code annotation information corresponding to the updated code, and the interface document of the target module is updated according to the extracted interface information. In this way, the updated module can be automatically obtained, and the interface document of the module can be updated in real time, so that the function of the module can be more accurately verified. The operation is simple and convenient, and the efficiency of updating the interface document is improved.

[0038] See also Figure 1, is a flow chart of an interface document updating method provided by an embodiment of the present invention, and the method of the embodiment of the present invention can be executed by the electronic device mentioned above. In this embodiment, the interface document updating method includes the following steps.

[0039] S101. Determine a target module whose code is to be updated from at least one module in a code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module.

[0040] A module refers to a part of an application. Specifically, a module can be obtained according to the functional division of the application. For example, if the application is an instant messaging program, the module can be a user account information management module, an information receiving and sending processing module, an interface display module, and the like. A code database refers to a database used to store applications. The code database may include one or more modules. In order to synchronously update the interface documents of the modules, the electronic device may detect whether the modules in the code database are updated according to preset rules. If an updated module is detected, the updated module is determined to be the target module. In this way, the updated module can be automatically detected, and the efficiency is high. There is no need to compare the historical code in each module in the code database with the current code. Here, the updated module refers to the module whose code in the module is updated.

[0041] In one embodiment, in order to reduce resource consumption of an electronic device, the electronic device can detect whether there is a module with updated code in the code database according to a preset rule based on a preset time interval, and determine the module with updated code as a target module. The preset time interval can be determined according to the speed at which each module history is updated in the code database, and the speed at which the module history is updated refers to the average update speed or the maximum update speed within a preset time period, etc. For example, if a module is updated 4 times within a week, and the time intervals between each two adjacent updates are 1 day, 1 day, and 2 days respectively, then the speed at which the module is updated includes once every 1 day and once every 2 days. The electronic device can set the preset time interval to 1 day (i.e., 24 hours), and the electronic device can use the preset rule to detect whether there is a module with updated code in the code database every 24 hours.

[0042] In another embodiment, in order to reduce resource consumption of the electronic device, the electronic device may detect whether the code of the module is updated when testing the module. Specifically, if a test instruction for a module is received, whether the code of the module is updated is detected according to a preset rule, and if the code of the module is updated, the module is determined as a target module.

[0043] In yet another embodiment, the electronic device may detect in real time according to a preset rule whether there is a module with updated code in at least one module in the code database, and if so, determine the module with updated code as the target module.

[0044] S102: Obtain updated code in the target module and an interface document of the target module, wherein the updated code is at least one of deleted code, newly added code and replaced code in the target module.

[0045] After determining that the target module is updated, the electronic device can obtain the updated code in the target module, wherein the updated code is a line of code or multiple lines of code (i.e., a code segment). Specifically, the electronic device can obtain the updated code of the target module based on the system log information of the device that developed the target module. The system log refers to recording events that occurred in the system, which may specifically include the time when the event occurred and the operation process, etc. Alternatively, the electronic device can obtain the updated code of the target module based on the historical code of the target module. The historical code is the code when the target module was last updated. Further, the electronic device can obtain the interface document of the target module. The interface document of the target module is a document used to record the interface information of the target module. The interface information may include one or more of the interface name, interface uniform resource locator, interface description, input parameters, output parameters, return data, and the domain name and port of the interface test server.

[0046] In one embodiment, the electronic device can obtain the system log data of the device that developed the target module, and extract the log data about the target module from the system log data according to the identification of the target module. The identification of the target module can refer to the name of the target module and / or the address information storing the target module, etc.; the log data of the target module records the operation events of the target module, and the updated code in the target module is obtained from the log data of the target module. Among them, the device that developed the target module and the electronic device can refer to the same device or different devices.

[0047] In one embodiment, in order to facilitate the subsequent viewing of the development process of the target module, the electronic device usually records the historical code of the target module. Here, if the target module has been updated, the historical code refers to the code of the target module after the most recent update; if the target module has not been updated, the historical code refers to the code when the target module is developed (i.e., the original code). The electronic device can obtain the historical code of the target module and compare the historical code with the current code in the target module to obtain the updated code.

[0048] S103: extracting interface information from the code annotation information corresponding to the updated code, performing format processing on the extracted interface information to obtain processed interface information, wherein the code annotation information is used to explain the updated code.

[0049] In order to synchronously update the interface document of the target module, the electronic device can extract the interface information from the code annotation information corresponding to the updated code. Specifically, the electronic device can extract the annotation information carrying the preset identifier from the code annotation information corresponding to the updated code, and generate the interface information according to the annotation information of the preset identifier. The preset identifier can include the target function identifier, the input parameter identifier and the output identifier. In order to facilitate the subsequent writing, modification and development of the interface document or to quickly generate the test, the electronic device can format the extracted interface information according to the preset format to obtain the processed interface information. The above preset format can be set according to actual needs. For example, the preset format can be set according to the code type of the target module, and the preset format can be the format of the interface information in the interface document in the target module.

[0050] In one embodiment, in order to facilitate the user to understand the code in the module, developers usually add corresponding code annotation information to the code segment during the code writing process, and use preset identifiers in these code annotation information to respectively identify the summary information and parameter information of the code. Among them, the summary information includes an explanation of the interface name, interface uniform resource locator, interface description, return data, domain name and port of the interface test server. The parameter information includes an explanation of the input parameters and output parameters. Therefore, the electronic device can extract the annotation information carrying the preset identifier from the code annotation information corresponding to the updated code, and generate interface information according to the annotation information of the preset identifier. For example, the input parameter identifier can be @PAFInput, and the output parameter identifier can be @PAFOutput. The annotation information carrying @PAFInput and the annotation information carrying @PAFOutput are extracted from the code annotation information corresponding to the updated code. If the annotation information carrying @PAFInput is @PAFInput(desc=""), that is, the information in double quotes in @PAFInput(desc="") is the input parameter. The annotation information carrying @PAFOutput is @PAFOutput(desc=""), that is, the information in double quotes in @PAFOutput(desc="") is the output parameter.

[0051] S104. Update the interface document of the target module according to the processed interface information to obtain an updated interface document.

[0052] The electronic device can update the interface document of the target module according to the processed interface information to obtain an updated interface document.

[0053] In one embodiment, if the updated code is the code deleted in the target module, the interface information matching the processed interface information is deleted from the interface document of the target module; if the updated code is the code newly added in the target module, the processed interface information is added to the interface document of the target module; if the updated code is the code replaced in the target module, the interface information corresponding to the code before the replacement is removed from the interface document of the target module, and the processed interface information is added to the interface document of the target module.

[0054] If the updated code is the deleted code in the target module, the deleted code will not affect the function of the target module, which means that the interface information corresponding to the deleted code is invalid interface information and cannot be used to test the function of the target module. Therefore, the interface information matching the processed interface information is deleted from the interface document of the target module. For example, the interface document records the source of the interface information in the target module, that is, the code comment information of which line of code each interface information is obtained from. If the deleted code is the 112th to 150th lines of the original code in the target module, the interface information in the comment information of the 112th to 150th lines of the original code of the target module is deleted from the interface document of the target module.

[0055] If the updated code is a newly added code in the target module, it indicates that the newly added code will affect the function of the target module, that is, the interface information corresponding to the newly added code is useful interface information, so the processed interface information can be added to the interface document of the target module. For example, if the interface information corresponding to the newly added code is an input parameter and an output parameter, the electronic device can add the interface information corresponding to the newly added code to the location where the parameters are stored in the interface document of the target module.

[0056] If the updated code is the replaced code in the target module (i.e., the replaced code), then the replaced code replaces the function corresponding to the code before the replacement in the target module, that is, it is necessary to verify the current function of the target module based on the interface information of the replaced code. Therefore, the interface information corresponding to the code before the replacement can be removed from the interface document of the target module, and the processed interface information can be added to the interface document of the target module. For example, assuming that the replaced code replaces the 112th-150th lines of code in the target module, the electronic device can use the interface information corresponding to the replaced code to replace the interface information corresponding to the 112th-150th lines of code in the interface document of the target module.

[0057] In an embodiment of the present invention, the electronic device detects whether a module in a code database is updated through information such as the timestamp, version number, and number of lines of code of the module. When a module is updated, the updated module is determined as the target module, so that the updated module can be automatically obtained. The updated code in the target module is obtained, and the interface information is extracted from the code annotation information corresponding to the updated code, and the extracted interface information is formatted to obtain the processed interface information, and the interface document of the target module is updated according to the processed interface information. The interface document of the target module is updated in real time according to the interface information corresponding to the updated code in the target module, so that the function of the module can be verified more accurately, the operation is simple and convenient, and the efficiency of updating the interface document is improved. In addition, by formatting the extracted interface information, it is conducive to the subsequent writing, modification and development of the interface document.

[0058] See also Figure 2 , is a flow chart of another interface document updating method provided by an embodiment of the present invention, and the method of the embodiment of the present invention can be executed by the electronic device mentioned above. In this embodiment, the interface document updating method includes the following steps.

[0059] S201. Determine a target module whose code is to be updated from at least one module in a code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module.

[0060] In one embodiment, the preset rule includes a rule set according to the timestamp of the module, and step S201 may specifically include the following steps s11 to s12.

[0061] s11. Obtain the first timestamp of the last update of each module in the code database and the second timestamp of the last update of each interface document corresponding to the module.

[0062] s12. Determine a module in the code database whose difference between the first timestamp and the second timestamp is greater than a preset threshold as a target module.

[0063] In steps s11 to s12, the electronic device can obtain the first timestamp of the last update of each module in the code database, and the second timestamp of the last update of each interface document corresponding to the module. Specifically, if the module has not been updated, the first timestamp of the last update of the module may refer to the timestamp when the module was developed, and the second timestamp of the last update of the interface document corresponding to the module may refer to the timestamp when the interface document of the module was established. If the module has been updated, the first timestamp of the last update of the module may refer to the timestamp when the module was most recently updated, and the second timestamp of the last update of the interface document corresponding to the module may refer to the timestamp when it was most recently updated. Among them, the timestamp can specifically refer to time, or a character used to identify time, etc., and the timestamps corresponding to the same time are usually the same. Furthermore, if the difference between the first timestamp and the second timestamp of a module in the code database is greater than a preset threshold, it indicates that the update time of the interface document of the module is not synchronized with the update time of the module, and the electronic device can determine the module whose difference between the first timestamp and the second timestamp is greater than the preset threshold as the target module, wherein the preset threshold can be manually set by the user, or determined according to the update speed of the code in the module, for example, the preset threshold can be less than the minimum update speed of the code in the module. Optionally, if the time indicated by the second timestamp corresponding to the module in the code database is earlier than the time indicated by the first timestamp, it is determined that the interface document of the module is not updated after the module is updated, so the module can be used as the target module.

[0064] For example, assuming that the preset threshold is 2 days, the code database includes module 1. If the first timestamp of the code of module 1 that was most recently updated is August 15, 2018, and the second timestamp of the interface document corresponding to module 1 that was most recently updated is August 11, 2018, and the difference between the first timestamp and the second timestamp is 4 days, that is, the difference between the first timestamp and the second timestamp corresponding to module 1 is greater than the preset threshold, then module 1 is determined to be the target module.

[0065] In another embodiment, the preset rule includes a rule set according to a version number of the module, and step S201 may specifically include the following steps s21 to s22.

[0066] s21. Obtain the current version number and historical version number of each module in the code database. The historical version number of each module is the version number of the module when the interface document of the corresponding module was last updated.

[0067] s22. Determine the module in the code database whose current version number is different from the historical version number as the target module.

[0068] In steps s21 to s22, usually after a module is updated, the updated module will be assigned a new version number. Therefore, it is possible to determine whether the module has been updated based on the version number of the module. Specifically, the electronic device can obtain the current version number and historical version number of each module in the code database. If the current version number of a module in the code database is different from the historical version number, it indicates that the module has been updated, and the module whose current version number is different from the historical version number in the code database can be determined as the target module. For example, the code database includes module 1, and the historical version number of module 1 is the version number of module 1 when the interface document corresponding to module 1 was last updated. If the historical version number of module 1 is 1.1.2 and the current version number of the module is 1.1.3, it is determined that the current version number of module 1 is different from the historical version number, and the code of module 1 is determined to be updated, that is, module 1 is used as the target module.

[0069] In yet another embodiment, the preset rule includes a rule set according to the number of code lines of the module, and step S201 may specifically include the following steps s31 to s32.

[0070] s31. Obtain the current number of code lines and the historical number of code lines for each module in the code database. The historical number of code lines for each module is the number of code lines for the corresponding module when the interface document of the corresponding module was last updated.

[0071] s32. Determine the module in the code database whose current number of code lines is different from the historical number of code lines as the target module.

[0072] In steps s31 to s32, when new code is added or deleted in a module, the number of code lines of the module will change. Therefore, the electronic device can determine whether the module is updated based on the number of code lines of the module. Specifically, the electronic device can obtain the current number of code lines and the historical number of code lines of each module in the code database. If the current number of code lines of the module is different from the historical number of code lines, it indicates that new code has been added or deleted in the module. The module whose current number of code lines is different from the historical number of code lines in the code database can be determined as the target module. For example, the code database includes module 1, and the historical number of lines of the module 1 is the number of code lines of the module 1 when the interface document corresponding to the module 1 was last updated. If the historical number of code lines of module 1 is 1,000 lines and the current number of code lines of the module is 2,000 lines, it is determined that the current number of code lines of module 1 is different from the historical number of code lines, and the code of module 1 is determined to be updated, that is, the module 1 is used as the target module.

[0073] S202, obtaining the updated code in the target module and the interface document of the target module, wherein the updated code is at least one of the deleted code, the newly added code and the replaced code in the target module.

[0074] S203: extracting interface information from the code annotation information corresponding to the updated code, performing format processing on the extracted interface information to obtain processed interface information, wherein the code annotation information is used to explain the updated code.

[0075] In one embodiment, step S203 may specifically include the following steps s41 to s43.

[0076] s41. Get the code type in the target module.

[0077] s42. Determine the format of the test case for testing the target module according to the code type in the target module.

[0078] s43. Process the extracted interface information according to the format of the test case to obtain processed interface information.

[0079] In steps s41 to s43, in order to facilitate the subsequent writing, modification and development of the interface document or to quickly generate a test, the electronic device can obtain the code type of the target module, which may include C language, object-oriented and literal computer programming language Python or object-oriented programming language Java, etc. The format of the test case corresponding to each type of code is inconsistent. Therefore, the format of the test case used to test the target module can be determined according to the code type in the target module. In order to quickly add the interface document of the target module to the test case when testing the target module, the electronic device can process the extracted interface information according to the format of the test case to obtain the processed interface information. For example, if the code type of the target module is Java, the format of the test case corresponding to the target module can be JavaScript Object Notation (JSON), that is, a lightweight data exchange format. The extracted interface information is processed according to the JSON format to obtain the processed interface information.

[0080] S204. Update the interface document of the target module according to the processed interface information to obtain an updated interface document.

[0081] S205: Receive a test request for the target module.

[0082] S206. Add the interface information in the updated interface document to the test case used to test the target module. The interface information in the updated interface document includes one or more of the following: interface name, interface uniform resource locator, interface description, input parameters, output parameters, return data, domain name and port of the interface test server.

[0083] S207: Test the target module according to the test case of the target module.

[0084] In steps S205 to S207, when a test request for a target module is received, the electronic device can add the interface information in the updated interface document to the test case used to test the target module, and test the target module according to the test case of the target module. The updated interface document is the latest interface document of the target module. Therefore, it can more accurately test whether the functions of the target module meet the requirements.

[0085] In an embodiment of the present invention, the electronic device detects whether a module in a code database is updated through information such as the module's timestamp, version number, and number of code lines. When a module is updated, the updated module is determined as a target module, so that the updated module can be automatically obtained. The updated code in the target module is obtained, and the interface information is extracted from the code annotation information corresponding to the updated code, and the extracted interface information is formatted to obtain the processed interface information, and the interface document of the target module is updated according to the processed interface information. The interface document of the target module is updated in real time according to the interface information corresponding to the updated code in the target module, so that the function of the module can be verified more accurately, the operation is simple and convenient, and the efficiency of updating the interface document is improved. In addition, the extracted interface information is formatted to facilitate the subsequent writing, modification and development of the interface document.

[0086] See also Figure 3 , is a schematic diagram of the structure of an interface document updating device provided by an embodiment of the present invention. The device of the embodiment of the present invention can be arranged in the electronic device mentioned above. In this embodiment, the interface document updating device includes:

[0087] A determination module 301, configured to determine a target module whose code is to be updated from at least one module in a code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module;

[0088] An acquisition module 302 is used to acquire the updated code in the target module and the interface document of the target module, wherein the updated code is at least one of the deleted code, the newly added code and the replaced code in the target module;

[0089] An extraction module 303, used to extract interface information from the code annotation information corresponding to the updated code;

[0090] The processing module 304 is used to perform format processing on the extracted interface information to obtain processed interface information, wherein the code annotation information is used to explain the updated code;

[0091] The updating module 305 is used to update the interface document of the target module according to the processed interface information to obtain an updated interface document.

[0092] Optionally, the preset rules include rules set according to the timestamp of the module, and a determination module 301 is specifically used to obtain a first timestamp of the last update of each module in the code database, and a second timestamp of the last update of the interface document corresponding to each module; and a module in the code database whose difference between the first timestamp and the second timestamp is greater than a preset threshold is determined as a target module.

[0093] Optionally, the preset rules include rules set according to the version number of the module, and a determination module 301 is specifically used to obtain the current version number and historical version number of each module in the code database, where the historical version number of each module is the version number of the module when the interface document of the corresponding module was last updated; and a module in the code database whose current version number is different from the historical version number is determined as a target module.

[0094] Optionally, the preset rules include rules set according to the number of code lines of the module, and a determination module 301 is specifically used to obtain the current number of code lines and the historical number of code lines of each module in the code database, where the historical number of code lines of each module is the number of code lines of the corresponding module when the interface document of the corresponding module was last updated; and a module in the code database whose current number of code lines is different from the historical number of code lines is determined as a target module.

[0095] Optionally, the extraction module 303 is specifically used to obtain the code type in the target module; determine the format of the test case used to test the target module according to the code type in the target module; and process the extracted interface information according to the format of the test case to obtain processed interface information.

[0096] Optionally, the update module 305 is used to delete the interface information matching the processed interface information from the interface document of the target module if the updated code is the code deleted in the target module; add the processed interface information to the interface document of the target module if the updated code is the code newly added in the target module; and remove the interface information corresponding to the code before the replacement from the interface document of the target module if the updated code is the code replaced in the target module, and add the processed interface information to the interface document of the target module.

[0097] Optionally, the device also includes: a testing module 306, used to receive a test request for the target module; adding the interface information in the updated interface document to the test case used to test the target module, the interface information in the updated interface document including one or more of the following: interface name, interface uniform resource locator, interface description, input parameters, output parameters, return data, domain name and port of the interface test server; testing the target module according to the test case of the target module.

[0098] In an embodiment of the present invention, the electronic device detects whether a module in a code database is updated through information such as the module's timestamp, version number, and number of code lines. When a module is updated, the updated module is determined as a target module, so that the updated module can be automatically obtained. The updated code in the target module is obtained, and the interface information is extracted from the code annotation information corresponding to the updated code, and the extracted interface information is formatted to obtain the processed interface information, and the interface document of the target module is updated according to the processed interface information. The interface document of the target module is updated in real time according to the interface information corresponding to the updated code in the target module, so that the function of the module can be verified more accurately, the operation is simple and convenient, and the efficiency of updating the interface document is improved. In addition, the extracted interface information is formatted to facilitate the subsequent writing, modification and development of the interface document.

[0099] See also Figure 4 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. As shown in the figure, the electronic device in this embodiment may include: one or more processors 401; one or more input devices 402, one or more output devices 403 and a memory 404. The processor 401, input device 402, output device 403 and memory 404 are connected via a bus 405.

[0100] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.

[0101] The input device 402 may include a touch pad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint direction information), a microphone, etc. The output device 403 may include a display (LCD, etc.), a speaker, etc. The output device 403 can output prompt information, and the prompt information can be used to prompt whether the target user has abnormal hospitalization behavior.

[0102] The memory 404 may include a read-only memory and a random access memory, and provide instructions and data to the processor 401. A portion of the memory 404 may also include a non-volatile random access memory, and the memory 404 is used to store a computer program, the computer program includes program instructions, and the processor 401 is used to execute the program instructions stored in the memory 404 to perform an interface document update method, that is, to perform the following operations:

[0103] Determine a target module whose code is to be updated from at least one module in the code database according to a preset rule, wherein the preset rule includes a rule set according to at least one of a timestamp, a version number, and a number of code lines of the module;

[0104] Acquire the updated code in the target module and the interface document of the target module, wherein the updated code is at least one of the deleted code, the newly added code and the replaced code in the target module;

[0105] Extracting interface information from code annotation information corresponding to the updated code, performing format processing on the extracted interface information to obtain processed interface information, wherein the code annotation information is used to explain the updated code;

[0106] The interface document of the target module is updated according to the processed interface information to obtain an updated interface document.

[0107] Optionally, the preset rule includes a rule set according to a timestamp of the module, and the processor is used to execute program instructions stored in the memory to perform the following operations:

[0108] Obtain a first timestamp of the last update of each module in the code database, and a second timestamp of the last update of the interface document corresponding to each module;

[0109] A module in the code database, in which the difference between the first timestamp and the second timestamp is greater than a preset threshold, is determined as a target module.

[0110] Optionally, the preset rule includes a rule set according to a version number of the module, and the processor is used to execute program instructions stored in the memory to perform the following operations:

[0111] Obtain the current version number and historical version number of each module in the code database, where the historical version number of each module is the version number of the module when the interface document of the corresponding module was last updated;

[0112] A module in the code database whose current version number is different from the historical version number is determined as a target module.

[0113] Optionally, the preset rule includes a rule set according to the number of code lines of the module, and the processor is used to execute program instructions stored in the memory to perform the following operations:

[0114] Obtain the current number of code lines and the historical number of code lines of each module in the code database, where the historical number of code lines of each module is the number of code lines of the corresponding module when the interface document of the corresponding module was last updated;

[0115] A module in the code database whose current number of code lines is different from the historical number of code lines is determined as a target module.

[0116] Optionally, the processor is used to execute program instructions stored in the memory to perform the following operations:

[0117] Obtaining the code type in the target module;

[0118] Determining a format of a test case for testing the target module according to a code type in the target module;

[0119] The extracted interface information is processed according to the format of the test case to obtain processed interface information.

[0120] Optionally, the processor is used to execute program instructions stored in the memory to perform the following operations:

[0121] If the updated code is the code deleted in the target module, deleting the interface information matching the processed interface information from the interface document of the target module;

[0122] If the updated code is a newly added code in the target module, adding the processed interface information to the interface document of the target module;

[0123] If the updated code is the replaced code in the target module, the interface information corresponding to the code before the replacement is removed from the interface document of the target module, and the processed interface information is added to the interface document of the target module.

[0124] Optionally, the processor is used to execute program instructions stored in the memory to perform the following operations:

[0125] Receiving a test request for the target module;

[0126] Adding the interface information in the updated interface document to the test case for testing the target module, the interface information in the updated interface document including one or more of the following: interface name, interface uniform resource locator, interface description, input parameters, output parameters, return data, domain name and port of the interface test server;

[0127] The target module is tested according to the test case of the target module.

[0128] In an embodiment of the present invention, the electronic device detects whether a module in a code database is updated through information such as the module's timestamp, version number, and number of code lines. When a module is updated, the updated module is determined as a target module, so that the updated module can be automatically obtained. The updated code in the target module is obtained, and the interface information is extracted from the code annotation information corresponding to the updated code, and the extracted interface information is formatted to obtain the processed interface information, and the interface document of the target module is updated according to the processed interface information. The interface document of the target module is updated in real time according to the interface information corresponding to the updated code in the target module, so that the function of the module can be verified more accurately, the operation is simple and convenient, and the efficiency of updating the interface document is improved. In addition, the extracted interface information is formatted to facilitate the subsequent writing, modification and development of the interface document.

[0129] The processor 401, input device 402, and output device 403 described in the embodiment of the present invention can execute the implementation methods described in the first and second embodiments of the interface document update method provided in the embodiment of the present invention, and can also execute the implementation methods of the electronic device described in the embodiment of the present invention, which will not be repeated here.

[0130] In another embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the present invention is implemented. Figure 1 and Figure 2 The interface document updating method shown in the embodiment.

[0131] The computer-readable storage medium may be an internal storage unit of the electronic device described in any of the foregoing embodiments, such as a hard disk or memory of a control device. The computer-readable storage medium may also be an external storage device of the control device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the control device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the control device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the control device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.

[0132] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the control device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0133] In the several embodiments provided in the present application, it should be understood that the disclosed control device and method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0134] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A method for updating an interface document, It is characterized in that include: When the preset rule includes the timestamp according to the module, obtain the first timestamp of the last update of each module in the code database and the second timestamp of the last update of the interface document corresponding to each module; determine the module in the code database whose difference between the first timestamp and the second timestamp is greater than a preset threshold as the target module whose code is updated; Obtaining an interface document of the target module and system log data of a device for developing the target module, extracting log data about the target module from the system log data according to an identifier of the target module, and obtaining updated code in the target module from the log data of the target module, wherein the updated code is at least one of deleted code, newly added code and replaced code in the target module; Extracting interface information from the code annotation information corresponding to the updated code to obtain the code type in the target module; determining the format of a test case for testing the target module according to the code type in the target module; processing the extracted interface information according to the format of the test case to obtain processed interface information, wherein the code annotation information is used to explain the updated code; If the updated code is the code deleted in the target module, deleting the interface information matching the processed interface information from the interface document of the target module; If the updated code is a newly added code in the target module, adding the processed interface information to the interface document of the target module; If the updated code is the replaced code in the target module, the interface information corresponding to the code before the replacement is removed from the interface document of the target module, and the processed interface information is added to the interface document of the target module.

2. The method according to claim 1, It is characterized in that The preset rules also include rules set according to the version number of the module, and the method further includes: Obtain the current version number and historical version number of each module in the code database, where the historical version number of each module is the version number of the corresponding module when the interface document of the corresponding module was last updated; A module in the code database whose current version number is different from the historical version number is determined as a target module.

3. The method according to claim 1, It is characterized in that The preset rules also include rules set according to the number of code lines of the module, and the method further includes: Obtain the current number of code lines and the historical number of code lines of each module in the code database, where the historical number of code lines of each module is the number of code lines of the corresponding module when the interface document of the corresponding module was last updated; A module in the code database whose current number of code lines is different from the historical number of code lines is determined as a target module.

4. The method according to any one of claims 1 to 3, It is characterized in that The method further comprises: Receiving a test request for the target module; Adding the interface information in the updated interface document to the test case for testing the target module, the interface information in the updated interface document including one or more of the following: interface name, interface uniform resource locator, interface description, input parameters, output parameters, return data, domain name and port of the interface test server; The target module is tested according to the test case of the target module.

5. An interface document updating device, It is characterized in that include: A determination module, configured to obtain, when the preset rule includes a timestamp based on the module, a first timestamp of the last update of each module in the code database and a second timestamp of the last update of the interface document corresponding to each module; and determine a module in the code database whose difference between the first timestamp and the second timestamp is greater than a preset threshold as a target module whose code is to be updated; an acquisition module, used to acquire an interface document of the target module and system log data of a device for developing the target module, extract log data about the target module from the system log data according to an identifier of the target module, and acquire updated code in the target module from the log data of the target module, wherein the updated code is at least one of deleted code, newly added code and replaced code in the target module; An extraction module, used for extracting interface information from code annotation information corresponding to the updated code; A processing module, used for obtaining the code type in the target module; Determining the format of a test case for testing the target module according to the code type in the target module; processing the extracted interface information according to the format of the test case to obtain processed interface information, wherein the code annotation information is used to explain the updated code; An updating module, configured to delete, from an interface document of the target module, interface information matching the processed interface information if the updated code is the code deleted in the target module; If the updated code is a newly added code in the target module, adding the processed interface information to the interface document of the target module; If the updated code is the replaced code in the target module, the interface information corresponding to the code before the replacement is removed from the interface document of the target module, and the processed interface information is added to the interface document of the target module.

6. An electronic device, It is characterized in that include: a processor adapted to implement at least one instruction; and A computer-readable storage medium storing at least one instruction, wherein the at least one instruction is suitable for being loaded by a processor and executing the interface document updating method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores at least one instruction, and the at least one instruction is suitable for being loaded by a processor and executing the interface document updating method as described in any one of claims 1-4.