Processing method and device for checking service interface calling information
By combining language parsing tools to build an automated batch process, the problem of inefficient information calling by manual verification of service interfaces is solved, and efficient and accurate service interface upgrade verification is achieved.
Patent Information
- Application Number
- CN202411887320.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-04
AI Technical Summary
In application projects based on microservice architecture, manual verification of service interface call information is inefficient, especially when the amount of code is large, it is difficult to ensure the accuracy and efficiency of verification.
Combining language parsing tools, a batch process is built for automatically verifying service interface call information. Configure the interface list through the preset service interface design specification, receive batch source code files, use the corresponding source code parsing tool to parse the service interface call information, conduct correctness verification, and generate verification reports.
Automatic service interface upgrade verification is realized, saving a lot of manual verification work, improving verification efficiency, and ensuring the accuracy of verification.
Smart Images

Figure CN119759361A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a processing method and device for verifying service interface call information. Background Art
[0002] In application projects based on microservice architecture, there will be a large amount of service interface call information in the source code text of the project. In some specific situations (such as adding or reducing service interface functions, switching service deployment addresses, etc.), such application projects will upgrade some or all service interfaces. Each service interface upgrade operation actually organizes engineers to adjust the service interface call information in some or all source code texts in the project based on the latest service interface design specifications. This upgrade process is completed through manual updates, and it is inevitable that omissions or errors will occur. Therefore, after completing the code update, engineers will be organized to conduct a round of manual verification of all service interface call information in all source code texts of the project. However, through practice, we have found that the verification efficiency of this manual verification process is not ideal due to human factors, especially when the amount of code is large, the verification efficiency is very low.
[0003] It is known that there are relatively mature language parsing tools for multiple programming languages (such as Java language, C++ language, Python language, JavaScript language, GO language, etc.) on the market. These language parsing tools are commonly used: Apifox tool and Swagger dedicated to Java language parsing, Clang tool dedicated to C++ language parsing, JMESPath tool and AST parsing tool dedicated to Python language parsing, ESLint tool and DocBlockr tool dedicated to JavaScript language parsing, Go AST parsing tool and Staticcheck tool dedicated to GO language parsing, and Sourcegraph tool, SonarQube tool, Checkmarx tool and SRCINFO tool that support multiple programming languages. These language parsing tools provide rich text parsing interfaces, and the service interface call information on the source code text can be automatically identified by directly using these text parsing interfaces or performing simple secondary programming on the basis of these text parsing interfaces. If a processing tool for automatically checking the service interface call information can be constructed in combination with these language parsing tools, the low efficiency of the current verification caused by the manual verification operation can be naturally solved. And this is exactly the technical problem that the present invention needs to solve. Summary of the invention
[0004] The purpose of the present invention is to provide a processing method, device, electronic device and computer-readable storage medium for verifying service interface call information in view of the defects of the prior art. The present invention configures the corresponding first interface list based on the preset service interface design specification; receives the batch source code files input by the user as the corresponding first batch of code files; and uses each first code file of the first batch of code files as the corresponding current code file, and records the programming language corresponding to the current code file as the current programming language, and records the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool, and parses the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list, and performs correctness verification on the second interface list according to the first interface list to obtain the corresponding first verification report, and the current code file and the corresponding first verification report form a corresponding first verification file package; finally, all the first verification file packages obtained form the corresponding first batch of verification file packages to feedback to the current user. The present invention combines the language parsing tool to construct a batch processing flow for automatic verification of service interface call information; through the present invention, service interface upgrade verification can no longer be performed based on manual methods, a large amount of manual verification workload can be saved, and verification efficiency can be effectively improved.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present invention provides a processing method for verifying service interface call information, the method comprising:
[0006] Configure a corresponding first interface list based on a preset service interface design specification;
[0007] The batch of source code files received from the user are recorded as corresponding first batch of code files; the first batch of code files includes a plurality of first code files;
[0008] Take each of the first code files of the first batch of code files as the corresponding current code file; record the programming language corresponding to the current code file as the current programming language; record the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool; and parse the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list; and perform correctness verification on the second interface list according to the first interface list to obtain the corresponding first verification report; and the current code file and the corresponding first verification report form a corresponding first verification file package;
[0009] All the first verification file packages obtained form a corresponding first batch of verification file packages and feed back to the current user.
[0010] Preferably, the first interface list includes multiple first interface records; each of the first interface records corresponds to a service interface; the first interface record includes a first interface path, a first interface request method and a first interface parameter sequence; the first interface path is the URL address corresponding to the current service interface; the first interface request method is the HTTP method corresponding to the current service interface; the first interface parameter sequence is formed by sequentially sorting one or more first interface parameters; the first interface parameter corresponds to an interface parameter of the current service interface; the first interface parameter includes a first parameter name, a first optional / mandatory configuration and a first parameter type; the first parameter name is the parameter name corresponding to the current interface parameter; the first optional / mandatory configuration includes two types of configurations, optional parameters and mandatory parameters, and the first optional / mandatory configuration is an optional or mandatory feature of the current interface parameter; the first parameter type is the data type corresponding to the current interface parameter;
[0011] The second interface list includes multiple second interface records; each second interface record corresponds to a parsed service interface call information; the second interface record includes a second interface path, a second interface request method and a second interface parameter sequence; the second interface path is the URL address corresponding to the current service interface call information; the second interface request method is the HTTP method corresponding to the current service interface call information; the second interface parameter sequence is formed by sorting one or more second interface parameters in sequence; the second interface parameter corresponds to an interface parameter of the current service interface call information; the second interface parameter includes a first parameter value and a second parameter type; the second parameter type is the data type corresponding to the current interface parameter; when the first parameter value is empty, the second parameter type is empty, and when the first parameter value is not empty, the second parameter type is not empty;
[0012] The first verification report includes multiple first verification records; the first verification records correspond to the second interface records one by one; the first verification record consists of the corresponding second interface record and a corresponding first verification result; the first verification result includes passed verification, interface path error, interface request method error, parameter quantity error and error parameter name sequence; the error parameter name sequence is formed by one or more error parameter names sorted in sequence.
[0013] Preferably, the programming language includes at least Java, C++, Python, JavaScript and GO;
[0014] The source code parsing tools include at least the Apifox tool and Swagger dedicated to Java language parsing, the Clang tool dedicated to C++ language parsing, the JMESPath tool and AST parsing tool dedicated to Python language parsing, the ESLint tool and DocBlockr tool dedicated to JavaScript language parsing, the Go AST parsing tool and Staticcheck tool dedicated to GO language parsing, as well as the Sourcegraph tool, SonarQube tool, Checkmarx tool, and SRCINFO tool that support multiple programming languages.
[0015] Preferably, the correctness verification of the second interface list according to the first interface list to obtain a corresponding first verification report specifically includes:
[0016] Step 41, taking the first second interface record in the second interface list as the corresponding current interface record;
[0017] Step 42, taking the second interface path, the second interface request method and the second interface parameter sequence of the current interface record as the corresponding current interface path, the current interface request method and the current interface parameter sequence; and taking the first interface record in the first interface list whose first interface path matches the current interface path as the corresponding current reference record;
[0018] Step 43, identifying whether the current reference record is empty; if so, setting the corresponding first verification result as an interface path error, and going to step 48; if not, setting the first interface request method of the current reference record as the corresponding current reference method, and going to step 44;
[0019] Step 44, identifying whether the current reference method matches the current interface request method; if not, setting the corresponding first verification result as an interface request method error, and going to step 48; if matching, taking the first interface parameter sequence of the current reference record as the corresponding current reference parameter sequence, and going to step 45;
[0020] Step 45, counting the total number of the first interface parameters of the current reference parameter sequence to obtain the corresponding total number of reference parameters; and counting the total number of the second interface parameters of the current interface parameter sequence to obtain the corresponding total number of current parameters; and identifying whether the total number of reference parameters is equal to the total number of current parameters; if they are not equal, setting the corresponding first verification result as a parameter quantity error, and going to step 48; if they are equal, going to step 46;
[0021] Step 46, extracting a pair of the first and second interface parameters having the same sequence sorting index in the current reference parameter sequence and the current interface parameter sequence to form a corresponding first parameter group;
[0022] Step 47, perform a round of traversal on all the first parameter groups obtained; and in this round of traversal, use the first parameter group currently traversed as the corresponding current parameter group; and use the first optional / mandatory configuration and the first parameter type of the first interface parameter in the current parameter group as the corresponding reference optional / mandatory configuration and reference parameter type; and use the second parameter type of the second interface parameter in the current parameter group as the corresponding current parameter type; and identify the reference optional / mandatory configuration; if the reference optional / mandatory configuration is a mandatory parameter, identify whether the reference parameter type and the current parameter type match, if they match, set the corresponding first parameter check result to success, if not, set the corresponding first parameter check result to failure; if the reference optional / mandatory configuration is an optional parameter, set the corresponding first parameter type when the current parameter type is empty. A parameter check result is successful, and when the current parameter type is not empty and the reference parameter type matches the current parameter type, the corresponding first parameter check result is set to success, and when the current parameter type is not empty and the reference parameter type does not match the current parameter type, the corresponding first parameter check result is set to failure; and when the first parameter check result corresponding to the current parameter group is failure, a corresponding error parameter name is set to the first parameter name of the first interface parameter of the current parameter group; and at the end of this round of traversal, all the error parameter names obtained by this round of traversal are sequentially sorted to form a corresponding error parameter name sequence; and whether the obtained error parameter name sequence is empty is identified, and if so, the corresponding first verification result is set to pass the verification, otherwise, the corresponding first verification result is set to the corresponding error parameter name sequence;
[0023] Step 48, forming a corresponding first verification record by the current interface record and the corresponding first verification result;
[0024] Step 49, identify whether the current interface record is the last second interface record in the second interface list; if not, extract the next second interface record in the second interface list as the new current interface record, and return to step 42; if so, all the first verification records obtained constitute the corresponding first verification report.
[0025] The second aspect of the embodiment of the present invention provides a device for implementing the processing method for verifying the service interface call information described in the first aspect, the device comprising: a preprocessing module, a batch file receiving module, a service interface call information verification module and a batch result feedback module;
[0026] The preprocessing module is used to configure the corresponding first interface list based on the preset service interface design specification;
[0027] The batch file receiving module is used to receive batch source code files input by the user and record them as corresponding first batch code files; the first batch code files include multiple first code files;
[0028] The service interface call information verification module is used to take each of the first code files of the first batch of code files as the corresponding current code file; and record the programming language corresponding to the current code file as the current programming language; and record the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool; and parse the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list; and perform correctness verification on the second interface list according to the first interface list to obtain the corresponding first verification report; and the current code file and the corresponding first verification report form a corresponding first verification file package;
[0029] The batch processing result feedback module is used for feeding back to the current user a first batch of verification file packages composed of all the first verification file packages obtained.
[0030] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;
[0031] The processor is used to couple with the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;
[0032] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
[0033] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.
[0034] The embodiment of the present invention provides a processing method, device, electronic device and computer-readable storage medium for verifying service interface call information. As can be seen from the above content, the embodiment of the present invention configures the corresponding first interface list based on the preset service interface design specification; receives the batch source code files input by the user as the corresponding first batch of code files; and uses each first code file of the first batch of code files as the corresponding current code file, and records the programming language corresponding to the current code file as the current programming language, and records the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool, and parses the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list, and verifies the correctness of the second interface list according to the first interface list to obtain the corresponding first verification report, and the current code file and the corresponding first verification report form a corresponding first verification file package; finally, all the first verification file packages obtained form the corresponding first batch of verification file packages to feedback to the current user. The embodiment of the present invention combines the language parsing tool to construct a batch processing flow for automatic verification of service interface call information; through the embodiment of the present invention, the service interface upgrade verification can no longer be performed based on manual methods, saving a lot of manual verification workload and improving verification efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of a processing method for verifying service interface call information provided in Embodiment 1 of the present invention;
[0036] Figure 2 A module structure diagram of a processing device for checking service interface call information provided in Embodiment 2 of the present invention;
[0037] Figure 3 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] Embodiment 1 of the present invention provides a processing method for verifying service interface call information, such as Figure 1 As shown in the schematic diagram of a processing method for verifying service interface call information provided by the first embodiment of the present invention, the method mainly includes the following steps:
[0040] Step 1: configure the corresponding first interface list based on the preset service interface design specification.
[0041] Here, the service interface design specification of the embodiment of the present invention is a service interface design specification of a specified version.
[0042] The first interface list of the embodiment of the present invention includes multiple first interface records; each first interface record corresponds to a service interface; the first interface record includes a first interface path, a first interface request method and a first interface parameter sequence; the first interface path is the URL address corresponding to the current service interface; the first interface request method is the HTTP method corresponding to the current service interface, such as GET method, POST method, PUT method, DELETE method, HEAD method, OPTIONS method, CONNECT method, TRACE method, etc.; the first interface parameter sequence is formed by sequentially sorting one or more first interface parameters; the first interface parameter corresponds to an interface parameter of the current service interface; the first interface parameter includes a first parameter name, a first optional / mandatory configuration and a first parameter type; the first parameter name is the parameter name corresponding to the current interface parameter; the first optional / mandatory configuration includes two types of configurations, optional parameters and mandatory parameters, and the first optional / mandatory configuration is an optional or mandatory feature of the current interface parameter; the first parameter type is the data type corresponding to the current interface parameter, such as a structure type, a handle type, an object type, a pointer type, an integer type, a floating point type, a date type, a string type, a Boolean data type, etc.
[0043] Step 2: receiving batches of source code files input by the user and recording them as the corresponding first batch of code files.
[0044] Here, the first batch of code files in the embodiment of the present invention includes one or more first code files, each of which corresponds to a programming language. The programming language in the embodiment of the present invention includes at least Java, C++, Python, JavaScript, GO, etc.
[0045] Step 3, taking each first code file of the first batch of code files as the corresponding current code file; recording the programming language corresponding to the current code file as the current programming language; recording the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool; and parsing the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list; and checking the correctness of the second interface list according to the first interface list to obtain the corresponding first verification report; and the current code file and the corresponding first verification report form a corresponding first verification file package;
[0046] Specifically, it includes: step 31, taking each first code file of the first batch of code files as the corresponding current code file;
[0047] Step 32, and record the programming language corresponding to the current code file as the current programming language;
[0048] Step 33, and record the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool;
[0049] Here, the source code parsing tool of the embodiment of the present invention includes at least an Apifox tool and Swagger dedicated to Java language parsing, a Clang tool dedicated to C++ language parsing, a JMESPath tool and an AST parsing tool dedicated to Python language parsing, an ESLint tool and a DocBlockr tool dedicated to JavaScript language parsing, a GoAST parsing tool and a Staticcheck tool dedicated to GO language parsing, and a Sourcegraph tool, a SonarQube tool, a Checkmarx tool, and a SRCINFO tool that support multiple programming languages;
[0050] Step 34, parsing the service interface call information of the current code file based on the current parsing tool to obtain a corresponding second interface list;
[0051] Here, the second interface list of the embodiment of the present invention includes multiple second interface records; each second interface record corresponds to a parsed service interface call information; the second interface record includes a second interface path, a second interface request method and a second interface parameter sequence; the second interface path is the URL address corresponding to the current service interface call information; the second interface request method is the HTTP method corresponding to the current service interface call information; the second interface parameter sequence is formed by sequentially sorting one or more second interface parameters; the second interface parameter corresponds to an interface parameter of the current service interface call information; the second interface parameter includes a first parameter value and a second parameter type; the second parameter type is the data type corresponding to the current interface parameter; when the first parameter value is empty, the second parameter type is empty, and when the first parameter value is not empty, the second parameter type is not empty;
[0052] Step 35, verifying the correctness of the second interface list according to the first interface list to obtain a corresponding first verification report;
[0053] The first verification report includes a plurality of first verification records; the first verification records correspond to the second interface records one by one; the first verification record is composed of the corresponding second interface record and a corresponding first verification result; the first verification result includes passed verification, interface path error, interface request method error, parameter quantity error and error parameter name sequence; the error parameter name sequence is formed by sequentially sorting one or more error parameter names;
[0054] Specifically, it includes: step 351, taking the first second interface record in the second interface list as the corresponding current interface record;
[0055] Step 352, taking the second interface path, the second interface request method and the second interface parameter sequence of the current interface record as the corresponding current interface path, the current interface request method and the current interface parameter sequence; and taking the first interface record in the first interface list whose first interface path matches the current interface path as the corresponding current reference record;
[0056] Step 353, identifying whether the current reference record is empty; if so, setting the corresponding first verification result as an interface path error, and going to step 358; if not, setting the first interface request method of the current reference record as the corresponding current reference method, and going to step 354;
[0057] Step 354, identifying whether the current reference method matches the current interface request method; if not, setting the corresponding first verification result as an interface request method error, and going to step 358; if matching, taking the first interface parameter sequence of the current reference record as the corresponding current reference parameter sequence, and going to step 355;
[0058] Step 355, the total number of the first interface parameters of the current reference parameter sequence is counted to obtain the corresponding total number of reference parameters; and the total number of the second interface parameters of the current interface parameter sequence is counted to obtain the corresponding total number of current parameters; and whether the total number of reference parameters is equal to the total number of current parameters is identified; if they are not equal, the corresponding first verification result is set as a parameter quantity error, and the process goes to step 358; if they are equal, the process goes to step 356;
[0059] Step 356, extracting a pair of first and second interface parameters with the same sequence sorting index in the current reference parameter sequence and the current interface parameter sequence to form a corresponding first parameter group;
[0060] Step 357, perform a round of traversal for all the first parameter groups obtained; and in this round of traversal, use the currently traversed first parameter group as the corresponding current parameter group; use the first optional / mandatory configuration and the first parameter type of the first interface parameter in the current parameter group as the corresponding reference optional / mandatory configuration and reference parameter type; use the second parameter type of the second interface parameter in the current parameter group as the corresponding current parameter type; and identify the reference optional / mandatory configuration; if the reference optional / mandatory configuration is a mandatory parameter, identify whether the reference parameter type and the current parameter type match, if they match, set the corresponding first parameter check result to success, if not, set the corresponding first parameter check result to failure; if the reference optional / mandatory configuration is an optional parameter, set The corresponding first parameter check result is success, and when the current parameter type is not empty and the reference parameter type matches the current parameter type, the corresponding first parameter check result is set to success, and when the current parameter type is not empty and the reference parameter type does not match the current parameter type, the corresponding first parameter check result is set to failure; and when the first parameter check result corresponding to the current parameter group is failure, a corresponding error parameter name is set to the first parameter name of the first interface parameter of the current parameter group; and at the end of this round of traversal, all error parameter names obtained by this round of traversal are sorted in order to form a corresponding error parameter name sequence; and whether the obtained error parameter name sequence is empty is identified, and if so, the corresponding first verification result is set to pass the verification, otherwise, the corresponding first verification result is set to the corresponding error parameter name sequence;
[0061] Step 358, forming a corresponding first verification record by the current interface record and the corresponding first verification result;
[0062] Step 359, identifying whether the current interface record is the last second interface record in the second interface list; if not, extracting the next second interface record in the second interface list as the new current interface record, and returning to step 352; if so, composing a corresponding first verification report by all the obtained first verification records;
[0063] Step 36: The current code file and the corresponding first verification report form a corresponding first verification file package.
[0064] Step 4: All the first verification file packages obtained form the corresponding first verification file packages and feed them back to the current user.
[0065] Figure 2A module structure diagram of a processing device for checking service interface call information provided in the second embodiment of the present invention, the device is a terminal device or server that implements the aforementioned method embodiment, and can also be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment, for example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 2 As shown, the device includes: a pre-processing module 201, a batch file receiving module 202, a service interface call information checking module 203 and a batch result feedback module 204.
[0066] The pre-processing module 201 is used to configure the corresponding first interface list based on a preset service interface design specification.
[0067] The batch file receiving module 202 is used to receive batch source code files input by the user and record them as the corresponding first batch of code files; the first batch of code files includes multiple first code files.
[0068] The service interface call information verification module 203 is used to take each first code file of the first batch of code files as the corresponding current code file; and record the programming language corresponding to the current code file as the current programming language; and record the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool; and based on the current parsing tool, parse the service interface call information of the current code file to obtain the corresponding second interface list; and verify the correctness of the second interface list according to the first interface list to obtain the corresponding first verification report; and the current code file and the corresponding first verification report constitute a corresponding first verification file package.
[0069] The batch processing result feedback module 204 is used to feedback the first batch of verification file packages composed of all the obtained first verification file packages to the current user.
[0070] An embodiment of the present invention provides a processing device for verifying service interface call information, which can execute the method steps in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0071] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the service interface call information verification module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above determination module. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in software form.
[0072] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital signal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0073] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the above method embodiments are generated. The above computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) methods. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, a hard disk, a tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0074] Figure 3 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. The electronic device may be a terminal device or a server for implementing the method of the aforementioned embodiment, or may be a terminal device or a server for implementing the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 3 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303. Various instructions may be stored in the memory 302 to complete various processing functions and implement the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention also includes: a power supply 304, a system bus 305 and a communication port 306. The system bus 305 is used to realize the communication connection between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.
[0075] exist Figure 3The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize the communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM), and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.
[0076] The above-mentioned processor can be a general-purpose processor, including a central processing unit CPU, a network processor (Network Processor, NP), a graphics processing unit (Graphics Processing Unit, GPU), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0077] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the method and processing process provided in the above embodiments.
[0078] The embodiment of the present invention provides a processing method, device, electronic device and computer-readable storage medium for verifying service interface call information. As can be seen from the above content, the embodiment of the present invention configures the corresponding first interface list based on the preset service interface design specification; receives the batch source code files input by the user as the corresponding first batch of code files; and uses each first code file of the first batch of code files as the corresponding current code file, and records the programming language corresponding to the current code file as the current programming language, and records the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool, and parses the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list, and verifies the correctness of the second interface list according to the first interface list to obtain the corresponding first verification report, and the current code file and the corresponding first verification report form a corresponding first verification file package; finally, all the first verification file packages obtained form the corresponding first batch of verification file packages to feedback to the current user. The embodiment of the present invention combines the language parsing tool to construct a batch processing flow for automatic verification of service interface call information; through the embodiment of the present invention, the service interface upgrade verification can no longer be performed based on manual methods, saving a lot of manual verification workload and improving verification efficiency.
[0079] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0080] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for checking service interface call information, characterized in that: The method comprises: Configure a corresponding first interface list based on a preset service interface design specification; The batch of source code files received from the user are recorded as corresponding first batch of code files; the first batch of code files includes a plurality of first code files; Take each of the first code files of the first batch of code files as the corresponding current code file; record the programming language corresponding to the current code file as the current programming language; record the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool; and parse the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list; and perform correctness verification on the second interface list according to the first interface list to obtain the corresponding first verification report; and the current code file and the corresponding first verification report form a corresponding first verification file package; All the first verification file packages obtained form a corresponding first batch of verification file packages and feed back to the current user.
2. The method for verifying service interface call information according to claim 1, characterized in that: The first interface list includes a plurality of first interface records; each of the first interface records corresponds to a service interface; the first interface record includes a first interface path, a first interface request method and a first interface parameter sequence; The first interface path is the URL address corresponding to the current service interface; the first interface request method is the HTTP method corresponding to the current service interface; The first interface parameter sequence is formed by sequentially sorting one or more first interface parameters; the first interface parameter corresponds to an interface parameter of the current service interface; the first interface parameter includes a first parameter name, a first optional / mandatory configuration and a first parameter type; The first parameter name is the parameter name corresponding to the current interface parameter; the first optional / mandatory configuration includes two types of configurations: optional parameters and mandatory parameters. The first optional / mandatory configuration is an optional or mandatory feature of the current interface parameter; The first parameter type is the data type corresponding to the current interface formal parameter; The second interface list includes a plurality of second interface records; each of the second interface records corresponds to a parsed service interface call information; The second interface record includes a second interface path, a second interface request method, and a second interface parameter sequence; the second interface path is a URL address corresponding to the current service interface call information; the second interface request method is an HTTP method corresponding to the current service interface call information; the second interface parameter sequence is formed by sequentially sorting one or more second interface parameters; the second interface parameter corresponds to an interface parameter of the current service interface call information; the second interface parameter includes a first parameter value and a second parameter type; The second parameter type is the data type corresponding to the current interface parameter; When the first parameter value is empty, the second parameter type is empty, and when the first parameter value is not empty, the second parameter type is not empty; The first verification report includes multiple first verification records; the first verification records correspond to the second interface records one by one; the first verification record consists of the corresponding second interface record and a corresponding first verification result; the first verification result includes passed verification, interface path error, interface request method error, parameter quantity error and error parameter name sequence; the error parameter name sequence is formed by one or more error parameter names sorted in sequence.
3. The method for verifying service interface call information according to claim 1, characterized in that: The programming languages include at least Java, C++, Python, JavaScript and GO; The source code parsing tools include at least the Ap i fox tool and Swagger dedicated to Java language parsing, the Clang tool dedicated to C++ language parsing, the JMESPath tool and AST parsing tool dedicated to Python language parsing, the ESL int tool and DocBlockr tool dedicated to JavaScript language parsing, the Go AST parsing tool and Stati ccheck tool dedicated to GO language parsing, as well as the Sourcegraph tool, SonarQube tool, Checkmarx tool, and SRCINFO tool that support multiple programming languages.
4. The method for checking service interface call information according to claim 2, characterized in that: The correctness checking of the second interface list according to the first interface list to obtain a corresponding first verification report specifically includes: Step 41, taking the first second interface record in the second interface list as the corresponding current interface record; Step 42, taking the second interface path, the second interface request method and the second interface parameter sequence of the current interface record as the corresponding current interface path, the current interface request method and the current interface parameter sequence; and taking the first interface record in the first interface list whose first interface path matches the current interface path as the corresponding current reference record; Step 43, identifying whether the current reference record is empty; if so, setting the corresponding first verification result as an interface path error, and going to step 48; if not, setting the first interface request method of the current reference record as the corresponding current reference method, and going to step 44; Step 44, identifying whether the current reference method matches the current interface request method; if not, setting the corresponding first verification result as an interface request method error, and going to step 48; if matching, taking the first interface parameter sequence of the current reference record as the corresponding current reference parameter sequence, and going to step 45; Step 45, counting the total number of the first interface parameters of the current reference parameter sequence to obtain the corresponding total number of reference parameters; and counting the total number of the second interface parameters of the current interface parameter sequence to obtain the corresponding total number of current parameters; and identifying whether the total number of reference parameters is equal to the total number of current parameters; if they are not equal, setting the corresponding first verification result as a parameter quantity error, and going to step 48; if they are equal, going to step 46; Step 46, extracting a pair of the first and second interface parameters having the same sequence sorting index in the current reference parameter sequence and the current interface parameter sequence to form a corresponding first parameter group; Step 47, perform a round of traversal on all the first parameter groups obtained; and in this round of traversal, use the first parameter group currently traversed as the corresponding current parameter group; and use the first optional / mandatory configuration and the first parameter type of the first interface parameter in the current parameter group as the corresponding reference optional / mandatory configuration and reference parameter type; and use the second parameter type of the second interface parameter in the current parameter group as the corresponding current parameter type; and identify the reference optional / mandatory configuration; if the reference optional / mandatory configuration is a mandatory parameter, identify whether the reference parameter type and the current parameter type match, if they match, set the corresponding first parameter check result to success, if not, set the corresponding first parameter check result to failure; if the reference optional / mandatory configuration is an optional parameter, set the corresponding first parameter type when the current parameter type is empty. A parameter check result is successful, and when the current parameter type is not empty and the reference parameter type matches the current parameter type, the corresponding first parameter check result is set to success, and when the current parameter type is not empty and the reference parameter type does not match the current parameter type, the corresponding first parameter check result is set to failure; and when the first parameter check result corresponding to the current parameter group is failure, a corresponding error parameter name is set to the first parameter name of the first interface parameter of the current parameter group; and at the end of this round of traversal, all the error parameter names obtained by this round of traversal are sequentially sorted to form a corresponding error parameter name sequence; and whether the obtained error parameter name sequence is empty is identified, and if so, the corresponding first verification result is set to pass the verification, otherwise, the corresponding first verification result is set to the corresponding error parameter name sequence; Step 48, forming a corresponding first verification record by the current interface record and the corresponding first verification result; Step 49, identify whether the current interface record is the last second interface record in the second interface list; if not, extract the next second interface record in the second interface list as the new current interface record, and return to step 42; if so, all the first verification records obtained constitute the corresponding first verification report.
5. A device for executing the processing method for checking service interface call information according to any one of claims 1 to 4, characterized in that: The device comprises: a pre-processing module, a batch processing file receiving module, a service interface calling information checking module and a batch processing result feedback module; The preprocessing module is used to configure the corresponding first interface list based on the preset service interface design specification; The batch file receiving module is used to receive batch source code files input by the user and record them as corresponding first batch code files; the first batch code files include multiple first code files; The service interface call information verification module is used to take each of the first code files of the first batch of code files as the corresponding current code file; and record the programming language corresponding to the current code file as the current programming language; and record the source code parsing tool corresponding to the current programming language as the corresponding current parsing tool; and parse the service interface call information of the current code file based on the current parsing tool to obtain the corresponding second interface list; and perform correctness verification on the second interface list according to the first interface list to obtain the corresponding first verification report; and the current code file and the corresponding first verification report form a corresponding first verification file package; The batch processing result feedback module is used to feedback the first batch of verification file packages corresponding to all the first verification file packages obtained to the current user.
6. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is used to couple with the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 4; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer is enabled to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Interface calling method and device, computer equipment and storage medium
CN110532107A
URL extraction method and device
CN112632423A
Method and device for determining correctness of interface, equipment, storage medium and product
CN114647587A
Waste code searching method and device, electronic equipment and storage medium
CN115756600A
Interface contract checking method and device, electronic equipment and storage medium
CN117033208A