Interface upgrading method and device, equipment and medium

The interface source code is parsed through the JavaParser tool and uses mapping relationships and abstract syntax trees to upgrade the interface, which solves the problem of inefficient interface upgrades and realizes efficient and accurate interface migration and adaptation.

CN120540673APending Publication Date: 2025-08-26BEIJING BAIJU YIXING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510533786.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

In the prior art, the interface upgrade process is inefficient, there are a lot of repetitive work, and omissions and errors are prone to occur, resulting in the upgrade of the new interface that does not meet the transformation standards.

Method used

The interface source code is parsed through the JavaParser tool, obtain mapping relationships, and perform dependency upgrades and verifications. The abstract syntax tree is used for topological sorting and dependency updates, and the static type checking tool is combined to ensure the accuracy and efficiency of interface upgrades.

Benefits of technology

It significantly improves the efficiency of interface upgrades, from 10-20 minutes/interface to 1-2 minutes/interface, reduces manual intervention and reduces the risk of upgrade omissions and errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120540673A_ABST
    Figure CN120540673A_ABST
Patent Text Reader

Abstract

The invention discloses an interface upgrading method and device, equipment and a medium, and belongs to the technical field of communication. The method comprises the steps that a source code of a first interface is acquired; obtaining a mapping relationship between the first interface and the second interface; analyzing the source code of the first interface to obtain first interface Class type files and a dependency relationship between the first interface Class type files; upgrading the Class type file of the first interface and the dependency relationship between the Class type files of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the Class type files of the second interface and the Class type files of the second interface; performing verification processing on the second interface Class type files and a dependency relationship between the second interface Class type files; and outputting the second interface Class type file passing the verification processing according to the code storage path of the second interface. The conditions that the interface upgrading efficiency is low and upgrading omission and errors are prone to occurring can be improved, and the interface upgrading efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to an interface upgrade method, device, equipment and medium. Background Art

[0002] Currently, general interface upgrade development is based on the old version of the code. R&D personnel manually perform logical upgrades such as input parameter conversion and downstream interface replacement on the old version of the code. Interface upgrades involve copying historical code and then performing compatible logic adaptation based on the historical code. In conjunction with the property mapping plug-in of the integrated development environment (IDE), input and output parameter mappings are quickly generated. Upgrade adaptation parts such as field name modification and replacement of downstream RPC interface calls require manual adaptation and development.

[0003] When large-scale interfaces need to be migrated and adapted, R&D personnel need to perform a large amount of repetitive work of manually copying historical codes to the new version code package path, resulting in low migration efficiency.

[0004] Manual adaptation and development of transformation code logic involves a large amount of repetitive coding work, which is inefficient and prone to upgrade omissions and errors, resulting in the new interface upgrade not meeting the transformation standards. Summary of the Invention

[0005] In order to overcome the above technical defects, the purpose of this application is to provide an interface upgrade method, device, equipment and medium, the method comprising: receiving an instruction to upgrade a first interface; obtaining the source code of the first interface; obtaining the mapping relationship between the first interface and the second interface; parsing the source code of the first interface by a JavaParser tool (Java open source library tool) to obtain the dependency relationship between the first interface Class type file and the first interface Class type file; upgrading the dependency relationship between the first interface Class type file and the first interface Class type file according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the second interface Class type file and the second interface Class type file; verifying the dependency relationship between the second interface Class type file and the second interface Class type file; outputting the second interface Class type file that has passed the verification process according to the code storage path of the second interface. This application can improve the situation where the interface upgrade is inefficient and prone to upgrade omissions and errors, thereby improving the interface upgrade efficiency.

[0006] The specific technical solutions provided in the embodiments of this application are as follows:

[0007] In a first aspect, the present application provides an interface upgrade method, the method comprising:

[0008] receiving an instruction to upgrade the first interface;

[0009] Obtaining source code of the first interface; obtaining a mapping relationship between the first interface and the second interface;

[0010] Parsing the source code of the first interface by using an open source library tool to obtain first interface code classification type files and dependency relationships between the first interface code classification type files;

[0011] Updating the dependency relationship between the code classification type file of the first interface and the code classification type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the code classification type file of the second interface and the code classification type file of the second interface;

[0012] Verifying the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface;

[0013] The code classification type file of the second interface that has passed the verification process is output according to the code storage path of the second interface.

[0014] In one embodiment, the parsing of the source code of the first interface by an open source library tool to obtain the first interface code classification type file and the dependency relationship between the first interface code classification type files includes:

[0015] Creating an abstract syntax tree according to the source code of the first interface;

[0016] Recursively traverse the abstract syntax tree using a Java open source library tool to obtain first interface code classification type files and dependency relationships between first interface code classification type files;

[0017] Wherein, the first interface code classification type file includes input parameter type, output parameter type and method body execution logic type;

[0018] The dependency relationship between the first interface code classification type files is the dependency relationship between the input parameter type and the output parameter type of the first interface.

[0019] In one embodiment, the step of upgrading the dependency relationship between the first interface code classification type files according to the mapping relationship between the first interface and the second interface includes:

[0020] Converting the dependency relationship between the first interface code classification type files into a topological sort of the code classification type files in the abstract syntax tree;

[0021] updating the file names of the code classification type files in the abstract syntax tree according to the mapping relationship between the first interface and the second interface and in accordance with the topological sorting of the code classification type files in the abstract syntax tree;

[0022] Obtain the dependency relationship between the second interface code classification type files.

[0023] In one embodiment, the updating of the code classification type file of the first interface according to the mapping relationship between the first interface and the second interface includes:

[0024] Determine whether parameter types of the code classification type file of the first interface and the code classification type file of the second interface are consistent;

[0025] If so, the fields of the code classification type file of the first interface are recursively mapped according to the mapping relationship between the first interface and the second interface to obtain the code classification type file of the second interface; if not, the fields of the code classification type file of the first interface are manually mapped and encoded according to the mapping relationship between the first interface and the second interface.

[0026] In one embodiment, the verifying of the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface includes:

[0027] Determine, by a static type checking tool, whether the code classification type file of the second interface matches the second interface attribute;

[0028] If so, the code classification type file verification of the second interface is successful;

[0029] Determining whether a circular dependency occurs between the code classification type files of the second interface;

[0030] If not, the dependency relationship between the second interface code classification type files is successfully verified;

[0031] determining whether the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface comply with the Hypertext Transfer Protocol Application Programming Interface contract;

[0032] If so, the dependency verification process for the second interface code classification type file and the second interface code classification type files is successful.

[0033] In one embodiment, the method comprises:

[0034] In response to manual mapping and encoding of the fields of the code classification type file of the first interface based on the mapping relationship between the first interface and the second interface, a manual repair (TODO) item mark is added to the source code of the first interface, and a log of the reasons for manually mapping the fields of the code classification type file of the first interface is recorded.

[0035] In one embodiment, before obtaining the source code of the first interface and obtaining the mapping relationship between the first interface and the second interface, the steps include:

[0036] A mapping relationship between the first interface and the second interface is created according to the code classification type file name and the code storage path of the first interface and the second interface.

[0037] In a second aspect, the present application further provides an interface upgrade device, the device comprising:

[0038] A receiving module, configured to receive an instruction to upgrade the first interface;

[0039] An acquisition module, configured to acquire the source code of the first interface; and acquire a mapping relationship between the first interface and the second interface;

[0040] A parsing module, configured to parse the source code of the first interface using a JavaParser tool to obtain first interface code classification type files and dependency relationships between first interface code classification type files;

[0041] An upgrade module, configured to upgrade the code classification type file of the first interface and the dependency relationship between the code classification type file of the first interface according to the mapping relationship between the first interface and the second interface, and obtain the code classification type file of the second interface and the dependency relationship between the code classification type file of the second interface;

[0042] A verification module, configured to verify the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface;

[0043] The output module is used to output the code classification type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0044] In a third aspect, an interface upgrade device is also provided, comprising:

[0045] one or more processors;

[0046] a storage device for storing one or more programs;

[0047] When the one or more programs are executed by the one or more processors, the one or more processors implement the interface upgrade method as described in any one of the first aspects.

[0048] In a fourth aspect, the present application further provides a computer device, comprising:

[0049] A memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the interface upgrade method as described in any one of the first aspects.

[0050] In a fifth aspect, the present application also provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of any of the interface upgrade methods described in the first aspect.

[0051] In a sixth aspect, the present application further provides a computer storage medium, the medium comprising:

[0052] A computer program is stored thereon, and when the computer program is executed by a processor, the steps of any interface upgrading method described in the first aspect are implemented.

[0053] Compared with the prior art, the method described in the technical solution provided in the embodiment of the present application includes: receiving an instruction to upgrade the first interface; obtaining the source code of the first interface; obtaining the mapping relationship between the first interface and the second interface; parsing the source code of the first interface through the JavaParser tool to obtain the dependency relationship between the first interface Class type file and the first interface Class type file; upgrading the dependency relationship between the first interface Class type file and the first interface Class type file according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the second interface Class type file and the second interface Class type file; verifying the dependency relationship between the second interface Class type file and the second interface Class type file; and outputting the second interface Class type file that has passed the verification process according to the code storage path of the second interface. The present application can improve the situation where the interface upgrade is inefficient and prone to upgrade omissions and errors, thereby improving the interface upgrade efficiency.

[0054] The upgrade and transformation efficiency of the http protocol interface of the technical solution provided in the embodiment of the present application is improved from 10-20 minutes / interface to 1-2 minutes / interface, and the interface development efficiency is significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0056] Figure 1 This is a first flow chart of the interface upgrade method provided in Example 1 of the present application;

[0057] Figure 2 A second flow chart of the interface upgrade method provided in Example 2 of the present application;

[0058] Figure 3 This is a Class type file dependency data diagram provided in Example 2 of this application;

[0059] Figure 4 A specific flow chart of the interface upgrade method provided in Example 2 of this application;

[0060] Figure 5 This is a structural diagram of the interface upgrade device provided in Example 3 of the present application;

[0061] Figure 6 The exemplary system provided for the seventh embodiment of the present application can be used to implement the various embodiments described in the present application. DETAILED DESCRIPTION

[0062] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0063] It should be noted that, unless the context clearly requires otherwise, words such as “include” and “comprising” throughout the specification and claims should be interpreted as inclusive rather than exclusive or exhaustive; that is, as “including but not limited to”.

[0064] Furthermore, in the description of the present application, unless otherwise specified, “plurality” means two or more.

[0065] Example 1

[0066] The present application embodiment provides an interface upgrade method, such as Figure 1 As shown, the method includes:

[0067] receiving an instruction to upgrade the first interface;

[0068] Obtaining source code of the first interface; obtaining a mapping relationship between the first interface and the second interface;

[0069] Parsing the source code of the first interface by using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0070] Updating the dependency relationship between the Class type file of the first interface and the Class type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the Class type file of the second interface and the Class type file of the second interface;

[0071] Verifying the Class type file of the second interface and the dependency relationship between the Class type files of the second interface;

[0072] Output the Class type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0073] The Class type file is a code classification type file, and the JavaParser tool is an open source library tool, preferably a Java open source library tool.

[0074] Specifically, this application improves the efficiency of historical code copying, uses the JavaParser tool to parse historical Java source code, analyzes the dependencies between Java source code files, and automatically completes the historical code copying function; then uses the JavaPaser tool to automatically upgrade the parts of the historical code that need to be upgraded. The upgrade logic includes renaming of Class type file fields, exception handling and other general logic, replacement of Class type files of downstream RPC interfaces, and replacement of dependencies of Class type files.

[0075] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0076] This application can improve the situation where interface upgrade efficiency is low and upgrade omissions and errors are prone to occur, thereby improving the interface upgrade efficiency.

[0077] The upgrade and transformation efficiency of the http protocol interface of the technical solution provided in the embodiment of the present application is improved from 10-20 minutes / interface to 1-2 minutes / interface, and the interface development efficiency is significantly improved.

[0078] Example 2

[0079] The present application embodiment provides an interface upgrade method, such as Figure 2 As shown, the method includes:

[0080] Through the technical solution of this application, the R&D personnel responsible for interface upgrades only need to manually complete the work of creating mapping relationships before the upgrade and adding todo tags during manual repairs. The rest of the parsing, upgrading, verification, and output are automatically completed by the script.

[0081] Step S01: receiving an instruction to upgrade a first interface.

[0082] The interface here is the HTTP-API interface, which is a Hypertext Transfer Protocol Application Programming Interface, an interface that allows different software systems to communicate and exchange data through the HTTP protocol.

[0083] It can be understood that API: Application Programming Interface, is a set of definitions, protocols and tools used to enable interaction and communication between different software applications. Developers can access and use functions and data provided by other software through API interfaces without having to understand the specific implementation details within them.

[0084] Step S02: Create a mapping relationship between the first interface and the second interface according to the Class type file name and code storage path of the first interface and the second interface.

[0085] Specifically, R&D personnel are required to provide basic information about the old version of the interface code, such as the folder path of the source code, the path of the new RPC interface code dependency package, the mapping relationship between the old API interface (first interface) and the upgraded API interface (second interface), and organize it into an Excel file in the prescribed format.

[0086] Among them, the RPC (Remote Procedure Call) interface is a remote procedure call interface, which is a communication mechanism that allows a program to call a program or service on a remote computer in a network environment.

[0087] An Integrated Development Environment (IDE) is an application provided to programmers for developing software. It integrates various tools and functions required in the software development process, and can greatly improve development efficiency.

[0088] Step S03: Obtain the source code of the first interface; obtain the mapping relationship between the first interface and the second interface.

[0089] Step S04: Parse the source code of the first interface using a JavaParser tool to obtain first interface Class type files and dependency relationships between first interface Class type files.

[0090] The JavaParser tool is a library for parsing Java source code, which can parse Java code into an abstract syntax tree (AST) form that is easy to operate and analyze.

[0091] AST (Abstract Syntax Tree) is an abstract representation of the grammatical structure of source code. It uses a tree structure to describe the code, converts grammatical elements into nodes, and uses node connection relationships to reflect grammatical logic and hierarchy. It does not rely on a specific programming language, making it easy to analyze, process, and convert code. It is widely used in scenarios such as compilers, code optimization, code generation, and code analysis and inspection.

[0092] Java data types are divided into basic data types and reference data types; basic data types include numeric types (integer types byte, short, int, long, floating-point types float, double), character type char (representing a single character) and Boolean type boolean (values ​​true and false); reference data types include classes, interfaces, arrays, enumerations and String. Although String is not a basic data type, it is often used to process character strings.

[0093] Step S041, creating an abstract syntax tree according to the source code of the first interface;

[0094] Recursively traverse the abstract syntax tree using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0095] The first interface Class type file includes input parameter type, output parameter type and method body execution logic type;

[0096] The dependency relationship between the first interface Class type files is the dependency relationship between the input parameter type and the output parameter type of the first interface.

[0097] Specifically, this solution relies on the JavaParser tool to automatically parse and analyze the historical source code of the first interface. This step can be completed automatically:

[0098] Parse the input parameters, return values ​​(output parameters), and method body implementation of the API interface; because the Class types of the input parameters and return values ​​may have inheritance types and nested types, the logic code in the current method body may call the logic interface class and the specific implementation class. It is necessary to use the JavaParser tool to parse all the Class types that the API interface of the old interface source code depends on. This process requires recursively traversing the abstract syntax tree to obtain the Class type of the current API interface, the Class type that has inheritance and nested relationships with the input parameter and return value classes, and finally obtain the Java source code information of all the Class types that need to be migrated, as well as the dependencies between these Class types.

[0099] By parsing the first interface source code, it can be ensured that the Class types contained in the historical source code and the dependencies between the Class types can be properly parsed and used for subsequent migration to the new version code.

[0100] Here, the dependencies of the Class type include inheritance and nesting. In Java, references between Class types are completed through import statements. The import type path includes the type name of the Class and the package path name. After migrating the Class type, the package path or type name of the new Class type will change, so the import statement of the migrated Class type needs to be updated accordingly. By traversing the parsed AST tree through the JavaParser tool, Class types including output parameters, input parameters, method bodies, and dependencies between Class types can be generated.

[0101] Step S05: Upgrade the Class type file of the first interface and the dependency relationship between the Class type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the Class type file of the second interface and the Class type file of the second interface.

[0102] Step S051, converting the dependency relationship between the Class type files of the first interface into a topological sorting of the Class type files in the abstract syntax tree;

[0103] updating the file names of the Class type files in the abstract syntax tree according to the mapping relationship between the first interface and the second interface and in accordance with the topological sorting of the Class type files in the abstract syntax tree;

[0104] Get the dependency relationship between the second interface Class type files.

[0105] Specifically, the upgrade of Class type dependencies can be converted into a topological sorting problem of Class types in the AST tree.

[0106] like Figure 3 As shown, the topological sorting of the generated Class types is input type -> nested type 1 -> inherited type 1 -> nested type 2 -> inherited type 2; generating all parsed Class types in the reverse order of the topological sorting ensures that all Class types before the upgrade are generated during the generation process.

[0107] After the new version of the Class type is generated, the dependent type name in the import statement of the Class type needs to be replaced with the updated type name. In this solution, the update of the Class type dependency relationship can find the new Class type name of the dependent class through the name of the old Class type of the dependent type saved during the parsing process, and automatically complete the replacement.

[0108] For example, when generating nested type 2, inheritance type 2 has already generated a new inheritance type 2. The reference path of nested type 2 can be replaced with the new inheritance type 2. The new class type name and the old class type name are saved in the mapping relationship between the first interface and the second interface, which is used to subsequently update the import statement used to define the class type dependency.

[0109] For example: There is an import statement in the Class type definition of com.yueyue.abDemoVO: importcom.yueyue.abDemo. The mapping relationship between com.yueyue.abDemo and com.yueyue.abv2.Demo is maintained in the mapping relationship between the first interface and the second interface. After finding the mapping relationship, the Class type path can be upgraded to import com.yueyue.abv2.Demo.

[0110] Step S052: determining whether the parameter types of the Class type file of the first interface and the Class type file of the second interface are consistent;

[0111] If so, the fields of the Class type file of the first interface are recursively mapped according to the mapping relationship between the first interface and the second interface to obtain the Class type file of the second interface; if not, the fields of the Class type file of the first interface are manually mapped and encoded according to the mapping relationship between the first interface and the second interface.

[0112] Specifically, the adaptation work can be completed automatically:

[0113] Through the mapping relationship between the first interface and the second interface, find the call of the old RPC interface in the parsed old version API interface and replace it with the call logic of the new RPC interface. The replacement steps are as follows:

[0114] The replacement logic is divided into the mapping logic of API interface input and output parameters, and input and return parameters to the rpc interface. The Class types that need to be mapped are divided into basic types and reference types. For basic types (int, short, etc.), they include the packaging types of basic types (Integer, Short, etc.) and collection types of basic types (List, Map). As long as the names and types of the input and output parameters of the old API interface and RPC interface are consistent with the names and types of the input and output parameters of the new API interface and RPC interface, the mapping of parameters with the same name and type can be completed automatically. For nested Class types and inherited Class types in Class types, the mapping can be completed automatically. Inheriting Class type, you can follow the above steps to recursively complete the field mapping of nested Class types and inherited Class types of the new and old interfaces; the existing technology for this step can usually only generate field mapping code for a single Class type and inherited Class type, and cannot recursively process the field mapping of nested Class types; through this script, the field attributes of the new API interface input and output parameters and the RPC interface input and output parameters can be generated completely automatically; R&D personnel only need to handle special cases where the field names and types of the new and old input and output parameters are inconsistent, which can reduce the repetitive manual processing of mapping coding work.

[0115] Step S06: Verify the Class type file of the second interface and the dependency relationship between the Class type files of the second interface.

[0116] Specifically, the remaining adaptation work includes common processing logic such as parameter verification and error code processing. Through the post-code generation step, the parameter verification and error code processing execution logic can be added to the entry method body of the API interface implementation class; this part of the work originally required developers to locate the parameter verification and error code processing logic of the old interface, and manually transform it into the upgraded logic; the AST tree obtained by parsing with the JavaParser tool can locate the parameter verification method body and modify the old error code processing logic to the upgraded error code processing logic.

[0117] Step S061: Using a static type checking tool, determine whether the Class type file of the second interface matches the second interface attributes;

[0118] If yes, the Class type file of the second interface is verified successfully;

[0119] Determine whether a circular dependency occurs between the Class type files of the second interface;

[0120] If not, the dependency relationship between the second interface Class type files is successfully verified;

[0121] Determining whether the Class type file of the second interface and the dependency relationship between the second interface Class type files comply with the Hypertext Transfer Protocol Application Programming Interface contract;

[0122] If so, the dependency verification process for the Class type file of the second interface and the second interface Class type files is successful.

[0123] Specifically, use static type checking tools to ensure that the second interface Class type and interface definition meet expected properties and detect Class type mismatch issues;

[0124] Ensure that the dependencies between class types are correct to avoid circular dependencies or illegal calls;

[0125] Ensure that the Class type implements all methods of the interface and complies with the API contract;

[0126] By combining static analysis + dependency injection + contract testing, the Class type of the API interface and its dependencies can be effectively verified.

[0127] Step S07: Output the Class type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0128] Specifically, the script will automatically generate a v2 new version folder in the same directory of the original folder structure for the migrated new source code according to the source code output path specified in the input parameters, and save all migrated and adapted Class type files to the corresponding v2 folder; the original manual processing required manual copying of the Class type files of the old source code. Since the source code includes multiple Class type files such as input parameters, output parameters, method body implementation, etc., which may exist in multiple folders, the traditional method requires developers to repeatedly copy multiple source codes from the old folder to the new version folder one by one in the integrated development environment, and then perform adaptation modifications. Here, the upgrade script directly outputs the new version Class type files that can be compiled and run to the new version folder, completely omitting this part of the complicated manual copying work.

[0129] Step S08, in response to manual mapping and encoding of the fields of the Class type file of the first interface according to the mapping relationship between the first interface and the second interface, a TODO item mark is added to the source code of the first interface, and a log of the reasons for manual field mapping of the Class type file of the first interface is recorded.

[0130] Specifically, due to incompatible changes such as parameter name changes, field additions, and deletions, the script will add code todo-marked notes at code locations that require manual processing; developers need to locate the TODO-marked items and confirm the reasons for the Class type field changes with the RPC interface provider, and manually complete the field mapping of this part of the Class type based on the communication results.

[0131] like Figure 4 As shown, the present application receives an instruction to upgrade the first interface; obtains the source code of the first interface; obtains the mapping relationship between the first interface and the second interface; parses the source code of the first interface through the JavaParser tool to obtain the dependency relationship between the first interface Class type file and the first interface Class type file; upgrades the dependency relationship between the first interface Class type file and the first interface Class type file according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the second interface Class type file and the second interface Class type file; verifies the dependency relationship between the second interface Class type file and the second interface Class type file; and outputs the second interface Class type file that has passed the verification process according to the code storage path of the second interface. The present application can improve the situation where the interface upgrade is inefficient and prone to upgrade omissions and errors, thereby improving the interface upgrade efficiency.

[0132] The interface upgrade method provided in the embodiment of the present application can also be improved and optimized without departing from the technical solution of the present application, and these improvements and optimizations should also be regarded as the scope of protection of the present application.

[0133] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0134] This application can improve the situation where interface upgrade efficiency is low and upgrade omissions and errors are prone to occur, thereby improving the interface upgrade efficiency.

[0135] The upgrade and transformation efficiency of the http protocol interface of the technical solution provided in the embodiment of the present application is improved from 10-20 minutes / interface to 1-2 minutes / interface, and the interface development efficiency is significantly improved.

[0136] Example 3

[0137] This application provides an interface upgrade device, such as Figure 5 As shown, the device includes: a receiving module, a creating module, an acquiring module, a parsing module, an upgrading module, a checking module, an output module, and a post-processing module.

[0138] In this embodiment, the receiving module is configured to receive an instruction to upgrade the first interface;

[0139] An acquisition module, configured to acquire the source code of the first interface; and acquire a mapping relationship between the first interface and the second interface;

[0140] A parsing module, configured to parse the source code of the first interface using a JavaParser tool to obtain first interface Class type files and dependency relationships between first interface Class type files;

[0141] An upgrading module, configured to upgrade the Class type file of the first interface and the dependency relationship between the Class type file of the first interface according to the mapping relationship between the first interface and the second interface, and obtain the dependency relationship between the Class type file of the second interface and the Class type file of the second interface;

[0142] A verification module, configured to verify the Class type file of the second interface and the dependency relationship between the Class type files of the second interface;

[0143] The output module is used to output the Class type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0144] In this embodiment, the parsing module is used to create an abstract syntax tree according to the source code of the first interface;

[0145] Recursively traverse the abstract syntax tree using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0146] The first interface Class type file includes input parameter type, output parameter type and method body execution logic type;

[0147] The dependency relationship between the first interface Class type files is the dependency relationship between the input parameter type and the output parameter type of the first interface.

[0148] In one embodiment, the upgrade module is used to convert the dependency relationship between the Class type files of the first interface into a topological sorting of the Class type files in the abstract syntax tree;

[0149] updating the file names of the Class type files in the abstract syntax tree according to the mapping relationship between the first interface and the second interface and in accordance with the topological sorting of the Class type files in the abstract syntax tree;

[0150] Get the dependency relationship between the second interface Class type files.

[0151] In one embodiment, the upgrade module is used to determine whether the parameter types of the Class type file of the first interface and the Class type file of the second interface are consistent;

[0152] If so, the fields of the Class type file of the first interface are recursively mapped according to the mapping relationship between the first interface and the second interface to obtain the Class type file of the second interface; if not, the fields of the Class type file of the first interface are manually mapped and encoded according to the mapping relationship between the first interface and the second interface.

[0153] In one embodiment, the verification module is used to determine whether the Class type file of the second interface matches the second interface attribute through a static type checking tool;

[0154] If yes, the Class type file of the second interface is verified successfully;

[0155] Determine whether a circular dependency occurs between the Class type files of the second interface;

[0156] If not, the dependency relationship between the second interface Class type files is successfully verified;

[0157] Determining whether the Class type file of the second interface and the dependency relationship between the second interface Class type files comply with the Hypertext Transfer Protocol Application Programming Interface contract;

[0158] If so, the dependency verification process for the Class type file of the second interface and the second interface Class type files is successful.

[0159] In one embodiment, the post-processing module is used to add a TODO item mark in the source code of the first interface in response to manual mapping and encoding of the fields of the Class type file of the first interface according to the mapping relationship between the first interface and the second interface, and record a log of the reasons for manually mapping the fields of the Class type file of the first interface.

[0160] In one embodiment, a module is created to create a mapping relationship between the first interface and the second interface according to the Class type file name and code storage path of the first interface and the second interface.

[0161] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0162] This application can improve the situation where interface upgrade efficiency is low and upgrade omissions and errors are prone to occur, thereby improving the interface upgrade efficiency.

[0163] The upgrade and transformation efficiency of the http protocol interface of the technical solution provided in the embodiment of the present application is improved from 10-20 minutes / interface to 1-2 minutes / interface, and the interface development efficiency is significantly improved.

[0164] Example 4

[0165] The present invention also provides an interface upgrading device, comprising:

[0166] one or more processors;

[0167] a storage device for storing one or more programs;

[0168] When the one or more programs are executed by the one or more processors, the one or more processors execute the following interface upgrade method:

[0169] receiving an instruction to upgrade the first interface;

[0170] Obtaining source code of the first interface; obtaining a mapping relationship between the first interface and the second interface;

[0171] Parsing the source code of the first interface by using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0172] Updating the dependency relationship between the Class type file of the first interface and the Class type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the Class type file of the second interface and the Class type file of the second interface;

[0173] Verifying the Class type file of the second interface and the dependency relationship between the Class type files of the second interface;

[0174] Output the Class type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0175] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0176] This application can improve the situation where interface upgrade efficiency is low and upgrade omissions and errors are prone to occur, thereby improving the interface upgrade efficiency.

[0177] The upgrade and transformation efficiency of the http protocol interface of the technical solution provided in the embodiment of the present application is improved from 10-20 minutes / interface to 1-2 minutes / interface, and the interface development efficiency is significantly improved.

[0178] Example 5

[0179] The present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following interface upgrade method can be performed:

[0180] receiving an instruction to upgrade the first interface;

[0181] Obtaining source code of the first interface; obtaining a mapping relationship between the first interface and the second interface;

[0182] Parsing the source code of the first interface by using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0183] Updating the dependency relationship between the Class type file of the first interface and the Class type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the Class type file of the second interface and the Class type file of the second interface;

[0184] Verifying the Class type file of the second interface and the dependency relationship between the Class type files of the second interface;

[0185] Output the Class type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0186] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0187] This application can improve the situation where interface upgrade efficiency is low and upgrade omissions and errors are prone to occur, thereby improving the interface upgrade efficiency.

[0188] The upgrade and transformation efficiency of the http protocol interface of the technical solution provided in the embodiment of the present application is improved from 10-20 minutes / interface to 1-2 minutes / interface, and the interface development efficiency is significantly improved.

[0189] Example 6

[0190] The present application also provides a computer program product, including a computer program, which, when executed by a processor, can implement the following interface upgrade method:

[0191] receiving an instruction to upgrade the first interface;

[0192] Obtaining source code of the first interface; obtaining a mapping relationship between the first interface and the second interface;

[0193] Parsing the source code of the first interface by using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0194] Updating the dependency relationship between the Class type file of the first interface and the Class type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the Class type file of the second interface and the Class type file of the second interface;

[0195] Verifying the Class type file of the second interface and the dependency relationship between the Class type files of the second interface;

[0196] Output the Class type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0197] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0198] This application can improve the situation where interface upgrade efficiency is low and upgrade omissions and errors are prone to occur, thereby improving the interface upgrade efficiency.

[0199] The upgrade and transformation efficiency of the http protocol interface of the technical solution provided in the embodiment of the present application is improved from 10-20 minutes / interface to 1-2 minutes / interface, and the interface development efficiency is significantly improved.

[0200] Example 7

[0201] The present application provides a computer storage medium, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:

[0202] receiving an instruction to upgrade the first interface;

[0203] Obtaining source code of the first interface; obtaining a mapping relationship between the first interface and the second interface;

[0204] Parsing the source code of the first interface by using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0205] Updating the dependency relationship between the Class type file of the first interface and the Class type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the Class type file of the second interface and the Class type file of the second interface;

[0206] Verifying the Class type file of the second interface and the dependency relationship between the Class type files of the second interface;

[0207] Output the Class type file of the second interface that has passed the verification process according to the code storage path of the second interface.

[0208] In one embodiment, the parsing of the source code of the first interface by a JavaParser tool to obtain the first interface Class type file and the dependency relationship between the first interface Class type files includes:

[0209] Creating an abstract syntax tree according to the source code of the first interface;

[0210] Recursively traverse the abstract syntax tree using a JavaParser tool to obtain a first interface Class type file and a dependency relationship between the first interface Class type files;

[0211] The first interface Class type file includes input parameter type, output parameter type and method body execution logic type;

[0212] The dependency relationship between the first interface Class type files is the dependency relationship between the input parameter type and the output parameter type of the first interface.

[0213] In one embodiment, the updating of the dependency relationship between the first interface Class type files according to the mapping relationship between the first interface and the second interface includes:

[0214] Converting the dependency relationship between the Class type files of the first interface into a topological sort of the Class type files in the abstract syntax tree;

[0215] updating the file names of the Class type files in the abstract syntax tree according to the mapping relationship between the first interface and the second interface and in accordance with the topological sorting of the Class type files in the abstract syntax tree;

[0216] Get the dependency relationship between the second interface Class type files.

[0217] In one embodiment, the updating of the Class type file of the first interface according to the mapping relationship between the first interface and the second interface includes:

[0218] Determine whether the parameter types of the Class type file of the first interface and the Class type file of the second interface are consistent;

[0219] If so, the fields of the Class type file of the first interface are recursively mapped according to the mapping relationship between the first interface and the second interface to obtain the Class type file of the second interface; if not, the fields of the Class type file of the first interface are manually mapped and encoded according to the mapping relationship between the first interface and the second interface.

[0220] In one embodiment, the verifying of the Class type file of the second interface and the dependency relationship between the Class type files of the second interface includes:

[0221] Determine, by a static type checking tool, whether the Class type file of the second interface matches the second interface attributes;

[0222] If yes, the Class type file of the second interface is verified successfully;

[0223] Determine whether a circular dependency occurs between the Class type files of the second interface;

[0224] If not, the dependency relationship between the second interface Class type files is successfully verified;

[0225] Determining whether the Class type file of the second interface and the dependency relationship between the second interface Class type files comply with the Hypertext Transfer Protocol Application Programming Interface contract;

[0226] If so, the dependency verification process for the Class type file of the second interface and the second interface Class type files is successful.

[0227] In one embodiment, the method comprises:

[0228] In response to manually mapping and encoding the fields of the Class type file of the first interface according to the mapping relationship between the first interface and the second interface, a TODO item mark is added to the source code of the first interface, and a log of the reasons for manually mapping the fields of the Class type file of the first interface is recorded.

[0229] In one embodiment, before obtaining the source code of the first interface and obtaining the mapping relationship between the first interface and the second interface, the steps include:

[0230] A mapping relationship between the first interface and the second interface is created according to the Class type file name and code storage path of the first interface and the second interface.

[0231] This application can improve the situation where interface upgrade efficiency is low and upgrade omissions and errors are prone to occur, thereby improving the interface upgrade efficiency.

[0232] Figure 6 The exemplary system provided in the seventh embodiment of the present application can be used to implement the various embodiments described in the present application;

[0233] like Figure 6 As shown, in some embodiments, the system can be used as the above-mentioned device for interface upgrade in any of the above-mentioned embodiments. In some embodiments, the system may include one or more computer-readable media (e.g., system memory or NVM / storage device) having results and one or more processors (e.g., (one or more) processors) coupled to the one or more computer-readable media and configured to execute the results to implement the module to perform the actions described in this application.

[0234] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0235] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0236] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. An interface upgrade method, characterized in that: The method comprises: receiving an instruction to upgrade the first interface; Obtaining source code of the first interface; obtaining a mapping relationship between the first interface and the second interface; Parsing the source code of the first interface by using an open source library tool to obtain first interface code classification type files and dependency relationships between the first interface code classification type files; Updating the dependency relationship between the code classification type file of the first interface and the code classification type file of the first interface according to the mapping relationship between the first interface and the second interface to obtain the dependency relationship between the code classification type file of the second interface and the code classification type file of the second interface; Verifying the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface; The code classification type file of the second interface that has passed the verification process is output according to the code storage path of the second interface.

2. The interface upgrade method according to claim 1, characterized in that: The method of parsing the source code of the first interface by using an open source library tool to obtain first interface code classification type files and dependency relationships between first interface code classification type files includes: Creating an abstract syntax tree according to the source code of the first interface; Recursively traverse the abstract syntax tree using a Java open source library tool to obtain first interface code classification type files and dependency relationships between first interface code classification type files; Wherein, the first interface code classification type file includes input parameter type, output parameter type and method body execution logic type; The dependency relationship between the first interface code classification type files is the dependency relationship between the input parameter type and the output parameter type of the first interface.

3. The interface upgrade method according to claim 2, characterized in that: The step of upgrading the dependency relationship between the first interface code classification type files according to the mapping relationship between the first interface and the second interface includes: Converting the dependency relationship between the first interface code classification type files into a topological sort of the code classification type files in the abstract syntax tree; updating the file names of the code classification type files in the abstract syntax tree according to the mapping relationship between the first interface and the second interface and in accordance with the topological sorting of the code classification type files in the abstract syntax tree; Obtain the dependency relationship between the second interface code classification type files.

4. The interface upgrade method according to claim 1, characterized in that: The upgrading of the code classification type file of the first interface according to the mapping relationship between the first interface and the second interface includes: Determine whether parameter types of the code classification type file of the first interface and the code classification type file of the second interface are consistent; If so, the fields of the code classification type file of the first interface are recursively mapped according to the mapping relationship between the first interface and the second interface to obtain the code classification type file of the second interface; if not, the fields of the code classification type file of the first interface are manually mapped and encoded according to the mapping relationship between the first interface and the second interface.

5. The interface upgrade method according to claim 1, characterized in that: The verifying process of the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface includes: Determine, by a static type checking tool, whether the code classification type file of the second interface matches the second interface attribute; If so, the code classification type file verification of the second interface is successful; Determining whether a circular dependency occurs between the code classification type files of the second interface; If not, the dependency relationship between the second interface code classification type files is successfully verified; determining whether the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface comply with the Hypertext Transfer Protocol Application Programming Interface contract; If so, the dependency verification process for the second interface code classification type file and the second interface code classification type files is successful.

6. The interface upgrade method according to claim 4, characterized in that: The method comprises: In response to manual mapping and encoding of the fields of the code classification type file of the first interface based on the mapping relationship between the first interface and the second interface, a repair item mark is added to the source code of the first interface, and a log of the reasons for manual field mapping of the code classification type file of the first interface is recorded.

7. The interface upgrade method according to claim 1, characterized in that: said obtaining source code of said first interface; Before obtaining the mapping relationship between the first interface and the second interface, the following steps are included: A mapping relationship between the first interface and the second interface is created according to the code classification type file name and the code storage path of the first interface and the second interface.

8. An interface upgrade device, characterized in that: The device comprises: A receiving module, configured to receive an instruction to upgrade the first interface; An acquisition module, configured to acquire the source code of the first interface; and acquire a mapping relationship between the first interface and the second interface; A parsing module, configured to parse the source code of the first interface using an open source library tool to obtain first interface code classification type files and dependency relationships between first interface code classification type files; An upgrade module, configured to upgrade the code classification type file of the first interface and the dependency relationship between the code classification type file of the first interface according to the mapping relationship between the first interface and the second interface, and obtain the code classification type file of the second interface and the dependency relationship between the code classification type file of the second interface; A verification module, configured to verify the code classification type file of the second interface and the dependency relationship between the code classification type files of the second interface; The output module is used to output the code classification type file of the second interface that has passed the verification process according to the code storage path of the second interface.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the interface upgrading method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the interface upgrading method according to any one of claims 1 to 7 are implemented.