Interface information processing method and device, equipment, storage medium and program product
Through the automated interface information processing method, the problem of non-standard and incomplete interface documents is solved, the accuracy and efficiency of interface documents are improved, and the communication cost of front-end and back-end developers is reduced.
Patent Information
- Application Number
- CN202410659058.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-23
- Publication Date
- 2024-09-17
AI Technical Summary
In web project development, front-end developers need to rely on the interface documents provided by the back-end, and the interface documents are not standardized or incomplete, resulting in low development efficiency and high communication costs, affecting the accuracy of the documents.
Through automated interface information processing methods, interface information is modified in response to modification instructions, attribute information is matched, interface documents are generated or updated, and manual writing and communication requirements are reduced.
It reduces the workload, improves the accuracy and modification efficiency of interface documents, reduces the communication cost between front-end and back-end developers, and improves development efficiency.
Smart Images

Figure CN118656106A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an interface information processing method, device, equipment, storage medium and program product. Background Art
[0002] In the current web project development model, the most commonly used model is the separation of web development (front-end) and service development (back-end), that is, the front-end and back-end are developed independently. In this model, front-end developers often encounter the need to call back-end interfaces but the back-end interfaces are not well developed. In order to ensure the development efficiency of the front-end, the back-end developers usually provide an interface document to the front-end, and the front-end developers can obtain interface information through the interface document. After obtaining the interface document, if the interface document does not meet the specifications or the content is incomplete, the front-end developers need to communicate with the back-end developers at any time to modify the interface document. Summary of the invention
[0003] The embodiments of the present application provide an interface information processing method, apparatus, device, storage medium and program product, which do not require manual writing of interface documents, thereby reducing workload, improving modification efficiency, and ensuring the accuracy of interface documents.
[0004] In a first aspect, the present application provides an interface information processing method, the method comprising:
[0005] In response to a modification instruction of the target interface, modify the interface information of the target interface to obtain first interface information;
[0006] Determine a first interface document of the target interface and second interface information of the first interface document;
[0007] Matching the first attribute information of the first interface information with the second attribute information of the second interface information to obtain a first attribute information matching result;
[0008] Based on the first attribute information matching result, a second interface document is determined.
[0009] In an embodiment of the present application, in response to a modification instruction of the target interface, the interface information of the target interface is modified to obtain the first interface information, thereby realizing the modification of the interface information of the target interface. In addition, the present application determines the first interface document of the target interface, and the second interface information of the first interface document, that is, the generated different versions of the interface document corresponding to the target interface. In addition, the present application matches the first attribute information of the first interface information with the second attribute information of the second interface information, obtains the first attribute information matching result, to indicate whether there is a first interface document generated by the second result information identical to the first interface information, after obtaining the first attribute information matching result, determines the second interface document based on the first attribute information matching result, thereby eliminating the need for the back-end developer to rewrite an interface document based on the first interface information, that is, automatically determines the second interface document, reduces the workload, improves the modification efficiency, ensures the accuracy of the second interface document, and facilitates the direct use of the front-end developer, reducing the communication cost between the front-end and back-end developers.
[0010] In a second aspect, the present application provides an interface information processing device, the device comprising:
[0011] A modification module, configured to modify the interface information of the target interface in response to a modification instruction of the target interface to obtain first interface information;
[0012] A first determination module, used to determine a first interface document corresponding to the target interface and second interface information of the first interface document from the generated interface documents;
[0013] a matching module, configured to match the first attribute information of the first interface information with the second attribute information of the second interface information to obtain a first attribute information matching result;
[0014] The second determination module is used to determine a second interface document based on the first attribute information matching result.
[0015] In a third aspect, the present application provides an electronic device, including:
[0016] A memory for storing program instructions;
[0017] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods in the first aspect according to the obtained program instructions.
[0018] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods described in the first aspect.
[0019] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, when the computer program code is run on a computer, the computer executes any one of the methods described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0021] Figure 1 is a schematic diagram of an application scenario according to an exemplary embodiment;
[0022] Figure 2 is a schematic diagram of another application scenario according to an exemplary embodiment;
[0023] Figure 3 is a flow chart of a method for processing interface information according to an exemplary embodiment;
[0024] Figure 4 is a detailed flow chart of a method for processing interface information according to an exemplary embodiment;
[0025] Figure 5 is a flow chart showing a method for determining first interface information according to an exemplary embodiment;
[0026] Figure 6 is a schematic diagram of an interface for processing interface information according to an exemplary embodiment;
[0027] Figure 7 is a schematic diagram of a modification interface of a test interface according to an exemplary embodiment;
[0028] Figure 8 is a flow chart showing a method for generating a target interface according to an exemplary embodiment;
[0029] Fig. 9 is a schematic diagram of a target interface generation interface according to an exemplary embodiment;
[0030] Fig.10 is a schematic diagram of an interface for a user to edit a generated interface according to an exemplary embodiment;
[0031] Fig.11 is a schematic diagram of another interface for processing interface information according to an exemplary embodiment;
[0032] Fig.12 is an interface schematic diagram of a second interface document of a target interface according to an exemplary embodiment;
[0033] Fig.13 is a flow chart showing a method for displaying a target interface according to an exemplary embodiment;
[0034] Fig.14 is a schematic diagram of an interface showing interface information of a jsonSchema test interface according to an exemplary embodiment;
[0035] Fig.15 is a schematic diagram of a display interface of a type definition file corresponding to a test interface according to an exemplary embodiment;
[0036] Fig.16 is a schematic diagram of an interface for deleting a target interface according to an exemplary embodiment;
[0037] Fig.17 is a schematic diagram of an interface information processing device according to an exemplary embodiment;
[0038] Fig.18 The figure is a schematic diagram of an electronic device showing a method for processing interface information according to an exemplary embodiment. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0040] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0041] In the technical solution of this application, the collection, dissemination, and use of data are in compliance with the requirements of relevant national laws and regulations.
[0042] Before introducing the interface information processing method provided in the embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first introduced in detail below.
[0043] In the related art, back-end developers need to manually write interface documents corresponding to code files. This method is inefficient, and when the requirements change, the back-end developers need to manually update the interface information and rewrite an interface document based on the updated interface information. This workload is large and affects the accuracy of the interface document.
[0044] In order to process interface information, the present application provides an interface information processing method, device, equipment, storage medium and program product, which does not require manual writing of interface documents, thereby reducing workload, improving modification efficiency, and ensuring the accuracy of interface documents.
[0045] First, refer to Figure 1 , which is a schematic diagram of an application scenario of an embodiment, including a user device 10 and a server 11. The user device 10 and the server 11 are connected to each other through a network, and the network can be a local area network, a wide area network, etc. The user device 10 can be a convenient device (for example: a mobile phone, a tablet, a laptop, etc.), or a personal computer (PC), and the server 21 can be any device that can provide Internet services.
[0046] A possible form of communication between the user device 10 and the server 11 is that the server 11 modifies the interface information of the target interface in response to a modification instruction of the target interface triggered by the user on the user device 10, and obtains the first interface information; determines the first interface document of the target interface, and the second interface information of the first interface document; matches the first attribute information of the first interface information with the second attribute information of the second interface information, and obtains a first attribute information matching result; determines the second interface document based on the first attribute information matching result; the server 11 sends the second interface document to the user device 10, and the user device 10 displays the received second interface document.
[0047] refer to Figure 2, which is another application scenario diagram of the embodiment, including a user device 20 and a server 21, wherein the server 21 includes an intermediate server 211 and a backend server 212. The user device 20 and the server 21 are connected to each other through a network, which may be a local area network, a wide area network, etc. The user device 20 may be a convenient device (e.g., a mobile phone, a tablet, a laptop, etc.), or a personal computer (PC), the backend server 212 may be any device capable of providing Internet services, and the intermediate server 211 may be a server with an API-types-automatic-converter (intermediate server plug-in), or other servers.
[0048] A possible form of communication between the user device 20 and the server 21 is that the intermediate server 211 responds to the modification instruction of the target interface triggered by the user on the user device 20, and sends the modification instruction of the target interface to the back-end server 212. The back-end server 212 responds to the modification instruction of the target interface, modifies the interface information of the target interface, obtains the first interface information and sends it to the intermediate server 211. The intermediate server 211 determines the first interface document of the target interface and the second interface information of the first interface document; matches the first attribute information of the first interface information with the second attribute information of the second interface information to obtain the first attribute information matching result; determines the second interface document based on the first attribute information matching result, and the intermediate server 211 sends the second interface document to the user device 10, and the user device 10 displays the received second interface document.
[0049] In some embodiments, a method for processing interface information is described below through a specific embodiment. Figure 3 As shown, including:
[0050] Step 301, in response to a modification instruction of a target interface, modify the interface information of the target interface to obtain first interface information;
[0051] The modification instruction of the target interface may be triggered by a user or by other means, for example, the user inputs a file including the modified interface information of the target interface into the system, thereby triggering the modification instruction of the target interface. The interface information of the target interface includes at least one attribute information, each of which includes an attribute name and a corresponding attribute value. Specifically, each of which includes an attribute name and a corresponding attribute value, and the attribute name may include an interface name, a request method, a request path, a request body, a request header, a response header, a response body, and the like.
[0052] The request body in the embodiment of the present application refers to the request message sent by the front end to the back end. The response body in the embodiment of the present application refers to the response body in the response message returned by the back end after the back end receives and interprets the request message. The request method in the embodiment of the present application is the HTTP (Hyper Text Transfer Protocal) request method. According to the HTTP standard, HTTP requests can use a variety of request methods. HTTP1.0 defines three request methods: get (view), post (create) and head (check resource) methods. HTTP1.1 adds six new request methods: options (select), put (update), patch (update certain fields), delete (delete), trach (echo) and connect (communication) methods.
[0053] Optionally, after obtaining the first interface information, the method further includes:
[0054] If the first interface document of the target interface does not exist, a second interface document is generated based on the first interface information.
[0055] Step 302, determining a first interface document of a target interface and second interface information of the first interface document;
[0056] Specifically, a first interface document of the target interface and second interface information of the first interface document are determined from the generated interface documents.
[0057] Among them, the generated interface documents include different versions of interface documents of each interface that have been generated before responding to the modification instruction of the target interface. The number of first interface documents can be 1 or N, and each first interface document corresponds to a second interface information. Therefore, if the number of first interface documents is 1, the number of second interface information is 1. If the number of first interface documents is N, the number of second interface information is N, and N is an integer greater than 1.
[0058] Step 303, matching the first attribute information of the first interface information with the second attribute information of the second interface information to obtain a first attribute information matching result;
[0059] Specifically, the first attribute information of the first interface information is matched with the second attribute information of the second interface information by using a differ function to obtain a first attribute information matching result.
[0060] The first attribute information of the first interface information includes at least one piece of attribute information, and the second attribute information of the second interface information includes at least one piece of attribute information.
[0061] Step 304: Determine a second interface document based on the first attribute information matching result.
[0062] Optionally, determining the second interface document based on the first attribute information matching result includes:
[0063] If the first attribute information matching result indicates that the first attribute information matches the second attribute information successfully, the first interface document is used as the second interface document;
[0064] If the first attribute information matching result indicates that the first attribute information fails to match the second attribute information, a second interface document is generated based on the first interface information.
[0065] In an embodiment of the present application, if the first attribute information matching result indicates that the first attribute information matches the second attribute information successfully, it means that the second interface document generated based on the first interface information is the same as the first interface document generated based on the second interface information. Therefore, there is no need to perform the process of generating the second interface document based on the first interface information, and the first interface document is directly used as the second interface document, so that the back-end developer does not need to rewrite an interface document based on the first interface information, that is, automatically determine the second interface document, reduce the workload, improve the modification efficiency, ensure the accuracy of the second interface document, and do not need to save the second interface document to ensure that the same version of the interface document can be automatically merged. If the first attribute information matching result indicates that the first attribute information fails to match the second attribute information, it means that the second interface document generated based on the first interface information is different from the first interface document generated based on the second interface information. Therefore, it is necessary to generate the second interface document based on the first interface information, so that the back-end developer does not need to rewrite an interface document based on the first interface information, that is, automatically generate the second interface document, reduce the workload, improve the modification efficiency, ensure the accuracy of the second interface document, and it is necessary to save the second interface document to ensure the diversity of the interface document version.
[0066] For example, the first attribute information is {interface name: application list query, request method: get, request path: / api / get / appList}. If the second attribute information is {interface name: application list query, request method: get, request path: / api / get / appList}, the first attribute information and the second attribute information are matched, and it is determined that the first attribute information matches the second attribute information successfully, so the first interface document is used as the second interface document. If the second attribute information is {interface name: application list query, request method: get, request path: / api / get / app}, the first attribute information and the second attribute information are matched, and it is determined that the request path of the first attribute information does not match the request path of the second attribute information, that is, the first attribute information fails to match the second attribute information, so the second interface document is generated based on the first interface information. If the second attribute information is {interface name: application list query, request method: get, request path: / api / get / app, interface source: internal interface}, the first attribute information and the second attribute information are matched, and it is determined that the interface source in the second interface information does not exist in the first attribute information, that is, the first attribute information fails to match the second attribute information, and therefore, a second interface document is generated based on the first interface information. If the second attribute information is {interface name: application list query, request method: get}, the first attribute information and the second attribute information are matched, and it is determined that the request path of the first attribute information does not exist in the second attribute information, that is, the first attribute information fails to match the second attribute information, and therefore, a second interface document is generated based on the first interface information.
[0067] In an embodiment of the present application, in response to a modification instruction of the target interface, the interface information of the target interface is modified to obtain the first interface information, thereby realizing the modification of the interface information of the target interface. In addition, the present application determines the first interface document of the target interface, and the second interface information of the first interface document, that is, the generated different versions of the interface document corresponding to the target interface. In addition, the present application matches the first attribute information of the first interface information with the second attribute information of the second interface information, obtains the first attribute information matching result, to indicate whether there is a first interface document generated by the second interface information that is the same as the first interface information, after obtaining the first attribute information matching result, based on the first attribute information matching result, determines the second interface document, thereby eliminating the need for the back-end developer to rewrite an interface document based on the first interface information, that is, automatically determines the second interface document, reduces the workload, improves the modification efficiency, ensures the accuracy of the second interface document, and facilitates the direct use of the front-end developer, reducing the communication cost between the front-end and back-end developers.
[0068] The specific steps of the interface information processing method provided above are described in detail below. Figure 4As shown:
[0069] Step 401, in response to a modification instruction of a target interface, modify the interface information of the target interface to obtain first interface information.
[0070] Among them, after responding to the modification instruction of the target interface, the present application needs to modify the interface information of the target interface based on the modification instruction, so as to obtain the first interface information. Therefore, Figure 5 is a flowchart of a method for determining first interface information according to an exemplary embodiment. Figure 5 As shown, the above step 401 at least includes the following steps:
[0071] Step 501, based on the modification instruction, displaying a modification interface including interface information of a target interface;
[0072] The interface information of the target interface includes at least one piece of attribute information, and each piece of attribute information includes an attribute name and a corresponding attribute value.
[0073] Step 502, based on the editing operation on the modification interface, determining the candidate attribute information to be modified, and based on the candidate attribute information, modifying the interface information of the target interface to obtain the modified interface information;
[0074] The editing operation on the modification interface may be an editing operation performed by the user on the modification interface. The editing operation on the modification interface includes part or all of the following operations: modifying the attribute information, adding the attribute information, and deleting the attribute information.
[0075] Step 503: In response to the modification completion instruction, the modified interface information is used as the first interface information.
[0076] The modification completion instruction may be triggered by a user or by other means.
[0077] In an embodiment of the present application, based on an editing operation on the modification interface, modified interface information is obtained, and the modified interface information is used as the first interface information, thereby achieving flexible processing of the interface information, improving modification efficiency, and reducing workload.
[0078] For example, Figure 6 is a schematic diagram of an interface for processing interface information according to an exemplary embodiment. Figure 6As shown, this is a schematic diagram of the interface processing interface information. When the user clicks the "Internal Interface" button in the interface, the display instruction of the interface information of the internal interface is triggered. Therefore, the interface displays the interface information of the jsonSchema test interface, test interface, Create user interface and Update an existing pet interface. The jsonSchema test interface, test interface, Createuser interface and Update an existing pet interface belong to the internal interface. Each interface information includes the interface name, request path, request method, interface description, subsystem, associated application and processing method and other attribute names and corresponding attribute values. You can enter different sub-interfaces by clicking the "Modify", "Delete" and "Details Query" buttons corresponding to each interface, so as to process the interface information of the interface, or you can generate the interface information of a new interface by clicking the "Add" button. In addition, the user can search for the interface information of the corresponding interface based on the attribute value, or filter the interface information of the interface that meets the set conditions.
[0079] Figure 7 is a schematic diagram of a modification interface of a test interface according to an exemplary embodiment. Figure 6 When you click the "Modify" button corresponding to the test interface in the displayed interface, the modification instruction of the test interface is triggered, and the modification interface of the test interface is displayed as follows: Figure 7 As shown, the modification interface displays multiple attribute information included in the interface information of the test interface. The user can modify, add and delete the multiple attribute information included in the interface information of the test interface. For example, the user modifies the attribute value of the subsystem in the interface information of the test interface from "test system" to "test system 12", and increases the attribute value of the interface description in the interface information of the test interface "test interface is used for testing". Through the user's editing operation in the modification interface, the candidate attribute information modified by the user is obtained, and based on the candidate attribute information, the interface information of the target interface is modified to obtain the modified interface information. After the user determines that the modification is completed, the modification completion instruction can be triggered by clicking the "Save" button, and the modified interface information is used as the first interface information. The user can also click the "Save and Continue" button to save the current candidate attribute information and continue to modify the interface information of the test interface. The user can also cancel the modification of the interface information of the test interface by clicking the "Cancel" button.
[0080] Optionally, the attribute information includes an attribute name and a corresponding attribute value. Before responding to the modification instruction of the target interface, a target interface needs to be generated. Figure 8 is a flowchart of a method for generating a target interface according to an exemplary embodiment. Figure 8 As shown, the following steps are included:
[0081] Step 801, in response to a target interface generation instruction, displaying a generation interface including a plurality of attribute names;
[0082] In the embodiment of the present application, in response to a generation instruction of a target interface, a pop-up window may be opened to display a generation interface including a plurality of attribute names.
[0083] The target interface generation instruction may be triggered by a user or by other means.
[0084] Step 802, based on the editing operation on the generation interface, determine the attribute value of at least one attribute name to obtain at least one piece of attribute information;
[0085] In the embodiment of the present application, at least one piece of attribute information can be obtained by a user manually setting the attribute value of at least one attribute name on a generation interface, or at least one piece of attribute information can be obtained by a user importing a file including at least one piece of attribute information of a target interface.
[0086] Step 803: In response to the generation completion instruction, generate interface information of the target interface based on at least one piece of attribute information.
[0087] Among them, the generation completion instruction can be triggered by the user or by other means. The interface information of the target interface is a JSON (Java Script Object Notation, JS object notation) file that conforms to the interface definition OpenAPI3 specification (OAS), that is, one interface corresponds to one JSON file. In the embodiment of the present application, the mock function (a software testing technology) can be used to test the target interface to ensure the availability and security of the target interface.
[0088] The above Open API specification is a standard, programming language-independent interface description specification defined for HTTP API (Application Programming Interface), which allows people and computers to discover and understand the functions of a service without accessing source code, additional documentation, or inspecting network traffic. When correctly defined through Open API, users can understand and interact with remote services with minimal implementation logic. Similar to the role that interface descriptions play for low-level programming, the Open API specification eliminates the guesswork when calling services.
[0089] The above JSON refers to JavaScript (a programming language) object notation. JSON is a lightweight text data exchange format that is language independent: JSON uses JavaScript syntax to describe data objects, but JSON is still language and platform independent. JSON parsers and JSON libraries support many different programming languages. Currently, many dynamic programming languages support JSON, for example, PHP (Hypertext Preprocessor), JSP (Java ServerPages), .NET (a free open source development platform for building a variety of applications) and other programming languages. JSON is self-descriptive and easier to understand.
[0090] For example, Fig. 9 is a schematic diagram of a target interface generation interface according to an exemplary embodiment. Figure 6 When you click the "Add" button in the displayed interface, the target interface generation instruction is triggered, and the generated interface is displayed as follows: Fig. 9 As shown, multiple attribute names are displayed on the generation interface, namely, interface name, interface description, request method, request path, request body, response body, etc. The user can set the corresponding attribute value based on the attribute name in the generation interface to obtain at least one attribute information of the target interface. Fig.10 is a schematic diagram of an interface for a user to edit a generated interface according to an exemplary embodiment. Fig.10 As shown, the user sets the attribute value of the interface name to the application list query interface, the attribute value of the request method to get, the attribute value of the request path to / api / get / app and other attribute information. After confirming that the editing is complete, the user can click the "Save" button to trigger the generation completion instruction, thereby generating the interface information of the application list query interface based on the multiple attribute information of the application list query interface. The user can also click the "Save and Continue" button to save at least one edited attribute information and continue to set the attribute values corresponding to other attribute names. The user can also cancel the generation of the target interface this time by clicking the "Cancel" button. Fig.11 is a schematic diagram of another interface information processing interface according to an exemplary embodiment. Fig.10 After clicking the "Save" button in the displayed interface, Fig.11 As shown, the interface information of the newly generated application list query interface is displayed on the interface information processing interface.
[0091] In an embodiment of the present application, in response to a generation instruction of a target interface, at least one piece of attribute information is obtained based on an editing operation on a generation interface including multiple attribute names, and based on the at least one piece of attribute information, interface information of the target interface is generated, without the need for manual writing by back-end developers, thereby ensuring the integrity and correctness of the interface information of the target interface, thereby achieving flexible processing of interface information, improving the generation efficiency of the interface information of the target interface, reducing workload, and facilitating direct use by front-end developers, thereby reducing communication costs between front-end and back-end developers.
[0092] Optionally, after the interface information of the target interface is generated, the method further includes:
[0093] Based on the interface information of the target interface, a fifth interface document is generated and saved.
[0094] Optionally, the fifth interface document includes a fifth type definition file and a sixth type definition file, and the fifth interface document is generated based on the interface information of the target interface, including:
[0095] Based on the request body of the interface information of the target interface, a fifth type definition file is generated and saved; based on the response body of the interface information of the target interface, a sixth type definition file is generated and saved.
[0096] Specifically, Figure 2 As shown, the intermediate server 211 can proxy to the defined interface API, and allow the interface information of the target interface to pass through the intermediate server 211 through the reverse proxy, thereby obtaining the request body and response body of the interface information of the target interface for automatic conversion, and automatically converting the request body in the interface information of the target interface into the fifth type definition file, and converting the response body in the interface information of the target interface into the sixth type definition file.
[0097] Among them, the type definition file in the embodiment of the present application can also be called TS (Type Script, a lightweight, interpreted or just-in-time compiled programming language with function priority) type definition file. The type definition file is used to describe the type information of all exported interfaces in the JavaScript module. The type definition file can enhance the type definition, has a certain protection effect, and can improve security.
[0098] In the embodiment of the present application, after the interface information of the target interface is generated, the interface document of the target interface is automatically generated based on the interface information of the target interface, and there is no need for the back-end developer to manually write the interface document of the target interface, which reduces the communication with the front-end developer, improves the efficiency of generating the interface document, and reduces the workload. In addition, based on the request body and response body of the interface information of the target interface, the corresponding fifth type definition file and sixth type definition file are automatically generated, and there is no need for the back-end developer to manually write the type definition file of the target interface, which reduces the communication cost of the front-end and back-end developers, improves the development efficiency, and reduces the workload.
[0099] Step 402, determine whether the first interface document of the target interface does not exist, if so, execute step 403, otherwise, execute step 404.
[0100] In the embodiment of the present application, the interface document corresponding to the target interface saved before responding to the modification instruction of the target interface is used as the first interface document, for example, the interface document saved when generating the target interface, the interface document saved when displaying the target interface, the interface document saved when modifying the target interface, and other interface documents.
[0101] Step 403: Generate a second interface document based on the first interface information.
[0102] The second interface document includes a first type definition file and a second type definition file, and the first interface information includes a first request body, a first response body and other information. Therefore, generating the second interface document based on the first interface information includes:
[0103] A first type definition file is generated based on the first request body, and a second type definition file is generated based on the first response body.
[0104] Optionally, after generating the second interface document based on the first interface information, the method further includes:
[0105] In response to the download instruction of the second interface document, the second interface document is downloaded.
[0106] For example, if the target interface is a test interface, the user Figure 7 The modification interface shown in the figure performs the editing operation, that is, the user modifies the attribute value of the subsystem in the interface information of the test interface from "test system" to "test system 12", and adds the attribute value of the interface description in the interface information of the test interface "test interface for testing", and obtains the modified interface information. The user clicks the "Save" button to trigger the modification completion instruction, and the modified interface information is used as the first interface information. Fig.12 is a schematic diagram of an interface of a second interface document of a target interface according to an exemplary embodiment. Fig.12As shown, the interface displays the second interface document generated based on the first interface information, that is, the interface document obtained after the user modifies the test interface. The attribute value of the subsystem in the second interface document of the test interface is "test system 12", and the interface description is "test interface is used for testing". The user can click the "Download" button to trigger the download instruction of the second interface document of the test interface to download the second interface document of the test interface.
[0107] Step 404: determine the first interface document of the target interface and the second interface information of the first interface document.
[0108] Step 405 , determine whether the first attribute information matches the second attribute information, if so, execute step 406 , otherwise, execute step 407 .
[0109] The first attribute information of the first interface information includes at least one piece of attribute information, and the second attribute information of the second interface information includes at least one piece of attribute information.
[0110] Step 406: Use the first interface document as the second interface document.
[0111] In the embodiment of the present application, the cover function can be used to make the first interface document the second interface document.
[0112] In an embodiment of the present application, if the number of second interface information is 1, the number of second attribute information is 1; if the number of second interface information is N, the number of second attribute information is N, where N is an integer greater than 1.
[0113] Specifically, when the number of second attribute information is 1, the first attribute information is matched with the second attribute information to obtain a first attribute information matching result. If the first attribute information matching result indicates that the first attribute information and the second attribute information are successfully matched, the first interface document is used as the second interface document. When the number of second attribute information is N, the first attribute information is matched with N second attribute information respectively to obtain N first attribute information matching results. If there is a first attribute information matching result indicating that the first attribute information and the second attribute information are successfully matched, the first interface document corresponding to the first attribute information matching result indicating a successful match is used as the second interface document, and N is an integer greater than 1.
[0114] Step 407: Generate a second interface document based on the first interface information.
[0115] In an embodiment of the present application, if the number of second interface information is 1, the number of second attribute information is 1; if the number of second interface information is N, the number of second attribute information is N, where N is an integer greater than 1.
[0116] Specifically, when the number of second attribute information is 1, the first attribute information is matched with the second attribute information to obtain a first attribute information matching result. If the first attribute information matching result indicates that the first attribute information and the second attribute information fail to match, a second interface document is generated based on the first interface information. When the number of second attribute information is N, the first attribute information is matched with N second attribute information respectively to obtain N first attribute information matching results. If the N first attribute information matching results all indicate that the first attribute information and the second attribute information fail to match, a second interface document is generated based on the first interface information and displayed, where N is an integer greater than 1.
[0117] For example, three first interface documents of the target interface are determined from the saved generated interface documents, namely, the first interface document A, the first interface document B and the first interface document C, and the second interface information of the three first interface documents is determined, namely, the second interface information a corresponding to the first interface document A, the second interface information b corresponding to the first interface document B and the second interface information c corresponding to the first interface document C. The first attribute information of the first interface information is matched with the second attribute information of the second interface information a to obtain attribute information matching result 1, the first attribute information of the first interface information is matched with the second attribute information of the second interface information b to obtain attribute information matching result 2, and the first attribute information of the first interface information is matched with the second attribute information of the second interface information c to obtain attribute information matching result 3. If the attribute information matching result 2 indicates that the first attribute information of the first interface information matches the second attribute information of the second interface information b successfully, the first interface document B is used as the second interface document. If all three attribute matching results indicate that the matching fails, the second interface document is generated based on the first interface information.
[0118] Optionally, the second interface document includes a first type definition file and a second type definition file, and generating the second interface document based on the first interface information includes:
[0119] Matching the first request body of the first interface information with the second request body of the second interface information to obtain a first matching result, and determining a first type definition file based on the first matching result;
[0120] The first response body of the first interface information is matched with the second response body of the second interface information to obtain a second matching result, and a second type definition file is determined based on the second matching result.
[0121] Specifically, the first request body in the first interface information can be matched with the second request body in the second interface information using the differ function, and the first response body in the first interface information can be matched with the second response body in the second interface information using the differ function.
[0122] In the present application embodiment, Figure 2 As shown, the intermediate server 211 uses the onProxyReq function to intercept the first request body of the first interface information, and converts the first request body in JSON format, such as {id:'y91hhdhajhd'}, into a first type definition file in TS format. And according to the request path of the first interface information, the slash is converted into a hyphen, and the unique identifiers such as ID (Identity document) on the URL (Uniform Resource Locator) are removed as the file name of the first type definition file to be saved. For example, if the request path in the first interface information is api / getUserName / 1, the file name of the first type definition file is determined to be api-get-user-name.req.type.ts. The intermediate server 211 uses the onProxyRes function to intercept the first response body of the first interface information, and converts the first response body in JSON format, such as {status:0,data:[{name:1,age:11},{name:2,age:12}]}, into a second type definition file in TS format. And according to the request path of the first interface information, the slashes are converted into hyphens, and the unique identifiers such as ID on the URL are removed as the file name of the second type definition file to be saved. For example, the request address of the first interface information is api / getUserName / 1, then the file name of the second type definition file is determined to be api-get-user-name.res.resbody.ts.
[0123] In an embodiment of the present application, based on the matching of the first request body of the first interface information and the second request body of the second interface information, the first type definition file of the second interface document is determined, and based on the matching of the first response body of the first interface information and the second response body of the second interface information, the second type definition file of the second interface document is determined. There is no need for back-end developers to manually write the type definition file of the target interface, which ensures the accuracy of the type definition file of the target interface, improves development efficiency, reduces workload, and is convenient for front-end developers to use directly, reducing communication costs between front-end and back-end developers.
[0124] Optionally, determining the first type definition file based on the first matching result includes:
[0125] If the first matching result indicates that the first request body matches the second request body successfully, the third type definition file of the first interface document is used as the first type definition file;
[0126] If the first matching result indicates that the first request body fails to match the second request body, a first type definition file is generated based on the first request body.
[0127] In the embodiment of the present application, the cover function can be used to use the third type definition file of the first interface document as the first type definition file.
[0128] Among them, since the second interface information corresponds to a second request body, and the number of second interface information is 1 or N, if the number of second interface information is 1, the number of second request bodies is 1, and if the number of second interface information is N, the number of second request bodies is N, and N is an integer greater than 1. The specific process of generating the first type definition file based on the first request body is a prior art and will not be described in detail here.
[0129] Specifically, when the number of second request bodies is 1, the first request body is matched with the second request body to obtain a first matching result. If the first matching result indicates that the first request body matches the second request body successfully, the third type definition file of the first interface document is used as the first type definition file; if the first matching result indicates that the first request body matches the second request body unsuccessfully, the first type definition file is generated based on the first request body.
[0130] When the number of second request bodies is N, the first request body is matched with the N second request bodies respectively to obtain N first matching results. If there is a first matching result indicating that the first request body matches the second request body successfully, the third type definition file of the first interface document corresponding to the first matching result indicating the successful match is used as the first type definition file; if the N first matching results all indicate that the first request body matches the second request body unsuccessfully, the first type definition file is generated based on the first request body.
[0131] Since the present application uses the third type definition file in the first interface document as the first type definition file when the first request body matches the second request body successfully, there may be duplicate second request bodies when the number of second request bodies is N. Therefore, the present application needs to deduplicate the N second request bodies to reduce matching operations, reduce workload, and improve processing efficiency.
[0132] Specifically, if the number of second request bodies is N, the N second request bodies are deduplicated to obtain M second request bodies, the first request body is matched with the M second request bodies respectively to obtain M first matching results, and the first type definition file is determined based on the M first matching results, where M is less than or equal to N.
[0133] For example, three first interface documents of the target interface are determined from the saved generated interface documents, namely, the first interface document A, the first interface document B and the first interface document C, the second interface information of the three first interface documents is determined, namely, the second interface information a corresponding to the first interface document A, the second interface information b corresponding to the first interface document B and the second interface information c corresponding to the first interface document C, and the second request bodies in the three second interface information are determined, namely, the second request body 1 in the second interface information a, the second request body 2 in the second interface information b and the second request body 3 in the second interface information c. The first request body is matched with the second request body 1 to obtain the first matching result 1, the first request body is matched with the second request body 2 to obtain the first matching result 2, and the first request body is matched with the second request body 3 to obtain the first matching result 3. If the first matching result 1 indicates that the first request body matches the second request body 1 successfully, the third type definition file in the first interface document A is used as the first type definition file. If all three first matching results indicate that the matching fails, the first type definition file is generated based on the first request body.
[0134] If the second request bodies in the three determined second interface information are respectively the second request body 1 in the second interface information a, the second request body 2 in the second interface information b, and the second request body 1 in the second interface information c, then it is determined that there are duplicate second request bodies in the three second request bodies, so a deduplication operation is performed to obtain the second request body 1 and the second request body 2. The first request body is matched with the second request body 1 to obtain the first matching result 1, and the first request body is matched with the second request body 2 to obtain the first matching result 2. If the first matching result 1 indicates that the first request body and the second request body 1 are matched successfully, the third type definition file in the first interface document A or the first interface document C is used as the first type definition file. If both of the two first matching results indicate that the match fails, a first type definition file is generated based on the first request body.
[0135] In an embodiment of the present application, if the first request body matches the second request body successfully, it indicates that the first type definition file generated based on the first request body is the same as the third type definition file generated based on the second request body. Therefore, there is no need to execute the process of generating the first type definition file based on the first request body, and the third type definition file in the first interface document is directly used as the first type definition file, thereby eliminating the need for back-end developers to manually write the first type definition file of the target interface, that is, automatically determining the first type definition file, reducing workload, improving development efficiency, and ensuring that type definition files of the same version can be automatically merged. If the first request body fails to match the second request body, it indicates that the first type definition file generated based on the first request body is different from the third type definition file generated based on the second request body. Therefore, it is necessary to generate the first type definition file based on the first request body, thereby eliminating the need for back-end developers to manually write the first type definition file of the target interface, that is, automatically determining the first type definition file, reducing workload, improving development efficiency, and ensuring the diversity of type definition file versions.
[0136] Optionally, determining a second type definition file based on the second matching result includes:
[0137] If the second matching result indicates that the first response body and the second response body match successfully, the fourth type definition file in the first interface document is used as the second type definition file;
[0138] If the second matching result indicates that the first response body and the second response body fail to match, a second type definition file is generated based on the first response body.
[0139] In the embodiment of the present application, the cover function can be used to use the fourth type definition file of the first interface document as the second type definition file.
[0140] Among them, since the second interface information corresponds to a second response body, and the number of second interface information is 1 or N, if the number of second interface information is 1, the number of second response bodies is 1, and if the number of second interface information is N, the number of second response bodies is N, and N is an integer greater than 1. The specific process of generating a second type definition file based on the first response body is a prior art and will not be described in detail here.
[0141] Specifically, when the number of second response bodies is 1, the first response body is matched with the second response body to obtain a second matching result. If the second matching result indicates that the first response body and the second response body match successfully, the fourth type definition file in the first interface document is used as the second type definition file; if the second matching result indicates that the first response body and the second response body fail to match, the second type definition file is generated based on the first response body.
[0142] And determine the second type definition file based on the second matching result; if the number of second response bodies is N, match the first response body with the N second response bodies respectively to obtain N second matching results. If there is a second matching result indicating that the first response body and the second response body match successfully, the fourth type definition file of the first interface document corresponding to the second matching result indicating the successful match is used as the second type definition file; if the N second matching results all indicate that the first response body and the second response body fail to match, generate a second type definition file based on the first response body.
[0143] Since the present application uses the fourth type definition file in the first interface document as the second type definition file when the first response body matches the second response body successfully, there may be duplicate second response bodies when the number of second response bodies is N. Therefore, the present application needs to deduplicate the N second response bodies to reduce matching operations, reduce workload, and improve processing efficiency. The number of deduplicated second response bodies may be the same as or different from the number of deduplicated second request bodies.
[0144] Specifically, if the number of second response bodies is N, the N second response bodies are deduplicated to obtain W second response bodies, the first response body is matched with the W second response bodies respectively to obtain W second matching results, and the second type definition file is determined based on the W second matching results, where W is less than or equal to N.
[0145] For example, two first interface documents of the target interface, namely, the first interface document D and the first interface document F, are determined from the saved generated interface documents, the second interface information of the two first interface documents, namely, the second interface information d corresponding to the first interface document D, and the second interface information f corresponding to the first interface document F, and the second response bodies in the two second interface information, namely, the second response body 1 in the second interface information d, and the second response body 2 in the second interface information f, are determined. The first response body is matched with the second response body 1 to obtain the second matching result 1, and the first response body is matched with the second response body 2 to obtain the second matching result 2. If the second matching result 1 indicates that the first response body and the second response body 1 are matched successfully, the fourth type definition file in the first interface document D is used as the second type definition file. If both of the two second matching results indicate that the match fails, a second type definition file is generated based on the first response body.
[0146] If the second response bodies in the two determined second interface information are respectively the second response body 2 in the second interface information d and the second response body 2 in the second interface information f, it is determined that there are duplicate second response bodies in the two second response bodies, so a deduplication operation is performed to obtain the second response body 2. The first response body is matched with the second response body 2 to obtain a first matching result 1. If the first matching result 1 indicates that the first response body and the second response body 2 are matched successfully, the fourth type definition file in the first interface document D or the first interface document F is used as the second type definition file. If the first matching result 1 indicates that the first response body and the second response body 2 fail to match, a second type definition file is generated based on the first response body.
[0147] In an embodiment of the present application, if the first response body matches the second response body successfully, it indicates that the second type definition file generated based on the first response body is the same as the fourth type definition file generated based on the second response body. Therefore, there is no need to execute the process of generating the second type definition file based on the first response body, and the fourth type definition file in the first interface document is directly used as the second type definition file, thereby eliminating the need for back-end developers to manually write the second type definition file of the target interface, that is, automatically determining the second type definition file, reducing workload, improving development efficiency, and ensuring that type definition files of the same version can be automatically merged. If the first response body fails to match the second response body, it indicates that the second type definition file generated based on the first response body is different from the fourth type definition file generated based on the second response body. Therefore, it is necessary to generate the second type definition file based on the first response body, thereby eliminating the need for back-end developers to manually write the second type definition file of the target interface, that is, automatically determining the second type definition file, reducing workload, improving development efficiency, and ensuring the diversity of type definition file versions.
[0148] Optionally, before responding to the modification instruction of the target interface, the target interface may be displayed. Fig.13 is a flowchart of a method for displaying a target interface according to an exemplary embodiment. Fig.13 As shown, including:
[0149] Step 131, in response to a display instruction of a target interface, determining a third interface document of the target interface and third interface information of the third interface document;
[0150] Specifically, in response to the display instruction of the target interface, a third interface document of the target interface and third interface information of the third interface document are determined from the generated interface documents.
[0151] The display instruction of the target interface may be triggered by a user or by other means. The number of third interface documents may be 1 or K, and each third interface document corresponds to a third interface information. Therefore, if the number of third interface documents is 1, the number of third interface information is 1. If the number of third interface documents is K, the number of third interface information is K, and K is an integer greater than 1.
[0152] In an embodiment of the present application, the interface document corresponding to the target interface saved before responding to the display instruction of the target interface is used as the first interface document, for example, the interface document saved when the target interface is generated, the interface document saved when other target interfaces are displayed, the interface document saved when the target interface is modified, and other interface documents.
[0153] Step 132, matching the third attribute information of the interface information of the target interface with the fourth attribute information of the third interface information to obtain a second attribute information matching result;
[0154] Specifically, the third attribute information of the interface information of the target interface is matched with the fourth attribute information in the third interface information by using the differ function to obtain a second attribute information matching result.
[0155] The third attribute information of the interface information of the target interface includes at least one piece of attribute information, and the fourth attribute information of the third interface information includes at least one piece of attribute information.
[0156] Step 133: Determine a fourth interface document based on the second attribute information matching result.
[0157] In an embodiment of the present application, if the number of third interface information is 1, then the number of fourth attribute information is 1; if the number of third interface information is K, then the number of fourth attribute information is K, where K is an integer greater than 1.
[0158] Specifically, if the number of fourth attribute information is 1, the third attribute information is matched with the fourth attribute information to obtain a second attribute information matching result, and the fourth interface document is determined based on the second attribute information matching result. If the number of fourth attribute information is K, the third attribute information is matched with K fourth attribute information respectively to obtain K second attribute information matching results, and the fourth interface document is determined based on the K second attribute information matching results.
[0159] For example, Fig.14 is a schematic diagram of an interface showing interface information of a jsonSchema test interface according to an exemplary embodiment. Figure 6When you click the "Details Query" button corresponding to the jsonSchema test interface in the displayed interface, the interface information display instruction of the jsonSchema test interface is triggered, and the interface information of the jsonSchema test interface is displayed as follows: Fig.14 As shown, on this interface, the interface document of the jsonSchema test interface is displayed, and the interface document includes the interface information of the jsonSchema test interface, namely, the interface name, interface description, request method, request path, request header, request parameters and other attribute names and corresponding attribute values.
[0160] In an embodiment of the present application, in response to a display instruction of the target interface, the third interface document of the target interface and the third interface information of the third interface document are determined, the third attribute information of the interface information of the target interface is matched with the fourth attribute information of the third interface information, and the second attribute information matching result is obtained. Based on the second attribute information matching result, the fourth interface document is determined, thereby eliminating the need for back-end developers to write an interface document based on the interface information of the target interface, i.e., the fourth interface document is automatically determined, which reduces workload, improves modification efficiency, ensures the accuracy of the second interface document, and facilitates direct use by front-end developers, thereby reducing communication costs between front-end and back-end developers.
[0161] Optionally, determining the fourth interface document based on the second attribute information matching result includes:
[0162] If the second attribute information matching result indicates that the third attribute information matches the fourth attribute information successfully, the third interface document is used as the fourth interface document;
[0163] If the second attribute information matching result indicates that the third attribute information fails to match the fourth attribute information, a fourth interface document is generated based on the interface information of the target interface.
[0164] In the embodiment of the present application, the cover function can be used to make the first interface document the second interface document.
[0165] Specifically, when the number of fourth attribute information is 1, the third attribute information is matched with the fourth attribute information to obtain a second attribute information matching result, and if the second attribute information matching result indicates that the third attribute information matches the fourth attribute information successfully, the third interface document is used as the fourth interface document. If the second attribute information matching result indicates that the third attribute information matches the fourth attribute information unsuccessfully, a fourth interface document is generated based on the interface information of the target interface.
[0166] When the number of fourth attribute information is K, the third attribute information is matched with K fourth attribute information respectively to obtain K second attribute information matching results. If there is a second attribute information matching result indicating that the third attribute information matches the fourth attribute information successfully, the third interface document corresponding to the second attribute information matching result indicating a successful match is used as the fourth interface document. If the K second attribute information matching results all indicate that the third attribute information matches the fourth attribute information unsuccessfully, a fourth interface document is generated based on the interface information of the target interface, where K is an integer greater than 1.
[0167] In the embodiment of the present application, the specific process of generating the fourth interface document based on the interface information of the target interface is the same as the specific process of generating the second interface document based on the first interface information, and will not be repeated here.
[0168] In the embodiment of the present application, if the second attribute information matching result indicates that the third attribute information matches the fourth attribute information successfully, it indicates that the fourth interface document generated based on the interface information of the target interface is the same as the third interface document generated based on the third interface information. Therefore, there is no need to perform the process of generating the third interface document based on the interface information of the target interface, and the third interface document is directly used as the fourth interface document, so that the back-end developer does not need to write the corresponding interface document based on the interface information of the target interface, so as to achieve flexible processing of the interface information, reduce the workload, improve the modification efficiency, ensure the accuracy of the fourth interface document, and do not need to save the fourth interface document to ensure that the interface documents of the same version can be automatically merged. If the second attribute information matching result indicates that the third attribute information fails to match the fourth attribute information, it indicates that the fourth interface document generated based on the interface information of the target interface is different from the third interface document generated based on the third interface information. Therefore, it is necessary to generate the fourth interface document based on the interface information of the target interface, so that it is not necessary for the back-end developer to write the corresponding interface document based on the interface information of the target interface, so as to achieve flexible processing of the interface information, reduce the workload, improve the development efficiency, ensure the accuracy of the fourth interface document, and it is necessary to save the fourth interface document to ensure the diversity of the interface document version.
[0169] In an embodiment of the present application, when displaying the interface document of the target interface, the type definition files of different versions that have been generated corresponding to the saved target interface can be displayed, and in response to the download instruction of the target type definition file of the target interface, the target type definition file of the target interface is downloaded.
[0170] Among them, the interface document of the displayed target interface can be the interface document saved when the target interface is generated, the fourth interface document saved when the target interface is displayed, and the second interface document saved when the target interface is modified.
[0171] In the embodiment of the present application, the type definition file named get-api-list-500.res.reqbody.ts can be downloaded through the following download link:
[0172] (
[0173] / / Link to the / node / sample / src / get-api-list-500.res.resbody.ts page.
[0174] download="get-api-list-500.res.resbody.ts">
[0175] / / Download with the file name get-api-list-500.res.resbody.ts.
[0176] get-api-list-500.res.resbody.ts)
[0177] / / get-api-list-500.res.resbody.ts link.
[0178] Specifically, when a user clicks the "get-api-list-500.res.resbody.ts" link, the / node / sample / src / get-api-list-500.res.resbody.ts file starts downloading, and the default file name is get-api-list-500.res.resbody.ts.
[0179] Taking the second interface document of the target interface being displayed and the number of the first interface documents being 1 as an example, if the third type definition file in the first interface document is used as the first type definition file, and the fourth type definition file in the first interface document is used as the second type definition file, the third type definition file and the fourth type definition file are displayed; if the third type definition file in the first interface document is used as the first type definition file, and the second type definition file is generated based on the first response body, the third type definition file, the second type definition file, and the fourth type definition file are displayed; if the first type definition file is generated based on the first request body, and the fourth type definition file in the first interface document is used as the second type definition file, the first type definition file, the fourth type definition file, and the third type definition file are displayed; if the first type definition file is generated based on the first request body, and the second type definition file is generated based on the first response body, the first type definition file, the second type definition file, the third type definition file, and the fourth type definition file are displayed.
[0180] Taking the second interface document of the target interface being displayed, and the number of the first interface documents being greater than 1 as an example, if the third type definition file in the first interface document is used as the first type definition file, and the fourth type definition file in the first interface document is used as the second type definition file, it is determined that there is at least one third type definition file in the first interface document that is the same as the first type definition file, and there is at least one fourth type definition file in the first interface document that is the same as the second type definition file, therefore, it is necessary to perform a deduplication operation on the third type definition file and the fourth type definition file, and display the deduplicated third type definition file and the fourth type definition file. If the third type definition file in the first interface document is used as the first type definition file, and the second type definition file is generated based on the first response body, it is determined that there is at least one third type definition file in the first interface document that is the same as the first type definition file, therefore, it is necessary to perform a deduplication operation on the third type definition file and the fourth type definition file, and display the second type definition file, as well as the deduplicated third type definition file and the fourth type definition file.
[0181] If the first type definition file is generated based on the first request body, and the fourth type definition file in the first interface document is used as the second type definition file, it is determined that there is at least one fourth type definition file in the first interface document that is the same as the second type definition file, and therefore, it is necessary to perform a deduplication operation on the third type definition file and the fourth type definition file, and display the first type definition file, and the deduplication of the third type definition file and the fourth type definition file. If the first type definition file is generated based on the first request body, and the second type definition file is generated based on the first response body, the third type definition file and the fourth type definition file are deduplicated, and the first type definition file, the second type definition file, and the deduplication of the third type definition file and the fourth type definition file are displayed.
[0182] For example, Fig.12 As shown, the interface displays the interface document of the test interface. When the user clicks the "Type Definition File" button, an instruction to display the type definition file of the test interface is triggered. Fig.15 is a schematic diagram of a display interface of a type definition file corresponding to a test interface according to an exemplary embodiment. Fig.15 As shown, in the embodiment of the present application, the type definition file is divided into two categories, namely, the response body type definition file and the request body type definition file. The response body type definition file is a type definition file generated based on the response body, and the request body type definition file is a type definition file generated based on the request body. The interface displays 4 type definition files corresponding to the test interface, namely 1 request body type definition file and 3 response body type definition files. The user can click on the file name of the type definition file to trigger the download instruction of the type definition file. The user can click on "get-api-list.req.reqbody.ts" to trigger the download instruction of the type definition file named get-api-list.res.reqbody.ts, thereby downloading the type definition file named get-api-list.res.reqbody.ts. The user can click on "get-api-list-400.res.reqbody.ts" to trigger the download instruction of the type definition file named get-api-list-400.res.reqbody.ts, thereby downloading the type definition file named get-api-list.res.reqbody.ts.
[0183] Optionally, the method further comprises:
[0184] In response to the deletion instruction of the target interface, the interface information of the target interface is deleted, and the interface document of the target interface is deleted.
[0185] Specifically, in response to a deletion instruction of the target interface, the interface information of the target interface is deleted, and the interface document of the target interface is deleted from the generated interface documents.
[0186] The target interface deletion instruction may be triggered by a user or by other means. The target interface interface document includes various versions of interface documents generated during the period from when the user triggers the target interface generation instruction to when the user triggers the target interface deletion instruction.
[0187] For example, Figure 6 As shown, the interface displays the interface information of the jsonSchema test interface, test interface, Create user interface and Update an existing pet interface. When the user clicks the "Delete" button corresponding to the Update an existing pet interface, the delete instruction for the Update an existing pet interface is triggered, the interface information of the Update anexisting pet interface is deleted, and the interface document corresponding to the Update an existing pet interface is deleted from the generated interface document. Fig.16 is a schematic diagram of an interface for deleting a target interface according to an exemplary embodiment. The target interface is the Update an existing pet interface. After deleting the interface information of the Update an existing pet interface and deleting the interface document corresponding to the Update an existing pet interface from the generated interface documents, the interface displayed is as follows: Fig.16 As shown, this interface displays the interface information of the jsonSchema test interface, the test interface, and the Create user interface.
[0188] In an embodiment of the present application, in response to a deletion instruction of the target interface triggered by a user, the interface information of the target interface is deleted, and the interface document of the target interface is deleted, thereby achieving flexible processing of the interface information, reducing workload, and improving development efficiency.
[0189] Based on the same inventive concept, the present application embodiment provides an interface information processing device, please refer to Fig.17 , the device comprises:
[0190] A modification module 171, configured to modify the interface information of the target interface in response to a modification instruction of the target interface to obtain first interface information;
[0191] A first determining module 172, configured to determine a first interface document corresponding to the target interface and second interface information of the first interface document from the generated interface documents;
[0192] A matching module 173, configured to match the first attribute information of the first interface information with the second attribute information of the second interface information to obtain a first attribute information matching result;
[0193] The second determination module 174 is used to determine a second interface document based on the first attribute information matching result.
[0194] As an optional implementation manner, the second determining module 174 is configured to:
[0195] If the first attribute information matching result indicates that the first attribute information matches the second attribute information successfully, the first interface document is used as the second interface document;
[0196] If the first attribute information matching result indicates that the first attribute information fails to match the second attribute information, the second interface document is generated based on the first interface information.
[0197] As an optional implementation manner, the second interface document includes a first type definition file and a second type definition file, and the second determination module 174 is used to:
[0198] Matching the first request body of the first interface information with the second request body of the second interface information to obtain a first matching result, and determining the first type definition file based on the first matching result;
[0199] The first response body of the first interface information is matched with the second response body of the second interface information to obtain a second matching result, and the second type definition file is determined based on the second matching result.
[0200] As an optional implementation manner, the second determining module 174 is configured to:
[0201] If the first matching result indicates that the first request body matches the second request body successfully, using the third type definition file of the first interface document as the first type definition file;
[0202] If the first matching result indicates that the first request body fails to match the second request body, the first type definition file is generated based on the first request body.
[0203] As an optional implementation manner, the second determining module 174 is configured to:
[0204] If the second matching result indicates that the first response body and the second response body match successfully, using the fourth type definition file in the first interface document as the second type definition file;
[0205] If the second matching result indicates that the first response body and the second response body fail to match, the second type definition file is generated based on the first response body.
[0206] As an optional implementation manner, before responding to the modification instruction of the target interface, the modification module 171 is further configured to:
[0207] In response to the display instruction of the target interface, determining a third interface document of the target interface and third interface information of the third interface document;
[0208] Matching the third attribute information of the interface information of the target interface with the fourth attribute information of the third interface information to obtain a second attribute information matching result;
[0209] Based on the second attribute information matching result, a fourth interface document is determined.
[0210] As an optional implementation, the modification module 171 is used to:
[0211] If the second attribute information matching result indicates that the third attribute information matches the fourth attribute information successfully, the third interface document is used as the fourth interface document;
[0212] If the second attribute information matching result indicates that the third attribute information fails to match the fourth attribute information, the fourth interface document is generated based on the interface information of the target interface.
[0213] As an optional implementation, the modification module 171 is used to:
[0214] Based on the modification instruction, displaying a modification interface including the interface information of the target interface, wherein the interface information of the target interface includes at least one piece of attribute information;
[0215] Determine the candidate attribute information to be modified based on the editing operation on the modification interface, and modify the interface information of the target interface based on the candidate attribute information to obtain the modified interface information;
[0216] In response to the modification completion instruction, the modified interface information is used as the first interface information.
[0217] As an optional implementation manner, the attribute information includes an attribute name and a corresponding attribute value; before responding to the modification instruction of the target interface, the modification module 171 is further used to:
[0218] In response to the target interface generation instruction, displaying a generation interface including a plurality of attribute names;
[0219] Based on the editing operation on the generation interface, determine the attribute value of at least one attribute name to obtain at least one piece of attribute information;
[0220] In response to the generation completion instruction, interface information of the target interface is generated based on the at least one piece of attribute information.
[0221] Based on the same inventive concept, the embodiment of the present application provides an electronic device, which can implement the interface information processing function discussed above, please refer to Fig.18 , the device comprises a processor 181 and a memory 182, wherein the memory 182 is used to store program instructions;
[0222] The processor 181 calls the program instructions stored in the memory, and implements the interface information processing method provided in the above embodiment by running the program instructions:
[0223] In response to a modification instruction of the target interface, modify the interface information of the target interface to obtain first interface information;
[0224] Determine a first interface document of the target interface and second interface information of the first interface document;
[0225] Matching the first attribute information of the first interface information with the second attribute information of the second interface information to obtain a first attribute information matching result;
[0226] Based on the first attribute information matching result, a second interface document is determined.
[0227] The processor 181 implements the steps of the interface information processing method provided in the above embodiment by running the executable instructions, and the repeated parts are not repeated here.
[0228] Based on the same inventive concept, the embodiment of the present application provides a computer-readable storage medium, and the computer program product includes: computer program code, when the computer program code is run on a computer, the computer executes any of the interface information processing methods discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the interface information processing method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0229] Based on the same inventive concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the interface information processing methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the interface information processing method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0230] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0231] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0232] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0233] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of user-operated steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0234] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. An interface information processing method, characterized in that: The method comprises: In response to a modification instruction of the target interface, modify the interface information of the target interface to obtain first interface information; Determine a first interface document of the target interface and second interface information of the first interface document; Matching the first attribute information of the first interface information with the second attribute information of the second interface information to obtain a first attribute information matching result; Based on the first attribute information matching result, a second interface document is determined.
2. The method according to claim 1, characterized in that The determining the second interface document based on the first attribute information matching result includes: If the first attribute information matching result indicates that the first attribute information matches the second attribute information successfully, the first interface document is used as the second interface document; If the first attribute information matching result indicates that the first attribute information fails to match the second attribute information, the second interface document is generated based on the first interface information.
3. The method according to claim 2, characterized in that The second interface document includes a first type definition file and a second type definition file, and generating the second interface document based on the first interface information includes: Matching the first request body of the first interface information with the second request body of the second interface information to obtain a first matching result, and determining the first type definition file based on the first matching result; The first response body of the first interface information is matched with the second response body of the second interface information to obtain a second matching result, and the second type definition file is determined based on the second matching result.
4. The method according to claim 3, characterized in that The determining the first type definition file based on the first matching result includes: If the first matching result indicates that the first request body matches the second request body successfully, using the third type definition file of the first interface document as the first type definition file; If the first matching result indicates that the first request body fails to match the second request body, the first type definition file is generated based on the first request body.
5. The method according to claim 3, characterized in that The determining the second type definition file based on the second matching result includes: If the second matching result indicates that the first response body and the second response body match successfully, using the fourth type definition file in the first interface document as the second type definition file; If the second matching result indicates that the first response body and the second response body fail to match, the second type definition file is generated based on the first response body.
6. The method according to claim 1, characterized in that Before responding to the modification instruction of the target interface, the method further includes: In response to the display instruction of the target interface, determining a third interface document of the target interface and third interface information of the third interface document; Matching the third attribute information of the interface information of the target interface with the fourth attribute information of the third interface information to obtain a second attribute information matching result; Based on the second attribute information matching result, a fourth interface document is determined.
7. The method according to claim 6, characterized in that The determining the fourth interface document based on the second attribute information matching result includes: If the second attribute information matching result indicates that the third attribute information matches the fourth attribute information successfully, the third interface document is used as the fourth interface document; If the second attribute information matching result indicates that the third attribute information fails to match the fourth attribute information, the fourth interface document is generated based on the interface information of the target interface.
8. The method according to claim 1, characterized in that The modifying the interface information of the target interface to obtain the first interface information includes: Based on the modification instruction, displaying a modification interface including the interface information of the target interface, wherein the interface information of the target interface includes at least one piece of attribute information; Determine the candidate attribute information to be modified based on the editing operation on the modification interface, and modify the interface information of the target interface based on the candidate attribute information to obtain the modified interface information; In response to the modification completion instruction, the modified interface information is used as the first interface information.
9. The method according to claim 1, characterized in that The attribute information includes an attribute name and a corresponding attribute value; before responding to the modification instruction of the target interface, it also includes: In response to the target interface generation instruction, displaying a generation interface including a plurality of attribute names; Based on the editing operation on the generation interface, determine the attribute value of at least one attribute name to obtain at least one piece of attribute information; In response to the generation completion instruction, interface information of the target interface is generated based on the at least one piece of attribute information.
10. An interface information processing device, characterized in that: The device comprises: A modification module, configured to modify the interface information of the target interface in response to a modification instruction of the target interface to obtain first interface information; A first determination module, used to determine a first interface document corresponding to the target interface and second interface information of the first interface document from the generated interface documents; a matching module, configured to match the first attribute information of the first interface information with the second attribute information of the second interface information to obtain a first attribute information matching result; The second determination module is used to determine a second interface document based on the first attribute information matching result.
11. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods of claims 1-9 according to the obtained program instructions.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 9.
