Interface change detection method and device

By automatically detecting differences in input and output parameters and access path parameters in interface documents, an interface change report is generated, which solves the time-consuming and error-prone problem of back-end developers manually sorting out interface change documents, and improves efficiency and accuracy.

CN112579146BActive Publication Date: 2024-10-25BEIJING GRIDSUM TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN201910947627.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-29
Publication Date
2024-10-25
Estimated Expiration
2039-09-29

AI Technical Summary

Technical Problem

During the project development and version iteration process, back-end developers manually organize the documentation of interface changes, which is time-consuming and error-prone. Existing technologies cannot effectively solve this problem.

Method used

By obtaining the interface documents of the two versions, extracting the input and output parameters and access path parameters, automatically detecting parameter differences, generating interface change information, and outputting detection reports, automatic interface change detection is realized.

Benefits of technology

It improves the efficiency of interface document change detection, reduces human errors, and realizes automated interface change monitoring and report generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112579146B_ABST
    Figure CN112579146B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for detecting interface changes. The method includes: obtaining a first interface document of a first version and a second interface document of a second version; extracting a first input-output parameter and a first access path parameter of an application interface from the first interface document, and extracting a second input-output parameter and a second access path parameter of the application interface from the second interface document; detecting the difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and detecting the difference between the first access path parameter and the second access path parameter to obtain second interface change information; outputting the first interface change information and the second interface change information. The present application solves the technical problem of low efficiency in determining interfaces and parameters that have changed in interface documents in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software development, and in particular to a method and device for detecting interface changes. Background Art

[0002] During project development and version iteration, especially for projects with separated front-end and back-end, when back-end developers and front-end developers are doing interface docking, back-end developers need to inform front-end developers which new interfaces have been added and which parameters of existing interfaces have been modified. If back-end developers manually organize the documentation of interface changes, it is very time-consuming and prone to errors. To solve the above problems, in Java back-end web development, by introducing Swagger documents, you only need to add corresponding annotations to the relevant application program interfaces (APIs) and classes to generate interface-related documents. However, this method of manually checking which parameters of which interfaces have changed based on swagger documents is labor-intensive and error-prone.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present application provide a method and device for detecting interface changes, so as to at least solve the technical problem of low efficiency in determining changed interfaces and parameters in interface documents in the related art.

[0005] According to one aspect of an embodiment of the present application, a method for detecting an interface change is provided, including: obtaining a first interface document of a first version and a second interface document of a second version; extracting a first input-output parameter and a first access path parameter of an application interface from the first interface document, and extracting a second input-output parameter and a second access path parameter of the application interface from the second interface document; detecting a difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and detecting a difference between the first access path parameter and the second access path parameter to obtain second interface change information; and outputting the first interface change information and the second interface change information.

[0006] Optionally, detecting the difference between the first input-output parameter and the second input-output parameter to obtain the first interface change information, and detecting the difference between the first access path parameter and the second access path parameter to obtain the second interface change information, includes: loading the first input-output parameter and the second input-output parameter into a first instance corresponding to the first interface document, and loading the first access path parameter and the second access path parameter into a second instance corresponding to the second interface document; comparing the difference between the first type of field in the first instance and the first type of field in the second instance to obtain the first interface change information, wherein the first type of field is used to define the input-output parameters in the first interface document and the second interface document; and comparing the difference between the second type of field in the first instance and the second type of field in the second instance to obtain the second interface change information, wherein the second type of field is used to define the access path parameters in the first interface document and the second interface document;

[0007] Optionally, the difference between the first category field in the first instance and the first category field in the second instance is compared to obtain the first interface change information, including at least one of the following: determining a deleted class in the first category field that exists in the first instance but does not exist in the second instance, and using the deleted class as the first interface change information; determining a newly added class in the first category field that does not exist in the first instance but exists in the second instance, and using the newly added class as the first interface change information; determining a common class in the first category field that exists in both the first instance and the second instance, determining the difference between each object in the common class in the first instance and the second instance, and obtaining the first interface change information.

[0008] Optionally, determining the difference between each object in a common class in a first instance and a second instance includes: detecting the type of the target object in the common class; when the type is the first type, comparing the difference between the first type of the target object in the first instance and the first type in the second instance; when the type is the second type, obtaining a target attribute in the target object, wherein the target attribute is used to reference other definition fields to define the target object; determining the target object corresponding to the target attribute, and continuing to determine the difference between the object corresponding to the target attribute in the first instance and the second instance; when the type is the third type, traversing the subclass in the attribute class in the target object, and determining the difference between the subclass in the first instance and the second instance.

[0009] Optionally, the target object includes: a simple Java object POJO; the first type includes: a basic type, the basic type includes at least one of the following: an integer type, a long integer type, a Boolean type, a string type; the second type includes: an array; the third type includes: an object class.

[0010] Optionally, the difference between the second category field in the first instance and the second category field in the second instance is compared to obtain the second interface change information, including: determining the interface in the second category field that exists in the first instance but does not exist in the second instance, and using the determination result as the second interface change information; determining the interface in the second category field that does not exist in the first instance but exists in the second instance, and using the determination result as the second interface change information; determining the common interface in the first category field that exists in both the first instance and the second instance, determining the difference between each interface in the common interface in the first instance and the second instance, and obtaining the second interface change information.

[0011] Optionally, determining the difference between each interface in the common interface in the first instance and the second instance includes at least one of the following: determining the difference between the request method corresponding to each interface in the first instance and the second instance; determining the difference between the sub-parameters in the parameter attributes of each interface in the first instance and the second instance; determining the difference between the response method of each interface in the first instance and the second instance.

[0012] Optionally, determining the difference between sub-parameters in the parameter attributes of each interface in the first instance and the second instance includes: determining the difference between the name parameter in the parameter attributes of each interface in the first instance and the second instance; when the name parameter is the same in the first instance and the second instance, determining the difference between the type parameter in the parameter attributes in the first instance and the second instance.

[0013] Optionally, outputting the first interface change information and the second interface change information includes one of the following: generating a detection report based on the first interface change information and the second interface change information, and outputting the detection report; or, when the second version is higher than the first version, highlighting the first interface change information and the second interface change information in the second interface document.

[0014] According to one aspect of an embodiment of the present application, a device for detecting interface changes is provided, including: an acquisition module, used to acquire a first interface document of a first version and a second interface document of a second version; an extraction module, used to extract a first input-output parameter and a first access path parameter of an application interface from the first interface document, and to extract a second input-output parameter and a second access path parameter of the application interface from the second interface document; a detection module, used to detect the difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and to detect the difference between the first access path parameter and the second access path parameter to obtain second interface change information; and an output module, used to output the first interface change information and the second interface change information.

[0015] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; and the processor is used to call program instructions in the memory to execute the interface change detection method as described above.

[0016] According to one aspect of an embodiment of the present application, a non-volatile storage medium is provided, the non-volatile storage medium including a stored program, wherein when the program is executed, a device where the non-volatile storage medium is located is controlled to execute the above-mentioned method for detecting interface changes.

[0017] According to one aspect of an embodiment of the present application, a processor is provided, and the processor is used to run a program, wherein the above-mentioned method for detecting interface changes is executed when the program is running.

[0018] In an embodiment of the present application, a method is adopted in which the differences between input and output parameters and access path parameters in a first interface document of a first version and a second interface document of a second version are determined, and interface change information is determined based on the differences. Since the above parameters can be automatically extracted and the differences between the parameters can be detected, the purpose of automatically detecting interface change information can be achieved, thereby solving the technical problem of low efficiency in determining interfaces and parameters that have changed in interface documents in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0020] Figure 1 is a flow chart of a method for detecting interface changes according to an embodiment of the present application;

[0021] Figure 2 is a structural schematic diagram of a device for detecting interface changes according to an embodiment of the present application;

[0022] Figure 3 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0025] Swagger: Swagger is an API expression tool. When you use Swagger to generate an API, you can get interactive documentation, an SDK that automatically generates code, and API discovery features.

[0026] Now, Swagger has helped world-renowned companies including Apigee, Getty Images, Intuit, LivingSocial, McKesson, Microsoft, Morningstar and PayPal to build a perfect service system based on RESTful API.

[0027] Interface document: A document containing interface information. In the embodiment of the present application, it may refer to a document containing an application interface provided to front-end developers during the software product development process.

[0028] Path parameter: To find user information based on username, you need to add an interface operation, such as adding an operation like / persons / {username} to get user information. Note that {username} is a parameter in the request path.

[0029] According to an embodiment of the present application, a method embodiment of a method for detecting interface changes is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0030] Figure 1 FIG. 1 is a flow chart of a method for detecting interface changes according to an embodiment of the present application. Figure 1 As shown, the method comprises the following processing steps:

[0031] Step S102, obtaining a first interface document of a first version and a second interface document of a second version;

[0032] In some embodiments of the present application, the above-mentioned first interface document and second interface document include but are not limited to: swagger document, wherein the swagger document can be determined in the following manner: adding corresponding annotations to the application interface and the corresponding class during the development process, and loading them into the original swagger document.

[0033] Step S104, extracting the first input / output parameter and the first access path parameter of the application interface from the first interface document, and extracting the second input / output parameter and the second access path parameter of the application interface from the second interface document;

[0034] In some embodiments of the present application, the first input and output parameters and the second input and output parameters include but are not limited to definition information in the swagger document, and the first access path parameter and the second access path parameter include but are not limited to: paths information. Specifically, the contents of the two versions of the swagger document are read respectively, and the paths information and definitions information are extracted by parsing the json file of the swagger temperature, and then the information is loaded into the corresponding instances, for example, loaded into swagger Instance1 and swagger Instance2 respectively.

[0035] Step S106, detecting the difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and detecting the difference between the first access path parameter and the second access path parameter to obtain second interface change information; the difference between the first input-output parameter and the second input-output parameter includes but is not limited to: increase, decrease, modification, etc. of classes related to the interface, for example, decrease or increase of POJO classes, changes in properties of POJO classes in the first interface document and the second interface document, etc.

[0036] Step S108: output first interface change information and second interface change information.

[0037] In some embodiments of the present application, there are multiple ways to output the first interface change information and the second interface change information. For example, a detection report is generated based on the first interface change information and the second interface change information, and the detection report is output. The detection report can only record the interface change information, and record it according to the first interface change information and the second interface change information classification; or, the interface change information is highlighted in the original document. For example, when the second version is higher than the first version, the first interface change information and the second interface change information are highlighted in the second interface document.

[0038] In an embodiment of the present application, a method is adopted in which the differences between input and output parameters and access path parameters in a first interface document of a first version and a second interface document of a second version are determined, and interface change information is determined based on the differences. Since the above parameters can be automatically extracted and the differences between the parameters can be detected, the purpose of automatically detecting interface change information can be achieved, thereby solving the technical problem of low efficiency in determining interfaces and parameters that have changed in interface documents in related technologies.

[0039] It should be noted that the execution subject of steps S102-108 may be a computer device, which includes a storage medium and a processor, and the storage medium includes program instructions for executing steps S102-S108.

[0040] There are many ways to implement step S106, for example, loading the first input-output parameter and the second input-output parameter into the first instance corresponding to the first interface document, and loading the first access path parameter and the second access path parameter into the second instance corresponding to the second interface document; comparing the difference between the first type of field in the first instance and the first type of field in the second instance to obtain the first interface change information, wherein the first type of field is used to define the input-output parameters in the first interface document and the second interface document; and comparing the difference between the second type of field in the first instance and the second type of field in the second instance to obtain the second interface change information, wherein the second type of field is used to define the access path parameters in the first interface document and the second interface document;

[0041] Specifically, the difference between the first category field in the first instance and the first category field in the second instance can be compared in at least one of the following ways to obtain the first interface change information: determine the deleted class in the first category field that exists in the first instance but does not exist in the second instance, and use the deleted class as the first interface change information; determine the newly added class in the first category field that does not exist in the first instance but exists in the second instance, and use the newly added class as the first interface change information; determine the public class in the first category field that exists in both the first instance and the second instance, determine the difference between each object in the public class in the first instance and the second instance, and obtain the first interface change information. It should be noted that the names of the above classes, such as deleted class, newly added class, and public class, are not used to limit the class, but only indicate the existence status of the class in the first instance and the second instance, for example, deleted class: the class deleted in the second instance; newly added class, indicating the newly added class in the second instance; public class: the class that can exist in both the first instance and the second instance.

[0042] When determining the difference between each object in a common class in a first instance and a second instance, the type of the target object in the common class is detected, for example, a common POJO class is detected; when the type is the first type, the difference between the first type of the target object in the first instance and the first type of the second instance is compared; when the type is the second type, a target attribute in the target object is obtained, wherein the target attribute is used to reference other definition fields to define the target object; a target object corresponding to the target attribute is determined, and the difference between the object corresponding to the target attribute in the first instance and the second instance is continued to be determined; when the type is the third type, a subclass in the attribute class in the target object is traversed, and the difference between the subclass in the first instance and the second instance is determined.

[0043] In some embodiments of the present application, the above-mentioned target object includes: a simple Java object POJO; the first type includes: a basic type, which includes at least one of the following: an integer type, a long integer type, a Boolean type, a string type; the second type includes: an array; the third type includes: an object class.

[0044] In order to make the acquired interface change information more comprehensive and complete, in addition to comparing the first category of fields, it is also necessary to compare the difference between the second category of fields in the first instance and the second category of fields in the second instance to obtain the second interface change information, including: determining the interface in the second category of fields that exists in the first instance but does not exist in the second instance, and using the determination result as the second interface change information; determining the interface in the second category of fields that does not exist in the first instance but exists in the second instance, and using the determination result as the second interface change information; determining the common interface in the first category of fields that exists in both the first instance and the second instance, determining the difference between each interface in the common interface in the first instance and the second instance, and obtaining the second interface change information.

[0045] Among them, the difference between each interface in the common interface in the first instance and the second instance can be determined by at least one of the following methods: determining the difference between the request method corresponding to each interface in the first instance and the second instance; determining the difference between the sub-parameters in the parameter attributes of each interface in the first instance and the second instance; determining the difference between the response method of each interface in the first instance and the second instance.

[0046] In some embodiments of the present application, the difference between the sub-parameters in the parameter attributes of each interface in the first instance and the second instance can also be determined in the following manner: determine the difference between the name parameter in the parameter attributes of each interface in the first instance and the second instance; when the name parameter is the same in the first instance and the second instance, determine the difference between the type parameter in the parameter attributes in the first instance and the second instance.

[0047] Take the swagger document as an example

[0048] 1) Generate swagger documents for version 1 and swagger documents for version 2

[0049] During the development process, add corresponding annotations to the API interface and class. After starting the project, you can download the swagger document

[0050] 2) Parse the contents of the swagger document

[0051] Read the contents of the swagger document separately, extract the paths information and definitions information by parsing the swagger json file, and load the interface information into the corresponding instance. Suppose they are loaded into swaggerInstance1 and swaggerInstance2 respectively.

[0052] 3) Detect changes in related classes defined in definitions

[0053] a) Compare the definitions fields in swagger Instance1 and swagger Instance2, A = {swagger Instance1.definitions-swagger Instance2.definitions} is the set of deleted POJO classes (i.e., the set of POJO classes in swagger Instance1.definitions but not in swagger Instance2.definitions), B = {swagger Instance2.definitions-swagger Instance1.definitions} is the set of added POJO classes (i.e., the set of POJO classes in swagger Instance2.definitions but not in swaggerInstance1.definitions), and C is the set of POJO classes shared by swagger Instance1.definitions and swagger Instance2.definitions

[0054] b) Detect that the common POJO classes in C are changed in swaggerInstance1.definitions and swaggerInstance2.definitions.

[0055] i) For each POJO object, determine the type,

[0056] ii) If type is a basic type (integer, long, string, boolean, etc.), only type is compared and the difference is recorded;

[0057] iii) If type is array, get the $ref of items and find the related POJO, repeat i, recursively compare, and record the differences;

[0058] iv) If type is object, traverse its properties, compare the POJO classes in the properties, recursively compare, and record the differences;

[0059] 4) Detect interface changes in paths

[0060] a) Compare the paths fields in swagger Instance1 and swagger Instance2, A = {swaggerInstance1.paths-swaggerInstance2.paths} is the deleted API interface set (that is, the API interface set in swaggerInstance1.paths but not in swaggerInstance2.paths), B = {swaggerInstance2.paths-swaggerInstance1.paths} is the added API interface set (that is, the API interface set in swaggerInstance2.paths but not in swaggerInstance1.paths), and C is the API interface set shared by swaggerInstance1.paths and swaggerInstance2.paths

[0061] b) Detect that the common API interfaces in C have changed in swaggerInstance1.paths and swaggerInstance2.paths.

[0062] i) For each interface, determine the request mode (post, get, delete, etc.), and determine the difference between the request mode in the first instance and the second instance;

[0063] ii) For each interface, determine the parameters based on the parameter name. If the parameter names (or usernames) are different, record them. If the names are the same, compare the types. {username} is a path parameter. We need to add it to the parameters property like a request parameter and use the in property to indicate that it is a path parameter.

[0064] If type is a basic type (integer, long, string, boolean, etc.), only type is compared and the difference is recorded;

[0065] If type is array, get the $ref of items and find the relevant POJO class. Compare it with the result recorded in step (3) and record the difference. $ref is a reference parameter, for example:

[0066] In the definition, you can add another definition, Persons, by referencing the defined Person. Persons is an array of Person objects. The difference from the previous direct definition is that a reference property, $ref, is added to reference Person. The location of $ref is:

[0067] Persons:

[0068] type:array

[0069] Items:

[0070] $ref:"# / definitions / Person

[0071] If type is object, traverse its properties, compare the POJO classes in the properties, compare them according to the results recorded in step 3), and record the differences;

[0072] For each interface, determine the schema corresponding to "200" in responses, use "$ref" to find the POJO class corresponding to the response, compare it with the results recorded in step 3), and record the differences;

[0073] 5) Output the interface changes in paths.

[0074] By adopting the solution in the embodiment of the present application, changes in the interface can be automatically detected, making it convenient for developers to connect and maintain the interface.

[0075] The present application also provides a device for detecting interface changes. Figure 2 As shown, the device comprises:

[0076] An acquisition module 20 is used to acquire a first interface document of a first version and a second interface document of a second version;

[0077] An extraction module 22, configured to extract a first input / output parameter and a first access path parameter of the application interface from the first interface document, and to extract a second input / output parameter and a second access path parameter of the application interface from the second interface document;

[0078] The detection module 24 is used to detect the difference between the first input-output parameter and the second input-output parameter to obtain the first interface change information, and to detect the difference between the first access path parameter and the second access path parameter to obtain the second interface change information;

[0079] The output module 26 is used to output the first interface change information and the second interface change information.

[0080] The above-mentioned detection module 24 is also used to load the first input-output parameter and the second input-output parameter into a first instance corresponding to the first interface document, and load the first access path parameter and the second access path parameter into a second instance corresponding to the second interface document; compare the difference between the first type of field in the first instance and the first type of field in the second instance to obtain the first interface change information, wherein the first type of field is used to define the input and output parameters in the first interface document and the second interface document; and compare the difference between the second type of field in the first instance and the second type of field in the second instance to obtain the second interface change information, wherein the second type of field is used to define the access path parameters in the first interface document and the second interface document.

[0081] It should be noted that the above-mentioned modules can be expressed as software program modules or hardware modules. For the latter, it can be expressed as: the above-mentioned modules are located in the same storage medium or in different storage media.

[0082] The interface change detection device includes a processor and a memory. The acquisition unit, extraction unit, detection unit, and output unit are all stored in the memory as program units. The processor executes the program units stored in the memory to implement the corresponding functions. The processor includes a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels can be set. By adjusting the kernel parameters, the technical problem of low efficiency in determining the changed interfaces and parameters in the interface document in the related art is solved.

[0083] An embodiment of the present application also provides a non-volatile storage medium, which includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the above interface change detection method, and the non-volatile storage medium stores a program for executing the following instructions: obtaining a first interface document of a first version and a second interface document of a second version; extracting a first input and output parameter and a first access path parameter of the application interface from the first interface document, and extracting a second input and output parameter and a second access path parameter of the application interface from the second interface document; detecting the difference between the first input and output parameter and the second input and output parameter to obtain first interface change information, and detecting the difference between the first access path parameter and the second access path parameter to obtain second interface change information; outputting the first interface change information and the second interface change information.

[0084] The embodiment of the present application also provides a processor, the processor is used to run a program, wherein the above interface change detection method is executed when the program is running, the method comprising: obtaining a first interface document of a first version and a second interface document of a second version; extracting a first input-output parameter and a first access path parameter of the application interface from the first interface document, and extracting a second input-output parameter and a second access path parameter of the application interface from the second interface document; detecting the difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and detecting the difference between the first access path parameter and the second access path parameter to obtain second interface change information; outputting the first interface change information and the second interface change information. According to one aspect of the embodiment of the present application, an electronic device 30 is provided, such as Figure 3 The device includes at least one processor 301, at least one memory 302 and a bus 303 connected to the processor; wherein the processor and the memory communicate with each other through the bus; the processor is used to call the program instructions in the memory to execute the above-mentioned interface change detection method. For example, executing Figure 1 The interface change detection method shown is specifically:

[0085] The above-mentioned processor is used to call the program instructions in the memory to execute the above-mentioned program instructions to implement the following functions: obtain the first interface document of the first version and the second interface document of the second version; extract the first input and output parameters and the first access path parameters of the application interface from the first interface document, and extract the second input and output parameters and the second access path parameters of the application interface from the second interface document; detect the difference between the first input and output parameters and the second input and output parameters to obtain the first interface change information, and detect the difference between the first access path parameters and the second access path parameters to obtain the second interface change information; output the first interface change information and the second interface change information.

[0086] The electronic devices in this article can be servers, PCs, PADs, mobile phones, etc.

[0087] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: obtaining a first interface document of a first version and a second interface document of a second version; extracting a first input-output parameter and a first access path parameter of an application interface from the first interface document, and extracting a second input-output parameter and a second access path parameter of the application interface from the second interface document; detecting a difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and detecting a difference between the first access path parameter and the second access path parameter to obtain second interface change information; and outputting the first interface change information and the second interface change information.

[0088] Optionally, when executed on a data processing device, the program is also used to execute the following method steps: loading the first input-output parameter and the second output-input parameter into a first instance corresponding to the first interface document, and loading the first access path parameter and the second access path parameter into a second instance corresponding to the second interface document; comparing the difference between the first category field in the first instance and the first category field in the second instance to obtain first interface change information; and comparing the difference between the second category field in the first instance and the second category field in the second instance to obtain second interface change information; determining a deleted class in the first category field that exists in the first instance but does not exist in the second instance, and using the deleted class as the first interface change information; determining a newly added class in the first category field that does not exist in the first instance but exists in the second instance, and using the newly added class as the first interface change information; determining a common class in the first category field that exists in both the first instance and the second instance, determining the difference between each object in the common class in the first instance and the second instance, and obtaining the first interface change information. Detect the type of the target object in the public class; when the type is the first type, compare the difference between the first type in the first instance and the first type in the second instance of the target object; when the type is the second type, obtain the target attribute in the target object; determine the target object corresponding to the target attribute, and continue to determine the difference between the object corresponding to the target attribute in the first instance and the second instance; when the type is the third type, traverse the subclasses in the attribute class in the target object and determine the difference between the subclasses in the first instance and the second instance. Determine the interface in the second class field that exists in the first instance but does not exist in the second instance, and use the determination result as the second interface change information; determine the interface in the second class field that does not exist in the first instance but exists in the second instance, and use the determination result as the second interface change information; determine the public interface in the first class field that exists in both the first instance and the second instance, determine the difference between each interface in the public interface in the first instance and the second instance, and obtain the second interface change information. Determine the difference between the request mode corresponding to each interface in the first instance and the second instance; determine the difference between the sub-parameters in the parameter attribute of each interface in the first instance and the second instance; determine the difference between the response mode of each interface in the first instance and the second instance. Determine the difference between the name parameter in the parameter attribute of each interface in the first instance and the second instance; when the name parameter is the same in the first instance and the second instance, determine the difference between the type parameter in the parameter attribute in the first instance and the second instance. Generate a detection report based on the first interface change information and the second interface change information, and output the detection report; or when the second version is higher than the first version, highlight the first interface change information and the second interface change information in the second interface document.

[0089] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0090] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.

[0091] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.

[0092] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0093] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0094] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0095] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0096] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0097] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for detecting interface changes, characterized in that: include: Obtain a first interface document of a first version and a second interface document of a second version; Extracting first input / output parameters and first access path parameters of the application interface from the first interface document, and extracting second input / output parameters and second access path parameters of the application interface from the second interface document; Detecting a difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and detecting a difference between the first access path parameter and the second access path parameter to obtain second interface change information, wherein the difference between the first input-output parameter and the second input-output parameter includes: addition, reduction, and modification of classes related to the interface; Detecting a difference between the first input-output parameter and the second input-output parameter to obtain first interface change information includes: loading the first input-output parameter and the second input-output parameter into a first instance corresponding to the first interface document; Determine a common class in a first-category field that exists in both the first instance and the second instance, wherein the first-category field is used to define input and output parameters in the first interface document and the second interface document, and the input and output parameters include: definitions; Detecting the type of the target object in the common class, including: when the type is the first type, comparing the difference between the first type of the target object in the first instance and the first type in the second instance; when the type is the second type, obtaining the target attribute in the target object, wherein the target attribute is used to reference other definition fields to define the target object; determining the target object corresponding to the target attribute, and continuing to determine the difference between the first instance and the second instance of the object corresponding to the target attribute; when the type is the third type, traversing the subclass in the attribute class in the target object, and determining the difference between the first instance and the second instance of the subclass, wherein the target object includes: a Java object POJO; The first interface change information and the second interface change information are output.

2. The method according to claim 1, characterized in that Detecting a difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and detecting a difference between the first access path parameter and the second access path parameter to obtain second interface change information, including: Comparing the difference between the first type of fields in the first instance and the first type of fields in the second instance to obtain the first interface change information; and Compare the difference between the second type of fields in the first instance and the second type of fields in the second instance to obtain the second interface change information, wherein the second type of fields are used to define the access path parameters in the first interface document and the second interface document.

3. The method according to claim 2, characterized in that Comparing the difference between the first type of fields in the first instance and the first type of fields in the second instance to obtain the first interface change information includes at least one of the following: Determine a deletion class in the first class field that exists in the first instance but does not exist in the second instance, and use the deleted class as the first interface change information; Determine a newly added class in the first class field that does not exist in the first instance but exists in the second instance, and use the newly added class as the first interface change information; The difference between each object in the common class in the first instance and the second instance is determined to obtain the first interface change information.

4. The method according to claim 2, characterized in that: Comparing the difference between the second type of fields in the first instance and the second type of fields in the second instance to obtain the second interface change information includes: Determine an interface in the second type field that exists in the first instance but does not exist in the second instance, and use the determination result as the second interface change information; Determine an interface in the second type field that does not exist in the first instance but exists in the second instance, and use the determination result as the second interface change information; Determine the common interfaces in the first category field that exist in both the first instance and the second instance, determine the difference between each interface in the common interfaces in the first instance and the second instance, and obtain the second interface change information.

5. The method according to claim 4, characterized in that Determining a difference between each interface in the common interface in the first instance and the second instance includes at least one of the following: Determine the difference between the request mode corresponding to each interface in the first instance and the second instance; Determine the difference between the sub-parameters in the parameter attributes of each interface in the first instance and the second instance; The difference between the response mode of each interface in the first instance and the second instance is determined.

6. The method according to claim 5, characterized in that Determining the difference between the sub-parameters in the parameter attributes of each interface in the first instance and the second instance includes: Determine the difference between the name parameter in the parameter attribute of each interface in the first instance and the second instance; When the name parameter is the same in the first instance and the second instance, the difference between the type parameter in the parameter attribute in the first instance and the second instance is determined.

7. The method according to any one of claims 1 to 6, characterized in that: Outputting the first interface change information and the second interface change information includes one of the following: Generate a detection report based on the first interface change information and the second interface change information, and output the detection report; or In the case where the second version is higher than the first version, the first interface change information and the second interface change information are highlighted in the second interface document.

8. A device for detecting interface changes, characterized in that: include: An acquisition module, used to acquire a first interface document of a first version and a second interface document of a second version; an extraction module, configured to extract a first input / output parameter and a first access path parameter of the application interface from the first interface document, and to extract a second input / output parameter and a second access path parameter of the application interface from the second interface document; A detection module, used to detect the difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, and to detect the difference between the first access path parameter and the second access path parameter to obtain second interface change information, wherein the difference between the first input-output parameter and the second input-output parameter includes: increase, decrease, and modification of classes related to the interface; detecting the difference between the first input-output parameter and the second input-output parameter to obtain first interface change information, including: loading the first input-output parameter and the second input-output parameter into a first instance corresponding to the first interface document; determining a common class in a first class field that exists in both the first instance and the second instance, wherein the first class field is used to define the input-output parameters in the first interface document and the second interface document, The input and output parameters include: definitions; detecting the type of the target object in the common class, including: when the type is the first type, comparing the difference between the first type of the target object in the first instance and the first type in the second instance; when the type is the second type, obtaining the target attribute in the target object, wherein the target attribute is used to reference other definition fields to define the target object; determining the target object corresponding to the target attribute, and continuing to determine the difference between the first instance and the second instance of the object corresponding to the target attribute; when the type is the third type, traversing the subclasses in the attribute class in the target object, and determining the difference between the first instance and the second instance of the subclasses, wherein the target object includes: a Java object POJO; An output module is used to output the first interface change information and the second interface change information.

9. An electronic device, characterized in that: The device includes at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the interface change detection method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Verification method and device for returned parameters of interface, equipment and readable storage medium

    CN108089985A

  • Interface management method, interface management device, interface management equipment and storage medium

    CN109710298A

  • A method and a terminal for automatically comparing interface document differences

    CN109710301A

  • Interface test method and device, computer equipment and storage medium

    CN109947646A

  • Software interface monitor method and system

    US20050132346A1