CN110795084A - Method, device and equipment for generating interface description file and readable storage medium - Google Patents

Method, device and equipment for generating interface description file and readable storage medium Download PDF

Info

Publication number
CN110795084A
CN110795084A CN201911060384.5A CN201911060384A CN110795084A CN 110795084 A CN110795084 A CN 110795084A CN 201911060384 A CN201911060384 A CN 201911060384A CN 110795084 A CN110795084 A CN 110795084A
Authority
CN
China
Prior art keywords
data
http
interface
request
description file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911060384.5A
Other languages
Chinese (zh)
Other versions
CN110795084B (en
Inventor
王毅
张志欢
楚正
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911060384.5A priority Critical patent/CN110795084B/en
Publication of CN110795084A publication Critical patent/CN110795084A/en
Application granted granted Critical
Publication of CN110795084B publication Critical patent/CN110795084B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Abstract

The embodiment of the application provides a method, a device, equipment and a readable storage medium for generating an interface description file, wherein the method comprises the following steps: receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment; collecting and grouping HTTP request data and HTTP response data to obtain first interface definition data; according to the first interface definition data, big data analysis is carried out on HTTP request data and HTTP response data to obtain second interface definition data; and generating the interface description file according to the second interface definition data and a preset format of the interface description file. The method realizes that the interface description file is generated by analyzing HTTP request data and HTTP response data without precondition dependence; the method is independent of development languages and running environments, does not need strict code development specifications, greatly improves usability and practicability, does not increase development workload, and does not increase any requirement and workload for the existing interface service.

Description

Method, device and equipment for generating interface description file and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a readable storage medium for generating an interface description file.
Background
In the prior art, all the ways of generating interface description files have obvious prerequisite dependencies, for example, the prerequisite dependencies include existing standardized codes, Javadoc files or customized configuration files, and the prerequisite dependencies all need to have very good development habits and standard supports, for example, standardized code writing and structures, clear comments and the like. In the prior art, the method for generating the interface description file has higher requirements on developers, and the effect of finally generating the interface description file is greatly reduced, for example, the support of multiple languages is not enough, the format limitation of the configuration file is limited, and the like.
Disclosure of Invention
The application provides a method, a device, an electronic device and a computer-readable storage medium for generating an interface description file, aiming at the defects of the existing mode, so as to solve the problem of how to generate the interface description file without precondition dependence.
In a first aspect, the present application provides a method for generating an interface description file, which is applied to a server, and includes:
receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment;
collecting and grouping HTTP request data and HTTP response data to obtain first interface definition data;
according to the first interface definition data, big data analysis is carried out on HTTP request data and HTTP response data to obtain second interface definition data;
and generating an interface description file according to the second interface definition data and a preset format of the interface description file.
Optionally, the first device includes at least one of an application program interface API gateway and a Web Server, the first device is configured to receive an HTTP request sent by a client and obtain HTTP request data corresponding to the HTTP request according to the HTTP request, and the first device is further configured to send an HTTP response to the client and obtain HTTP response data corresponding to the HTTP response according to the HTTP response.
Optionally, the first interface definition data comprises at least one of:
domain name, interface path, request method, parameter, request header, request content body, response code, response header, response content body.
Optionally, the summarizing and grouping the HTTP request data and the HTTP response data to obtain first interface definition data includes:
summarizing data of the same domain name in HTTP request data and HTTP response data to a first hierarchy in the same multidimensional data packet;
summarizing the data of the same interface path in the first level to a second level in the same multidimensional data grouping;
summarizing the data of the same request method in the second hierarchy to a third hierarchy in the same multidimensional data grouping;
obtaining data in a fourth level in the same multidimensional data grouping according to the request method, wherein the data in the fourth level comprises at least one of parameters, a request header, a request content body and a response code;
and obtaining first interface definition data according to the domain name, the interface path, the request method and the data in the fourth hierarchy, wherein the same multidimensional data packet comprises the structure of the first interface definition data.
Optionally, when the data in the fourth hierarchy includes a response code, the method further includes:
and summarizing the data of the same response code in the fourth level to a fifth level in the same multidimensional data packet, wherein the data in the fifth level comprises at least one of a response head and a response content body.
Optionally, according to the first interface definition data, performing big data analysis on the HTTP request data and the HTTP response data to obtain second interface definition data, including:
dividing HTTP request data and HTTP response data into at least one data type according to first interface definition data, and obtaining a numerical range corresponding to the data of the at least one data type;
second interface definition data is obtained according to at least one data type and a value range.
Optionally, after generating the interface description file according to the second interface definition data and a preset format of the interface description file, the method further includes:
and generating a calling code of the client according to the interface description file, wherein the calling code of the client encapsulates the HTTP request.
In a second aspect, the present application provides an apparatus for generating an interface description file, which is applied to a server, and includes:
the first processing module is used for receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment;
the second processing module is used for summarizing and grouping the HTTP request data and the HTTP response data to obtain first interface definition data;
the third processing module is used for carrying out big data analysis on the HTTP request data and the HTTP response data according to the first interface definition data to obtain second interface definition data;
and the fourth processing module is used for generating the interface description file according to the second interface definition data and the preset format of the interface description file.
Optionally, the first device includes at least one of an application program interface API gateway and a Web Server, the first device is configured to receive an HTTP request sent by a client and obtain HTTP request data corresponding to the HTTP request according to the HTTP request, and the first device is further configured to send an HTTP response to the client and obtain HTTP response data corresponding to the HTTP response according to the HTTP response.
Optionally, the first interface definition data comprises at least one of:
domain name, interface path, request method, parameter, request header, request content body, response code, response header, response content body.
Optionally, the second processing module is specifically configured to summarize data of the same domain name in the HTTP request data and the HTTP response data to a first hierarchy in the same multidimensional data packet; summarizing the data of the same interface path in the first level to a second level in the same multidimensional data grouping; summarizing the data of the same request method in the second hierarchy to a third hierarchy in the same multidimensional data grouping; obtaining data in a fourth level in the same multidimensional data grouping according to the request method, wherein the data in the fourth level comprises at least one of parameters, a request header, a request content body and a response code; and obtaining first interface definition data according to the domain name, the interface path, the request method and the data in the fourth hierarchy, wherein the same multidimensional data packet comprises the structure of the first interface definition data.
Optionally, when the data in the fourth hierarchy includes a response code, the second processing module 602 is specifically configured to summarize the data of the same response code in the fourth hierarchy into a fifth hierarchy in the same multidimensional data packet, where the data in the fifth hierarchy includes at least one of a response header and a response content.
Optionally, the third processing module is specifically configured to define data according to the first interface, divide the HTTP request data and the HTTP response data into at least one data type, and obtain a numerical range corresponding to the data of the at least one data type; second interface definition data is obtained according to at least one data type and a value range.
Optionally, after the fourth processing module generates the interface description file according to the second interface definition data and the preset format of the interface description file, the fourth processing module is further specifically configured to generate a calling code of the client according to the interface description file, where the calling code of the client encapsulates the HTTP request.
In a third aspect, the present application provides an electronic device, comprising: a processor, a memory, and a bus;
a bus for connecting the processor and the memory;
a memory for storing operating instructions;
and the processor is used for executing the method for generating the interface description file in the first aspect of the application by calling the operation instruction.
In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program for executing the method for generating an interface description file of the first aspect of the present application.
The technical scheme provided by the embodiment of the application at least has the following beneficial effects:
receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment; collecting and grouping HTTP request data and HTTP response data to obtain first interface definition data; according to the first interface definition data, big data analysis is carried out on HTTP request data and HTTP response data to obtain second interface definition data; and generating the interface description file according to the second interface definition data and a preset format of the interface description file. According to the scheme of the embodiment of the application, the interface description file is generated by analyzing the HTTP request data and the HTTP response data without the need of precondition dependence; the scheme of the embodiment of the application is independent of development languages, independent of running environments, free of strict code development specifications and free of any limitation and special requirements on developers, so that the usability and the practicability are greatly improved, the development workload is not increased, and any requirements and workload on the existing interface service are not increased.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic flowchart of a method for generating an interface description file according to an embodiment of the present application;
fig. 2 is a schematic diagram of a structure of interface definition data provided in an embodiment of the present application;
FIG. 3 is a schematic diagram of big data analysis provided by an embodiment of the present application;
FIG. 4 is a schematic diagram of big data analysis provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of generating an interface description file according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an apparatus for generating an interface description file according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, features and advantages of the present invention more apparent and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
Artificial Intelligence (AI) is a theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human Intelligence, perceive the environment, acquire knowledge and use the knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technique of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a manner similar to human intelligence. Artificial intelligence is the research of the design principle and the realization method of various intelligent machines, so that the machines have the functions of perception, reasoning and decision making.
The artificial intelligence technology is a comprehensive subject and relates to the field of extensive technology, namely the technology of a hardware level and the technology of a software level. The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning or deep learning and the like.
Machine Learning (ML) is a multi-domain cross discipline, and relates to a plurality of disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and the like. The special research on how a computer simulates or realizes the learning behavior of human beings so as to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve the performance of the computer. Machine learning is the core of artificial intelligence, is the fundamental approach for computers to have intelligence, and is applied to all fields of artificial intelligence. Machine learning and deep learning generally include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and formal education learning.
For better understanding and description of the embodiments of the present application, some technical terms used in the embodiments of the present application will be briefly described below.
Big data analysis: the method is used for analyzing large-scale data, and the large data needs an artificial intelligence technology to perform data value operation, for example, machine learning is a common mode for analyzing the large data.
The technical solution provided by the embodiment of the present application relates to machine learning of artificial intelligence, and the following detailed description is provided for the technical solution of the present application and how to solve the above technical problems with the technical solution of the present application. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Example one
The embodiment of the application provides a method for generating an interface description file, a flow diagram of the method is shown in fig. 1, and the method comprises the following steps:
s101, receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment.
Optionally, the first device comprises at least one of an application program interface, API, gateway, a Web Server, Web Server. The Web Server can analyze the HTTP protocol, when the Web Server receives an HTTP request sent by the client, the Web Server will return an HTTP response to the client.
Optionally, the API gateway or the Web Server fetches HTTP request data from an HTTP request, and the API gateway or the Web Server fetches HTTP response data from an HTTP response. Capturing HTTP request data and HTTP response data through a plug-in running on an API gateway or a Web Server; and capturing HTTP request data and HTTP response data through a log function of the API gateway or a log function of the Web Server. The API gateway is envoy, the Webserver is nginx, data capture can be directly performed through the lua script, and other gateways or webservers can also support plug-in development or log configuration functions similarly to complete capture of HTTP request data and HTTP response data. The envoy and the nginx both support the development of lua plug-in, and the nginx and the tomcat both support log configuration, and the methods can capture complete HTTP request data and HTTP response data. lua is a lightweight and compact scripting language written in standard C language and open in source code form, designed to be embedded in applications to provide flexible extension and customization of applications. tomcat is a free Web application server with open source codes, belongs to a lightweight application server, and is generally used in small and medium-sized systems and occasions where concurrent access users are not many.
S102, collecting and grouping the HTTP request data and the HTTP response data to obtain first interface definition data.
Optionally, the first interface defines the structure of the data as a hierarchy. The first interface definition data is a complete and complete interface definition data, the first interface definition data is a multidimensional array, the first interface definition data realizes the grouping of HTTP request data and HTTP response data, and the same HTTP request data and HTTP response data are combined together.
And S103, according to the first interface definition data, performing big data analysis on the HTTP request data and the HTTP response data to obtain second interface definition data.
Optionally, the data type of the accurately obtained interface and the numerical range corresponding to the data belonging to the data type are refined through big data analysis, and second interface definition data is obtained according to the data type and the numerical range, wherein the second interface definition data is accurate and complete interface definition data.
And S104, generating an interface description file according to the second interface definition data and the preset format of the interface description file.
Alternatively, the interface description file is an interface description file in a standardized openapi3.0 format, and the interface description file in the openapi3.0 format can very fully define and describe information of an interface, such as a domain name, a version, an interface address, a description, a parameter type, a default value, response information, and the like.
In the embodiment of the application, hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment are received; collecting and grouping HTTP request data and HTTP response data to obtain first interface definition data; according to the first interface definition data, big data analysis is carried out on HTTP request data and HTTP response data to obtain second interface definition data; and generating the interface description file according to the second interface definition data and a preset format of the interface description file. According to the scheme of the embodiment of the application, the interface description file is generated by analyzing the HTTP request data and the HTTP response data without the need of precondition dependence; the scheme of the embodiment of the application is independent of development languages, independent of running environments, free of strict code development specifications and free of any limitation and special requirements on developers, so that the usability and the practicability are greatly improved, the development workload is not increased, and any requirements and workload on the existing interface service are not increased.
Optionally, the first device includes at least one of an application program interface API gateway and a Web Server, the first device is configured to receive an HTTP request sent by a client and obtain HTTP request data corresponding to the HTTP request according to the HTTP request, and the first device is further configured to send an HTTP response to the client and obtain HTTP response data corresponding to the HTTP response according to the HTTP response.
Optionally, the first interface definition data comprises at least one of:
domain name, interface path, request method, parameter, request header, request content body, response code, response header, response content body.
Optionally, the summarizing and grouping the HTTP request data and the HTTP response data to obtain first interface definition data includes:
summarizing data of the same domain name in HTTP request data and HTTP response data to a first hierarchy in the same multidimensional data packet;
summarizing the data of the same interface path in the first level to a second level in the same multidimensional data grouping;
summarizing the data of the same request method in the second hierarchy to a third hierarchy in the same multidimensional data grouping;
obtaining data in a fourth level in the same multidimensional data grouping according to the request method, wherein the data in the fourth level comprises at least one of parameters, a request header, a request content body and a response code;
and obtaining first interface definition data according to the domain name, the interface path, the request method and the data in the fourth hierarchy, wherein the same multidimensional data packet comprises the structure of the first interface definition data.
Optionally, when the data in the fourth hierarchy includes a response code, the method further includes:
and summarizing the data of the same response code in the fourth level to a fifth level in the same multidimensional data packet, wherein the data in the fifth level comprises at least one of a response head and a response content body.
Optionally, as shown in fig. 2, the interface definition data is first interface definition data, and the interface definition data includes a domain name host, an interface path uri, a request method, a parameter query, a request header request _ header, a request content body request _ body, a response code response _ code, a response header response _ header, and a response content body response _ body. Summarizing the data of the same domain name uri in the HTTP request data and the HTTP response data to a first hierarchy in the same multidimensional data packet; summarizing the data of the same interface path uri in the first level to a second level in the same multidimensional data grouping; summarizing the data of the same request method in the second level to a third level in the same multidimensional data grouping; obtaining data in a fourth level in the same multidimensional data packet according to the request method, wherein the data in the fourth level comprises a parameter query, a request header request _ header, a request content body request _ body and a response code response _ code; and summarizing the data of the same response code response _ code in the fourth level to a fifth level in the same multidimensional data packet, wherein the data in the fifth level comprises a response header response _ header and a response content body response _ body. The first level, the second level, the third level, the fourth level and the fifth level constitute a hierarchy of interface definition data, which is a multidimensional array.
Optionally, according to the first interface definition data, performing big data analysis on the HTTP request data and the HTTP response data to obtain second interface definition data, including:
dividing HTTP request data and HTTP response data into at least one data type according to first interface definition data, and obtaining a numerical range corresponding to the data of the at least one data type;
second interface definition data is obtained according to at least one data type and a value range.
Optionally, as shown in fig. 3, the original data is HTTP request data and HTTP response data, which are analyzed and verified based on a large amount of HTTP request data and HTTP response data, so as to ensure that the second interface definition data is obtained more accurately according to the first interface definition data. For example, when there is only one HTTP request data mass and one HTTP response data mass, it is considered that the data types of the HTTP request data and the HTTP response data are character string types, and when there are another 10 ten thousand HTTP request data and HTTP response data, these 10 ten thousand HTTP request data and HTTP response data are also mass, then after a large amount of data analysis, it can be determined that the data types of the HTTP request data and the HTTP response data are character string types, and the value is only mass; when 10 ten thousand HTTP request data female and HTTP response data female appear, analyzing that the data types of the HTTP request data and the HTTP response data are character string types, and the enumerated values are male and female; the result can be used for continuously verifying more HTTP request data and HTTP response data, and the analysis result with high probability is set as a final result, so that the accuracy of the first interface definition data is confirmed, and more accurate second interface definition data is obtained. As shown in fig. 4, the HTTP request data and the HTTP response data may also have other types of data, such as numbers, arrays, dates, and the like, and the more accurate second interface definition data is obtained based on analysis of big data and verification of more data, so as to ensure accurate and reliable results. As shown in fig. 4, the original data is HTTP request data and HTTP response data, the numbers of occurrences dispersed in the original data are 1 to N, N is a positive integer, and the number of occurrences of each number is also averaged, so that it can be determined that the data type is a number, for example, the data type of 3 is a number, and the value range is 0 to int.max, where int.max represents the maximum value that the integer type can represent, and the number 10 is within the value range.
Optionally, after generating the interface description file according to the second interface definition data and a preset format of the interface description file, the method further includes:
and generating a calling code of the client according to the interface description file, wherein the calling code of the client encapsulates the HTTP request.
Optionally, the automatically generated interface description file is further output in a templatized manner, so that the calling code of the client can be generated. The client call code, most importantly, the interface request, i.e. the HTTP request, can obtain the interface definition and key information, i.e. domain name, interface address, parameters and return value, required in the HTTP request according to the interface description file, so the client call code can be automatically generated, Uniform Resource Identifier (URI) of each HTTP request is encapsulated as a method, each request parameter is defined as a parameter of the call method, and the response is defined as a return value of the method.
In the embodiment of the application, because only HTTP request data and HTTP response data need to be captured on the API gateway or the Web Server, the time of developers is not increased, new requirements on development are not provided, and direct association and influence on the existing system development are not required; the compiling and updating of the interface description file can be automatically completed according to a large amount of captured HTTP request data and HTTP response data, and the document compiling and maintaining work of developers can be greatly reduced; and one interface description file is updated in time and accurately expressed, so that for cooperative development and more Internet applications, the development joint debugging efficiency can be greatly improved, and the communication time and debugging time increased due to unclear documents are reduced.
In order to better understand the method provided by the embodiment of the present application, the following describes the scheme of the embodiment of the present application in further detail with reference to an example of a specific application scenario.
As shown in fig. 5, the API gateway or the Web Server receives an HTTP request sent by the client, and the API gateway or the Web Server returns an HTTP response to the client. An API gateway or a Web Server captures HTTP request data from an HTTP request and captures HTTP response data from an HTTP response through a plug-in running on the API gateway or the WebServer; the API gateway can also grab HTTP request data from the HTTP request and grab HTTP response data from the HTTP response through the log function of the API gateway; the Web Server can also grab the HTTP request data from the HTTP request and grab the HTTP response data from the HTTP response by the log function of the Web Server. The interface request data in fig. 5 includes HTTP request data and HTTP response data, the API gateway or the Web Server sends the HTTP request data and the HTTP response data to the Server, the Server performs summary packet processing on the HTTP request data and the HTTP response data to obtain first interface definition data, the Server performs big data analysis on the HTTP request data and the HTTP response data according to the first interface definition data to obtain second interface definition data, and generates an interface description file in an openapi3.0 format according to the second interface definition data and a preset openapi3.0 format of the interface description file. The daily work performed by the API gateway or the Web Server in fig. 5 further includes: and sending the request (HTTP request) and the response (HTTP response) to the interface server side for interface service.
Optionally, client (application A) requests an interface http:// localhost/userinfo? And id is 1, and the return value of the interface is { "sender": "female", "username": microhaey }. The HTTP request data and the HTTP response data can be captured by the Api gateway or the Webserver, where the HTTP request data is as follows:
GET http://localhost/userinfo?id=1HTTP/1.1
Host:monitor_alarm.odptcp.oa.com
Proxy-Connection:keep-alive
Pragma:no-cache
Cache-Control:no-cache
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0(Macintosh;Intel Mac OS X 10_14_5)AppleWebKit/537.36(KHTML,like Gecko)Chrome/76.0.3809.100Safari/537.36
DNT:1
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding:gzip,deflate
Accept-Language:zh-CN,zh;q=0.9
Cookie:t_uid=michaey;dm_uid=michaey
the HTTP response data is as follows:
HTTP/1.1 200OK
x-proxy-by:SmartGate-IDC
access-control-allow-credentials:true
access-control-allow-headers:Content-Type,Access-Token,Cookie
access-control-allow-methods:*
access-control-expose-headers:*
app-since:137h13m19.982710693s
content-type:application/json;charset=UTF-8
date:Thu,24Oct 2019 01:37:50GMT
x-envoy-upstream-service-time:5
x-request-id:e3465bc2-9bf9-4b9f-9312-5460986806e1
transfer-encoding:chunked
connection:keep-alive
x-forwarded-for:10.57.180.55,9.19.161.66,10.14.87.209
content-encoding:gzip
x-rio-seq:k241eknh-147916870
{"gender":"female","username":"michaey"}
optionally, the format of the first interface definition data is as follows:
$data["localhost"]["/userinfo"]["get"]["request"]["header"]=[]
$data["localhost"]["/userinfo"]["get"]["request"]["query"]=[{"id":"1"}]
$data["localhost"]["/userinfo"]["get"]["request"]["body"]=""
$data["localhost"]["/userinfo"]["get"]["response"]["200"]["header"]=[]
$data["localhost"]["/userinfo"]["get"]["response"]["200"]["body"]="
{\"gender\":\"female\",\"username\":\"michaey\"}"
the first interface definition data is all from HTTP request data and HTTP response data, and the HTTP request data and the HTTP response data of pure character string type are converted into structured data which is easier to use in the program, namely the first interface definition data is structured data.
Optionally, the interface description file in openapi3.0 format is as follows:
Figure BDA0002257776530000141
Figure BDA0002257776530000151
optionally, the automatically generated test case is directly from the captured HTTP request data and HTTP response data, the HTTP request data and the HTTP response data may be used to construct and initiate a test request for the online interface service, and from the return value, the test case may be compared with the original HTTP response data to verify whether the HTTP response of the online interface service is correct.
According to the embodiment of the application, the interface description file is generated by analyzing HTTP request data and HTTP response data without the need of precondition dependence; the scheme of the embodiment of the application is independent of development languages, independent of running environments, free of strict code development specifications and free of any limitation and special requirements on developers, so that the usability and the practicability are greatly improved, the development workload is not increased, and any requirements and workload on the existing interface service are not increased.
Example two
Based on the same inventive concept, an apparatus for generating an interface description file is further provided in the embodiments of the present application, and a schematic structural diagram of the apparatus is shown in fig. 6, and the apparatus 60 for generating an interface description file includes a first processing module 601, a second processing module 602, a third processing module 603, and a fourth processing module 604.
A first processing module 601, configured to receive hypertext transfer protocol HTTP request data and HTTP response data sent by a first device;
the second processing module 602 is configured to perform summary and packet processing on the HTTP request data and the HTTP response data to obtain first interface definition data;
a third processing module 603, configured to perform big data analysis on the HTTP request data and the HTTP response data according to the first interface definition data to obtain second interface definition data;
the fourth processing module 604 is configured to generate an interface description file according to the second interface definition data and a preset format of the interface description file.
Optionally, the first device includes at least one of an application program interface API gateway and a Web Server, the first device is configured to receive an HTTP request sent by a client and obtain HTTP request data corresponding to the HTTP request according to the HTTP request, and the first device is further configured to send an HTTP response to the client and obtain HTTP response data corresponding to the HTTP response according to the HTTP response.
Optionally, the first interface definition data comprises at least one of:
domain name, interface path, request method, parameter, request header, request content body, response code, response header, response content body.
Optionally, the second processing module 602 is specifically configured to summarize data of the same domain name in HTTP request data and HTTP response data into a first hierarchy in the same multidimensional data packet; summarizing the data of the same interface path in the first level to a second level in the same multidimensional data grouping; summarizing the data of the same request method in the second hierarchy to a third hierarchy in the same multidimensional data grouping; obtaining data in a fourth level in the same multidimensional data grouping according to the request method, wherein the data in the fourth level comprises at least one of parameters, a request header, a request content body and a response code; and obtaining first interface definition data according to the domain name, the interface path, the request method and the data in the fourth hierarchy, wherein the same multidimensional data packet comprises the structure of the first interface definition data.
Optionally, when the data in the fourth hierarchy includes a response code, the second processing module 602 is specifically configured to summarize the data of the same response code in the fourth hierarchy into a fifth hierarchy in the same multidimensional data packet, where the data in the fifth hierarchy includes at least one of a response header and a response content.
Optionally, the third processing module 603 is specifically configured to divide the HTTP request data and the HTTP response data into at least one data type according to the first interface definition data, and obtain a numerical range corresponding to data of the at least one data type; second interface definition data is obtained according to at least one data type and a value range.
Optionally, after the fourth processing module 604 generates the interface description file according to the second interface definition data and the preset format of the interface description file, the fourth processing module 604 is further specifically configured to generate a calling code of the client according to the interface description file, where the calling code of the client encapsulates the HTTP request.
For the content that is not described in detail in the apparatus for generating an interface description file provided in the embodiment of the present application, reference may be made to the method for generating an interface description file provided in the first embodiment of the present application, and beneficial effects that can be achieved by the apparatus for generating an interface description file provided in the embodiment of the present application are the same as those achieved by the method for generating an interface description file provided in the first embodiment of the present application, and are not described herein again.
The application of the embodiment of the application has at least the following beneficial effects:
receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment; collecting and grouping HTTP request data and HTTP response data to obtain first interface definition data; according to the first interface definition data, big data analysis is carried out on HTTP request data and HTTP response data to obtain second interface definition data; and generating the interface description file according to the second interface definition data and a preset format of the interface description file. According to the scheme of the embodiment of the application, the interface description file is generated by analyzing the HTTP request data and the HTTP response data without the need of precondition dependence; the scheme of the embodiment of the application is independent of development languages, independent of running environments, free of strict code development specifications and free of any limitation and special requirements on developers, so that the usability and the practicability are greatly improved, the development workload is not increased, and any requirements and workload on the existing interface service are not increased.
EXAMPLE III
Based on the same inventive concept, an embodiment of the present application further provides an electronic device, a schematic structural diagram of the electronic device is shown in fig. 7, the electronic device 6000 includes at least one processor 6001, a memory 6002, and a bus 6003, and each of the at least one processor 6001 is electrically connected to the memory 6002; the memory 6002 is configured to store at least one computer-executable instruction, and the processor 6001 is configured to execute the at least one computer-executable instruction to perform the steps of any method for generating an interface description file as provided in any one of the embodiments or any one of the alternative embodiments of the present application.
Further, the processor 6001 may be an FPGA (Field-Programmable Gate Array) or other device with logic processing capability, such as an MCU (micro controller Unit) or a CPU (Central processing Unit).
The application of the embodiment of the application has at least the following beneficial effects:
receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment; collecting and grouping HTTP request data and HTTP response data to obtain first interface definition data; according to the first interface definition data, big data analysis is carried out on HTTP request data and HTTP response data to obtain second interface definition data; and generating the interface description file according to the second interface definition data and a preset format of the interface description file. According to the scheme of the embodiment of the application, the interface description file is generated by analyzing the HTTP request data and the HTTP response data without the need of precondition dependence; the scheme of the embodiment of the application is independent of development languages, independent of running environments, free of strict code development specifications and free of any limitation and special requirements on developers, so that the usability and the practicability are greatly improved, the development workload is not increased, and any requirements and workload on the existing interface service are not increased.
Example four
Based on the same inventive concept, the present application further provides another computer-readable storage medium, which stores a computer program, and the computer program is used for implementing, when executed by a processor, any one of the steps of generating an interface description file provided in any one of the embodiments or any one of the alternative embodiments of the present application.
The computer-readable storage medium provided by the embodiments of the present application includes, but is not limited to, any type of disk (including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks), ROMs (Read-Only memories), RAMs (random access memories), EPROMs (Erasable Programmable Read-Only memories), EEPROMs (Electrically Erasable Programmable Read-Only memories), flash memories, magnetic cards, or optical cards. That is, a readable storage medium includes any medium that stores or transmits information in a form readable by a device (e.g., a computer).
The application of the embodiment of the application has at least the following beneficial effects:
receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment; collecting and grouping HTTP request data and HTTP response data to obtain first interface definition data; according to the first interface definition data, big data analysis is carried out on HTTP request data and HTTP response data to obtain second interface definition data; and generating the interface description file according to the second interface definition data and a preset format of the interface description file. According to the scheme of the embodiment of the application, the interface description file is generated by analyzing the HTTP request data and the HTTP response data without the need of precondition dependence; the scheme of the embodiment of the application is independent of development languages, independent of running environments, free of strict code development specifications and free of any limitation and special requirements on developers, so that the usability and the practicability are greatly improved, the development workload is not increased, and any requirements and workload on the existing interface service are not increased.
It will be understood by those within the art that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by computer program instructions. Those skilled in the art will appreciate that the computer program instructions may be implemented by a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, implement the aspects specified in the block or blocks of the block diagrams and/or flowchart illustrations disclosed herein.
Those of skill in the art will appreciate that the various operations, methods, steps in the processes, acts, or solutions discussed in this application can be interchanged, modified, combined, or eliminated. Further, other steps, measures, or schemes in various operations, methods, or flows that have been discussed in this application can be alternated, altered, rearranged, broken down, combined, or deleted. Further, steps, measures, schemes in the prior art having various operations, methods, procedures disclosed in the present application may also be alternated, modified, rearranged, decomposed, combined, or deleted.
The foregoing is only a partial embodiment of the present application, and it should be noted that, for those skilled in the art, several modifications and decorations can be made without departing from the principle of the present application, and these modifications and decorations should also be regarded as the protection scope of the present application.

Claims (10)

1. A method for generating an interface description file is applied to a server, and is characterized by comprising the following steps:
receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment;
summarizing and grouping the HTTP request data and the HTTP response data to obtain first interface definition data;
according to the first interface definition data, big data analysis is carried out on the HTTP request data and the HTTP response data to obtain second interface definition data;
and generating the interface description file according to the second interface definition data and a preset format of the interface description file.
2. The method according to claim 1, wherein the first device comprises at least one of an Application Program Interface (API) gateway and a Web Server (Web Server), and is configured to receive an HTTP request sent by a client and obtain the HTTP request data corresponding to the HTTP request according to the HTTP request, and is further configured to send an HTTP response to the client and obtain the HTTP response data corresponding to the HTTP response according to the HTTP response.
3. The method of claim 1, wherein the first interface definition data comprises at least one of:
domain name, interface path, request method, parameter, request header, request content body, response code, response header, response content body.
4. The method according to claim 1, wherein the aggregating and grouping the HTTP request data and the HTTP response data to obtain the first interface definition data comprises:
summarizing the data of the same domain name in the HTTP request data and the HTTP response data to a first level in the same multidimensional data packet;
summarizing the data of the same interface path in the first hierarchy to a second hierarchy in the same multidimensional data grouping;
summarizing data of the same request method in the second hierarchy to a third hierarchy in the same multidimensional data grouping;
obtaining data in a fourth level in the same multidimensional data grouping according to the request method, wherein the data in the fourth level comprises at least one of parameters, a request header, a request content body and a response code;
and obtaining the first interface definition data according to the domain name, the interface path, the request method and the data in the fourth hierarchy, wherein the same multidimensional data group comprises a structure of the first interface definition data.
5. The method of claim 4, wherein when the data in the fourth hierarchy level includes a response code, the method further comprises:
and summarizing the data of the same response code in the fourth hierarchy to a fifth hierarchy in the same multidimensional data packet, wherein the data in the fifth hierarchy comprises at least one of a response header and a response content body.
6. The method of claim 1, wherein the performing big data analysis on the HTTP request data and the HTTP response data according to the first interface definition data to obtain second interface definition data comprises:
dividing the HTTP request data and the HTTP response data into at least one data type according to the first interface definition data, and obtaining a numerical range corresponding to the data of the at least one data type;
and obtaining the second interface definition data according to the at least one data type and the numerical range.
7. The method according to claim 1, further comprising, after the generating the interface description file according to the second interface definition data and a preset format of the interface description file, the step of:
and generating a calling code of the client according to the interface description file, wherein the calling code of the client encapsulates the HTTP request.
8. An apparatus for generating an interface description file, applied to a server, includes:
the first processing module is used for receiving hypertext transfer protocol (HTTP) request data and HTTP response data sent by first equipment;
the second processing module is used for summarizing and grouping the HTTP request data and the HTTP response data to obtain first interface definition data;
the third processing module is used for carrying out big data analysis on the HTTP request data and the HTTP response data according to the first interface definition data to obtain second interface definition data;
and the fourth processing module is used for generating the interface description file according to the second interface definition data and a preset format of the interface description file.
9. An electronic device, comprising: a processor, a memory;
the memory for storing a computer program;
the processor is configured to execute the method for generating an interface description file according to any one of claims 1 to 7 by calling the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, is adapted to carry out the method of generating an interface description file according to any one of claims 1 to 7.
CN201911060384.5A 2019-11-01 2019-11-01 Method, device and equipment for generating interface description file and readable storage medium Active CN110795084B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911060384.5A CN110795084B (en) 2019-11-01 2019-11-01 Method, device and equipment for generating interface description file and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911060384.5A CN110795084B (en) 2019-11-01 2019-11-01 Method, device and equipment for generating interface description file and readable storage medium

Publications (2)

Publication Number Publication Date
CN110795084A true CN110795084A (en) 2020-02-14
CN110795084B CN110795084B (en) 2021-08-27

Family

ID=69442454

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911060384.5A Active CN110795084B (en) 2019-11-01 2019-11-01 Method, device and equipment for generating interface description file and readable storage medium

Country Status (1)

Country Link
CN (1) CN110795084B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111414161A (en) * 2020-03-27 2020-07-14 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for generating ID L file
CN111447279A (en) * 2020-03-27 2020-07-24 广州华多网络科技有限公司 Server and interface analysis service packet generation method
CN114003220A (en) * 2021-12-30 2022-02-01 思创数码科技股份有限公司 Workflow model implementation method, system, readable storage medium and computer equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104954363A (en) * 2015-04-30 2015-09-30 北京嘀嘀无限科技发展有限公司 Method and device for generating interface document
CN107026821A (en) * 2016-02-01 2017-08-08 阿里巴巴集团控股有限公司 The processing method and processing device of message
CN107423105A (en) * 2017-06-19 2017-12-01 上海高顿教育培训有限公司 A kind of automatic generation method of interface document
CN109614102A (en) * 2018-10-09 2019-04-12 平安科技(深圳)有限公司 Code automatic generation method, device, electronic equipment and storage medium
CN109688202A (en) * 2018-12-04 2019-04-26 北京腾云天下科技有限公司 A kind of processing method of interface data, calculates equipment and storage medium at device
US20190196796A1 (en) * 2017-12-21 2019-06-27 Fujitsu Limited Api mashup generation
US20190212878A1 (en) * 2018-01-11 2019-07-11 Microsoft Technology Licensing, Llc Dependency-based presence for co-authored documents

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104954363A (en) * 2015-04-30 2015-09-30 北京嘀嘀无限科技发展有限公司 Method and device for generating interface document
CN107026821A (en) * 2016-02-01 2017-08-08 阿里巴巴集团控股有限公司 The processing method and processing device of message
CN107423105A (en) * 2017-06-19 2017-12-01 上海高顿教育培训有限公司 A kind of automatic generation method of interface document
US20190196796A1 (en) * 2017-12-21 2019-06-27 Fujitsu Limited Api mashup generation
US20190212878A1 (en) * 2018-01-11 2019-07-11 Microsoft Technology Licensing, Llc Dependency-based presence for co-authored documents
CN109614102A (en) * 2018-10-09 2019-04-12 平安科技(深圳)有限公司 Code automatic generation method, device, electronic equipment and storage medium
CN109688202A (en) * 2018-12-04 2019-04-26 北京腾云天下科技有限公司 A kind of processing method of interface data, calculates equipment and storage medium at device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
S M SOHAN,ETC.: "SpyREST in Action: An Automated RESTful API Documentation Tool", 《2015 30TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING (ASE)》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111414161A (en) * 2020-03-27 2020-07-14 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for generating ID L file
CN111447279A (en) * 2020-03-27 2020-07-24 广州华多网络科技有限公司 Server and interface analysis service packet generation method
CN111447279B (en) * 2020-03-27 2023-04-18 广州方硅信息技术有限公司 Server and interface analysis service package generation method
CN111414161B (en) * 2020-03-27 2023-05-12 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for generating IDL file
CN114003220A (en) * 2021-12-30 2022-02-01 思创数码科技股份有限公司 Workflow model implementation method, system, readable storage medium and computer equipment
CN114003220B (en) * 2021-12-30 2022-05-03 思创数码科技股份有限公司 Workflow model implementation method, system, readable storage medium and computer equipment

Also Published As

Publication number Publication date
CN110795084B (en) 2021-08-27

Similar Documents

Publication Publication Date Title
CN110795084B (en) Method, device and equipment for generating interface description file and readable storage medium
EP3534263A1 (en) Systems and methods for web analytics testing and web development
CN108337236A (en) A kind of gRPC call methods and device based on Protobuf and HTTP/1.1
US9195441B2 (en) Systems and methods for incremental compilation at runtime using relaxed guards
CN108984155B (en) Data processing flow setting method and device
CN112015396B (en) DSL-based intelligent contract code generation method, device, equipment and storage medium
CN111444181B (en) Knowledge graph updating method and device and electronic equipment
Du et al. Generating service models by trace subsequence substitution
JP2021039718A (en) Automated application programming interface (API) specification creation
CN109614319B (en) Automatic testing method and device, electronic equipment and computer readable medium
CN114138244A (en) Method and device for automatically generating model files, storage medium and electronic equipment
CN109145236A (en) Page file processing method, apparatus and system
CN112882844A (en) Network front-end and back-end based joint debugging method and device and storage medium
CN106919511A (en) The analogy method of application, simulation application and its operation method and simulation system
CN112084179A (en) Data processing method, device, equipment and storage medium
CN109284088B (en) Signaling big data processing method and electronic equipment
CN113742231A (en) Protobuf protocol dynamic analysis-based number making method and device
CN109408577B (en) ORACLE database JSON analysis method, system, device and storable medium
CN103139298A (en) Method for transmitting network data and device
CN115811513A (en) Third-party interface request design method, device and storage medium
Monteiro et al. A service-oriented architecture for integrating the modeling and formal verification of genetic regulatory networks
Gong et al. Wwof: an energy efficient offloading framework for mobile webpage
CN114185928A (en) Universal interface docking system, method, device and storage medium
CN112433752A (en) Page parsing method, device, medium and electronic equipment
CN114915434A (en) Network agent detection method, device, storage medium and computer equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40022289

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant