[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN113419738A - Interface document generation method and device and interface management equipment - Google Patents

Interface document generation method and device and interface management equipment Download PDF

Info

Publication number
CN113419738A
CN113419738A CN202110693050.2A CN202110693050A CN113419738A CN 113419738 A CN113419738 A CN 113419738A CN 202110693050 A CN202110693050 A CN 202110693050A CN 113419738 A CN113419738 A CN 113419738A
Authority
CN
China
Prior art keywords
interface
target
information
document
source code
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.)
Pending
Application number
CN202110693050.2A
Other languages
Chinese (zh)
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.)
Weikun Shanghai Technology Service Co Ltd
Original Assignee
Weikun Shanghai Technology Service 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 Weikun Shanghai Technology Service Co Ltd filed Critical Weikun Shanghai Technology Service Co Ltd
Priority to CN202110693050.2A priority Critical patent/CN113419738A/en
Publication of CN113419738A publication Critical patent/CN113419738A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • 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
    • G06F8/315Object-oriented languages

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a method and a device for generating an interface document and interface management equipment, wherein the method comprises the following steps: the interface management equipment can respond to a trigger event of a target interface document for generating a target project, acquire a source code text corresponding to the target project from the code warehouse, and call a syntax analyzer to analyze the source code text of the target project to obtain class information; and then calling a target interface model to process the class information to generate a target interface document. The source code text of the target project can be analyzed without invasion, and more complete class information can be obtained. And the target interface model is called to process the class information, so that the integrity and the accuracy of the target interface document can be improved.

Description

Interface document generation method and device and interface management equipment
Technical Field
The present application relates to the field of software development technologies, and in particular, to a method and an apparatus for generating an interface document, an interface management device, and a computer-readable storage medium.
Background
At present, an enterprise generally needs to deploy various service systems, and each service system provides a corresponding interface according to its own service. The information corresponding to each interface is different, for example, the data protocol used by each interface may be different, some interfaces may use the SOAP protocol, and some interfaces may use the HTTP protocol. Also for example, each interface may have different parameter information, and so on. Therefore, it is very necessary how to manage these complicated interfaces, generate interface documents, and facilitate the development of different business systems and the examination of the interfaces by testers.
Disclosure of Invention
The embodiment of the application provides a generation method and device of an interface document and interface management equipment, which can analyze a source code text of a target project without intrusiveness to obtain more complete class information. And the target interface model is called to process the class information, the interface model can be adjusted according to the class information adaptability, and the integrity and the accuracy of the target interface document are improved.
In a first aspect, an embodiment of the present application provides a method for generating an interface document, where the method for generating an interface document includes:
responding to a trigger event of generating a target interface document of a target project, and acquiring a source code text of the target project;
calling a syntax analyzer to analyze a source code text of a target project to obtain class information, wherein the class information is used for indicating at least one interface object;
acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol;
and calling a target interface model to process the class information to generate a target interface document.
In a second aspect, an embodiment of the present application provides an interface document generation apparatus, where the interface document generation apparatus includes:
the acquisition unit is used for responding to a trigger event of generating a target interface document of a target project and acquiring a source code text of the target project;
the parsing unit is used for calling the parser to parse the source code text of the target item to obtain class information, and the class information is used for indicating at least one interface object;
the acquisition unit is also used for acquiring a preset interface protocol and configuring a target interface model based on the interface protocol;
and the processing unit is used for calling the target interface model to process the class information and generate a target interface document.
In a third aspect, the present application provides an interface management device, which includes a processor, an input device, an output device, and a memory, where the processor, the input device, the output device, and the memory are connected to each other, where the memory is used to store a computer program, and the computer program includes a program, and the processor is configured to call the program, and execute the method for generating an interface document according to the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program comprising program instructions that, when executed by a processor, cause the processor to perform the method for generating an interface document according to the first aspect.
In the embodiment of the application, in response to a trigger event of generating a target interface document of a target project, interface management equipment acquires a source code text of the target project and calls a parser to parse the source code text of the target project to obtain class information; acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol; and calling a target interface model to process the class information to generate a target interface document. The interface management equipment analyzes the source code text of the target project through the syntax analyzer, and directly analyzes the source code text based on the JAVA syntax without introducing an additional tool, so that the intrusiveness to the target project is avoided. Moreover, the class information obtained by the parser includes class comments, additional information of class attributes and additional information of class methods, so that more complete class information can be obtained, and a subsequently generated target interface document is more complete and accurate. In addition, the generation scheme of the interface document in the embodiment of the application does not need manual participation, and manpower resources and time resources can be saved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart illustrating a generation scheme of an interface document according to an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating a method for generating an interface document according to an embodiment of the present disclosure;
FIG. 3 is a flow chart illustrating another interface document generation method according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a blockchain according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of an interface document generation apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an interface management device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. 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.
With the expansion of software project scale, efficient code multiplexing is becoming a common consensus among software developers, where the use of Application Programming Interface (API) is an important means for code multiplexing. Through the interface document, developers can clearly and quickly know the functions, the use conditions and the use limitations of the related interfaces. Therefore, an automatic generation of interface documents is an important research topic.
The embodiment of the application provides a generation scheme of an interface document, and the generation scheme of the interface document can be executed by interface management equipment. Referring to fig. 1, fig. 1 is a flow chart illustrating a generation scheme of an interface document. In the scheme, the interface management equipment can respond to a trigger event of generating a target interface document of a target item, acquire a source code text corresponding to the target item from a code warehouse, and call a parser to parse the source code text of the target item to obtain class information, wherein the class information is used for indicating at least one interface object; acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol; and calling a target interface model to process the class information to generate a target interface document. The source code text of the target item can be analyzed noninvasively, and more complete class information can be obtained. And the target interface model is called to process the class information, the interface model can be adjusted according to the class information adaptability, and the integrity and the accuracy of the target interface document are improved.
The interface management device may be any device having a data processing function, and for example, the interface management device may be a server. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, Network service, cloud communication, a Content Delivery Network (CDN), middleware service, security service, domain name service, big data and an artificial intelligence platform, and the like. The interface management system may also be a terminal device, which may include but is not limited to a portable terminal (e.g., a smart phone, a tablet computer, a wearable device, etc.) or a non-portable terminal (e.g., a desktop computer, a vehicle-mounted computer, etc.).
Based on the above description, the method for generating the interface document according to the embodiment of the present application is explained in detail below. Referring to fig. 2, fig. 2 is a flow chart diagram illustrating a method for generating an interface document. As shown in fig. 2, the method includes:
s201: and responding to a trigger event of generating a target interface document of the target item, and acquiring a source code text of the target item.
Wherein an item may refer to a portion of a business system. Specifically, the items may be obtained according to the functional division of the business system. For example, the service system is an instant messaging system, and the item may be a user information management item or a user interface presentation item in the instant messaging system, and the like. The items may be written in any programming language, for example, the items may be JAVA items written in JAVA language.
In one embodiment, the interface management apparatus may determine the target item from an Identity Document (ID). When the interface management apparatus receives the target item ID, the interface management apparatus may determine the item indicated by the target item ID as the target item.
Alternatively, the interface management apparatus may determine that a trigger event of generating a target interface document of the target item is detected upon receiving the trigger operation. In one embodiment, the interface management device may display a first user interface in the display screen, and the first user interface may include item IDs corresponding to a plurality of items. When the interface management apparatus determines that a selection operation of a target item ID is received, it determines that a trigger event of generating a target interface document of the target item is detected. In another embodiment, the interface management device may display a second user interface in the display screen, which may include an item ID entry bar. When the user enters a target project ID in the project ID entry field, the interface management apparatus may determine that a trigger event of a target interface document generating the target project is detected.
Alternatively, the interface management device may also determine that a trigger event for generating the target interface document by the target item is detected when a trigger instruction from the control tool is received. For example, the control tool may be Jenkins. The trigger instruction may carry a target item ID corresponding to the target item.
Further, one project may correspond to multiple versions of an interface document. To distinguish between different versions of the interface document, a version number may also be introduced. When the version number of an item is different, the interface document corresponding to the item may be different. Therefore, optionally, when the interface management device acquires the target version number, the interface management device may determine that a trigger event for generating a target interface document of the target item is detected. Optionally, the interface management device may also determine whether a target interface document corresponding to the target version number exists in the interface management device when the target version number is obtained. If so, the interface management device may generate notification information so as to determine whether a target interface document corresponding to the target version number needs to be regenerated.
Specifically for S201, the interface management device may obtain, from the code repository, a source code text corresponding to the target item in response to a trigger event for generating a target interface document of the target item. The code repository may refer to a code library for storing codes related to the business system, and one or more items may be included in the code repository.
In one embodiment, since most enterprises use the Git repository to manage code, the interface management device may obtain the source code text corresponding to the target project from the Git repository. Specifically, the interface management device may obtain a Git repository, scan the Git repository based on a Git protocol, and obtain a source code text corresponding to the target project.
The interface management device may obtain a Git repository address, and determine a Git repository according to the repository indicated by the Git repository address. And scanning the Git warehouse based on the analysis rule indicated by the Git protocol and the item ID corresponding to the target item to obtain a source code text corresponding to the target item. For example, the source code text corresponding to the target project can be obtained from the src/main/java path.
Wherein the Git repository can use four different protocols to transmit the source code text: local protocol (Local), HTTP protocol, ssh (secure shell) protocol, and Git protocol. Among them, the Git protocol does not require any authorization, and is the fastest of the network transmission protocols used by the Git repository. The data volume of the source code text of the target project, which needs to be acquired from the Git warehouse, is large, so that the acquisition rate of the source code text can be increased by using the Git protocol, the time is saved, and the user experience is improved.
S202: and calling a syntax analyzer to analyze the source code text of the target project to obtain class information, wherein the class information is used for indicating at least one interface object.
Specifically, the parsing rule of the parser may correspond to a syntax specification of JAVA. The parser may parse the source code text in a manner of reading character strings one by one, and keywords and/or stacking based on JAVA syntax specification to obtain class information.
The syntax specification for JAVA may include, but is not limited to, the following:
1) "; "symbols may be used to represent the termination of a statement.
2) The "/", "/" and "/" symbols may be used to annotate the statement.
3) The first line of active statements in the source code text may begin with a package, which is used to record the path of classes in JAVA.
4) The statement at the beginning of import may be used to indicate the path of the referenced class and the name of the referenced class.
5) public class is the beginning of a class definition; abstrate is the beginning of a class definition; enum is the start of the enumeration definition; interface is the start of the interface definition; instances can be the beginning of a parent definition, and so on.
6) private | protect | public | package [ static | final | view ] can be the beginning of the attribute definition.
7) public | protect | private | package [ static ] can be the beginning of a method definition.
8) Statements preceding the attribute and method definitions may contain comments, annotations, and the like. For example a sentence starting with the @ symbol.
A class may refer to a collection of interface objects having the same data members and function members, which provides an abstract description of all interface objects belonging to the class. The class information is used to indicate at least one interface object.
The class information may include one or more of an attribute field of the class and a method field of the class.
The attribute field of the class is used for indicating that the attribute of the member of the class can be accessed, and the attribute field of the class can comprise one or more of the attribute name of the class, the attribute type of the class, the visibility of the attribute of the class, and the annotation corresponding to the attribute of the class.
Wherein the method field of the class is used to indicate the operations that the members of the class can perform. The method fields of the class may include a description field, an entry information field, and a return information field. Specifically, the description field may include one or more of a name of a method of the class, a type of the method of the class, and a comment corresponding to the method of the class. The parameter information field may include one or more of a parameter name, parameter information, and a comment corresponding to the parameter. Wherein, the return information field can comprise one or more items of return type and return corresponding note.
Further, the visibility of attributes of a class may include public attributes and private attributes. The interface management apparatus may also modify visibility of an attribute of the class according to a method field of the class. For example, the initial visibility of the attribute 1 of the class is a private attribute name, and if the interface management device acquires the public method getName from the method field of the class, the interface management device may determine that the target visibility of the attribute 1 of the class is the public attribute name. For another example, the initial visibility of the attribute 2 of the class is a private attribute name, and if @ Data is included in the annotation corresponding to the attribute 2 of the class and the attribute 2 of the class obtained from the method field of the class refers to a lombok package, it may be determined that the target visibility of the attribute 2 of the class is a public attribute name.
The class information may further include a name of the class, a path of the class, a type of the class, and the like. In one embodiment, the class information may be stored. Alternatively, the class information may be stored by key-value pairs of the MAP structure. For example, the name of the class and/or the path of the class may be used as the key of the key-value pair, and the class information may be used as the value of the key-value pair. Optionally, the class information may also be stored by a list. The interface management apparatus may store the name of the class and/or the path of the class at any position in the list, and then may store class information associated with the name of the class and/or the path of the class at a position in the list corresponding to any position. And so on.
Further, since the items can be mutually called, the target item may have associated items. In order to further obtain more complete class information, the interface management device may also invoke a parser to parse the source code text corresponding to the associated item. For the method for acquiring the source code text of the associated item by the interface management device, reference may be made to the specific implementation of acquiring the source code text of the target item, which is not described herein again.
Alternatively, the associated item may be an item that has a parent-child relationship with the target item. At this time, the interface management device needs to call a parser to parse the source code text of the target item to obtain first type information, and call the parser to parse the source code text of the associated item to obtain second type information; the first type information is sub information of the second type information; and obtaining class information based on the first class information and the second class information. Specifically, the associated item is a parent item of the target item, and the attribute or the method in the second type of information corresponding to the associated item may be inherited by the first type of information, so that the second type of information may be added to the first type of information to obtain the type information, that is, the final type information.
Alternatively, the associated item may also be an item referenced by the target item. For example, when the access of a certain method of the target item a is from the associated item B, the interface management device may obtain the access from the class information obtained by analyzing the associated item B according to the import information of the class. And will not be described in detail herein.
S203: and acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol.
The interface protocol may be used to indicate the structure of the interface information corresponding to each interface object in the interface document. Optionally, the interface protocol may include one or more of a request address field, a request type field, a parameter information field, a return result field, and an additional information field.
Wherein the request address field is used for indicating the request address of the interface object. The interface management device may determine the request address of the interface object according to the path of the class in the class information and the annotation corresponding to the class method.
Wherein the request type field is used to indicate the request type of the interface object. The interface management device may determine the request type of the interface object according to the annotation corresponding to the class method.
The parameter information field is used for indicating the entry information of the interface object, and the parameter information field can be determined by the entry information field in the class information. The parameter information field may include one or more of a parameter category, a parameter name, a parameter type, and a parameter description. The parameter category may refer to a reference category of the interface object. For example, for JAVA REST service frameworks such as SpringMVC and Jersey, the categories of the parameters may be distinguished according to annotations corresponding to the entries, for example, @ PathVariable indicates a path parameter, and @ RequestParam indicates a parameter attached to the URL. The interface management device may obtain the parameter name from the access name. The parameter types may be classified into a character type, a boolean type, a class type, and the like. The interface management device may obtain the parameter type from the entry type. The interface management device may obtain the parameter description from the annotation corresponding to the entry.
Wherein, the return result field is used for indicating the return information of the interface object. The return result field may be determined from the attribute field of the class and the return information field.
Wherein the additional information field is used to indicate an additional description of the interface object.
S204: and calling a target interface model to process the class information to generate a target interface document.
Wherein the target interface document comprises interface documents of a plurality of interface objects. The data structure of the interface information conforms to the interface protocol described above.
In one embodiment, the interface model may be a Groovy script that supports dynamic configuration. The interface management device may generate a Groovy script according to an interface protocol.
In the embodiment of the application, in response to a trigger event of generating a target interface document of a target project, interface management equipment acquires a source code text of the target project and calls a parser to parse the source code text of the target project to obtain class information; acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol; and calling a target interface model to process the class information to generate a target interface document. The interface management equipment analyzes the source code text of the target project through the syntax analyzer, and directly analyzes the source code text based on the JAVA syntax without introducing an additional tool, so that the intrusiveness to the target project is avoided. Moreover, the class information obtained by the parser includes class comments, additional information of class attributes and additional information of class methods, so that more complete class information can be obtained, and a subsequently generated target interface document is more complete and accurate. In addition, the generation scheme of the interface document in the embodiment of the application does not need manual participation, and manpower resources and time resources can be saved.
As can be seen from the above description of the method embodiment shown in fig. 2, the interface document generation method shown in fig. 2 can generate an interface document. Because the interface models corresponding to different interface objects may be different, the interface management device may adjust the initial interface model according to the interface object adaptability to obtain the target interface model. Based on this, the embodiment of the application provides another interface document generation method; referring to fig. 3, the generation method of the graph interface document may include the following steps S301 to S302:
s301: and responding to a trigger event of generating a target interface document of the target item, and acquiring a source code text of the target item.
S302: and calling a syntax analyzer to analyze the source code text of the target project to obtain class information, wherein each class information is used for indicating at least one interface object.
S303: and acquiring a preset interface protocol.
It should be understood that specific implementation manners of S301-S303 can refer to the specific description of the embodiment related to fig. 2, and are not described herein again.
S304: and generating an initial interface model according to a preset interface protocol.
Wherein the initial interface model may include one or more of the following elements: the system comprises a class processing unit, a method processing unit, a request type acquiring unit, a request address acquiring unit, a parameter information acquiring unit, a result returning acquiring unit and an extra information acquiring unit.
The class processing unit is used for judging whether each class in the class information is a resource class. For example, the annotation corresponding to a class includes "Controller" or "RestController".
The method processing unit is used for judging whether the interface object in the class information is a method interface object. For example, if the annotation corresponding to the class method includes "RequestMapping", the method processing unit determines that the interface object is a method interface object.
The obtaining unit of the request type is used for obtaining the request type of the interface object. For example, if the annotation corresponding to the class method includes "GET", the request type obtained by the obtaining unit of the request type is the "GET" type.
The acquiring unit of the request address is used for acquiring the request address of the interface object. The obtaining unit of the request type can obtain the request address of the interface object through the annotation of the class and the annotation of the method.
The parameter information acquisition unit is used for acquiring the access information of the interface object. The parameter information acquiring unit may acquire the parameter information of the interface object through the parameter information field.
The return result acquiring unit is used for acquiring the return information of the interface object. The obtaining unit of the returned result may obtain the returned information of the interface object from the attribute field and the returned information field of the class.
The acquiring unit of the additional information is used for extracting the key information through the annotations corresponding to the classes, the annotations corresponding to the attributes of the classes, the annotations corresponding to the methods of the classes, the annotations corresponding to the entries and the corresponding annotations. For example, part or all of the annotations may be used as additional information.
S305: and acquiring an interface object in the class information, and adjusting the initial interface model based on the interface object to obtain a target interface model.
Because the interface models corresponding to different interface objects may be different, the interface management device may adjust the initial interface model according to the interface object adaptability to obtain the target interface model.
Wherein, for example, the interface management apparatus may add an acquisition unit of error information in the initial interface model. When the information of the interface object acquired by the interface management apparatus is abnormal, the error information of the interface object may be acquired by the error information acquisition unit. For example, the interface management apparatus may add an acquisition unit of the authority information in the initial interface model. When the interface management apparatus acquires the authority information of the interface object, the authority information of the interface object may be acquired by the acquisition unit of the authority information. Wherein, the authority information can be determined according to the request address of the interface object. For example, when the request address of an interface object contains admins, the interface object may be determined to be "administrator only calls".
In an embodiment, the initial interface model generated based on the interface protocol may be an initial Groovy script, then the Groovy Shell engine is used to call an interface object in the class information, and the initial Groovy script is adjusted based on the interface object to obtain a target Groovy script, where the target Groovy script may be used to process the class information to generate a target interface document.
S306: and calling a target interface model to process the class information to generate a target interface document.
In one embodiment, for data security, the interface management device may write the target interface document into the blockchain, so that the user can conveniently refer to each interface, and communication and maintenance costs can be reduced in the development process. Specifically, the interface management device may check the target interface document, and if the check is passed, perform consensus verification on the target interface document through a consensus node in the block chain network; and if the consensus verification is passed, packaging the target interface document into blocks, and writing the blocks into a block chain.
The block chain is a chain data structure formed by combining data blocks in a sequential connection mode according to a time sequence, and a distributed account book which ensures data to be not falsified and forged in a cryptographic mode is provided. Multiple independent distributed nodes maintain the same record. The blockchain technology realizes decentralization and becomes a foundation for credible digital asset storage, transfer and transaction.
Taking the block chain structure diagram shown in fig. 4 as an example, when new data needs to be written into the block chain, the data is collected into a block (block) and added to the end of the existing block chain, and the newly added block of each node is ensured to be identical through a consensus algorithm. A plurality of interface documents are recorded in each block, and simultaneously, the interface documents comprise hash (hash) values of the previous block, all blocks store the hash values of the previous block in the way, and the blocks are connected in sequence to form a block chain. The hash value of the previous block is stored in the block head of the next block in the block chain, and when the target interface document in the current block changes, the hash value of the current block also changes, so that the target interface document uploaded to the block chain network is difficult to tamper, and the reliability of data is improved.
In one embodiment, multiple versions of the interface document may correspond to a single project. The interface management device can also display a plurality of versions of interface documents corresponding to the target item through the user interface so that the user can distinguish the difference. Optionally, the interface management device may display part or all of the interface document corresponding to the target item. For example, the interface management apparatus may present all interface documents corresponding to the target item on the third user interface. For another example, the interface management apparatus may present only the interface document generated most recently from the current time and the interface document generated last but one time on the third user interface.
In one embodiment, the target interface document may be in error or need to be updated due to real-time changes in the business. Alternatively, the interface management apparatus may regenerate the revised interface document using the generation method of the interface document. Optionally, the interface management device may further modify the target interface document in response to a user operation to obtain a modified interface document.
In one embodiment, the interface management device may also have a test function. The interface management device can acquire interface information corresponding to the target interface object from the target interface document; the target interface object is any one of the interface objects. Generating a test case of the target interface object based on the parameter information corresponding to the target interface object; and testing the target interface object through the test case. The test case may refer to a set of test inputs, execution conditions, and expected results compiled for the interface object, and is used to verify whether the target interface object meets a specific business requirement.
In the embodiment of the application, because different interface objects are considered, the interface management device can adjust the initial interface model based on the interface objects to obtain the target interface model, and the target interface model can be dynamically changed and is not limited by a template, so that the interface management device calls the target interface model to process the class information to obtain a more complete target interface document. In addition, the interface management equipment also provides a test function, the test can be directly executed through the interface management equipment, a test tool is not required to be reused for testing the server associated with the interface object, and the processing resource is saved.
Based on the description of the above-mentioned embodiment of the fault handling method, the embodiment of the present application further discloses a device for generating an interface document, which may be a computer program (including a program code) running in the above-mentioned interface management apparatus. The interface document generating means may perform the method shown in fig. 2 or fig. 3. Referring to fig. 5, the interface document generating apparatus may operate as follows:
an obtaining unit 501, configured to obtain a source code text of a target item in response to a trigger event of generating a target interface document of the target item;
the parsing unit 502 is configured to invoke a parser to parse a source code text of a target item to obtain class information, where the class information is used to indicate at least one interface object;
a configuration unit 503, configured to obtain a preset interface protocol, and configure a target interface model based on the interface protocol;
and the processing unit 504 is configured to invoke the target interface model to process the class information, and generate a target interface document.
In some possible embodiments, the target item corresponds to an associated item,
the parsing unit 502 is configured to invoke a parser to parse the source code text of the target item, so as to obtain class information, where the class information includes:
calling a grammar analyzer to analyze the source code text of the target project to obtain first type information, and calling the grammar analyzer to analyze the source code text of the associated project to obtain second type information; the first type information is sub information of the second type information;
and obtaining the class information based on the first class information and the second class information.
In some possible embodiments, the obtaining unit 501 is configured to obtain a source code text of a target item, and includes:
acquiring a Git warehouse, wherein the Git warehouse is used for storing source code texts of a plurality of projects;
and scanning the Git warehouse based on the Git protocol to obtain the source code text of the target project.
In some possible embodiments, the configuration unit 503 is configured to configure the target interface model based on an interface protocol, and includes:
configuring an initial interface model based on an interface protocol;
and acquiring an interface object in the class information, and adjusting the initial interface model based on the interface object to obtain a target interface model.
In some possible embodiments, the configuring unit 503 is configured to adjust the initial interface model based on the interface object to obtain a target interface model, and includes:
and if the information of the acquired interface object is abnormal, adding an acquisition unit of error information in the initial interface model to obtain a target interface model.
In some possible implementations, the processing unit 504 is further configured to:
acquiring interface information corresponding to a target interface object in a target interface document; the target interface object is any one of at least one interface object;
generating a test case of the target interface object based on the interface information corresponding to the target interface object;
and testing the target interface object through the test case.
In some possible implementations, the processing unit 504 is further configured to:
checking the target interface document, and if the target interface document passes the checking, carrying out consensus verification on the target interface document through a consensus node in the block chain network;
and if the consensus verification is passed, packaging the target interface document into blocks, and writing the blocks into a block chain.
It can be understood that each unit of the interface document generating apparatus of this embodiment may be specifically implemented according to the method in the foregoing method embodiment fig. 2 or fig. 3, and a specific implementation process thereof may refer to the description related to the method embodiment fig. 2 or fig. 3, which is not described herein again.
According to another embodiment of the present application, the units in the generation apparatus of the interface document shown in fig. 5 may be respectively or entirely combined into one or several other units to form the unit, or some unit(s) therein may be further split into multiple units with smaller functions to form the unit(s), which may achieve the same operation without affecting the achievement of the technical effect of the embodiment of the present application. The units are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit. In other embodiments of the present application, the interface document based generation apparatus may also include other units, and in practical applications, these functions may also be implemented by being assisted by other units, and may be implemented by cooperation of multiple units.
According to another embodiment of the present application, the Processing element and the memory element may include a Central Processing Unit (CPU), a random access memory medium (RAM), a read only memory medium (ROM), and the like. A general-purpose computing device such as a computer runs a computer program (including program code) capable of executing the steps involved in the corresponding method shown in fig. 2 or fig. 3, to construct the interface document generation apparatus shown in fig. 5, and to implement the interface document generation method of the embodiment of the present application. The computer program may be recorded on a computer-readable recording medium, for example, and loaded and executed in the interface document generation apparatus via the computer-readable recording medium.
In the embodiment of the application, in response to a trigger event of a target interface document for generating a target project, a generating device of the interface document acquires a source code text of the target project, and calls a parser to parse the source code text of the target project to obtain class information; acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol; and calling a target interface model to process the class information to generate a target interface document. The interface document generation device analyzes the source code text of the target project through the syntax analyzer, and directly analyzes the source code text based on JAVA syntax without introducing an additional tool, so that the target project is not intrusive. Moreover, the class information obtained by the parser includes class comments, additional information of class attributes and additional information of class methods, so that more complete class information can be obtained, and a subsequently generated target interface document is more complete and accurate. In addition, the generation scheme of the interface document in the embodiment of the application does not need manual participation, and manpower resources and time resources can be saved.
Based on the description of the embodiment of the generation method of the interface document, the embodiment of the application also discloses an interface management device. Referring to fig. 6, the interface management device at least comprises a processor 601, an input interface 602, an output interface 603 and a computer storage medium 604, which can be connected by a bus or other means. The computer storage medium 604 is a memory device in the interface management device for storing programs and data. It is understood that the computer storage medium 604 herein may include a built-in storage medium of the interface management device, and may also include an extended storage medium supported by the interface management device. The computer storage media 604 provides storage space that stores the operating system of the interface management device. Also stored in this memory space are one or more instructions, which may be one or more computer programs (including program code), suitable for loading and execution by processor 601. Note that the computer storage media herein can be high-speed RAM memory; optionally, the interface management device may further include at least one computer storage medium remote from the processor, where the processor may be referred to as a Central Processing Unit (CPU), and is a core and a control center of the interface management device, and the processor is adapted to be implemented with one or more instructions, and specifically load and execute the one or more instructions to implement the corresponding method flow or function.
In one embodiment, one or more instructions stored in the computer storage medium 604 may be loaded and executed by the processor 601 to implement the steps involved in performing the corresponding method as shown in fig. 2 or fig. 3, and in particular, one or more instructions stored in the computer storage medium 604 may be loaded and executed by the processor 601 to implement the steps of:
responding to a trigger event of generating a target interface document of a target project, and acquiring a source code text of the target project;
calling a syntax analyzer to analyze a source code text of a target project to obtain class information, wherein the class information is used for indicating at least one interface object;
acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol;
and calling a target interface model to process the class information to generate a target interface document.
In some possible embodiments, the target item corresponds to an associated item,
the processor 601 is configured to invoke a parser to parse the source code text of the target item, so as to obtain class information, where the class information includes:
calling a grammar analyzer to analyze the source code text of the target project to obtain first type information, and calling the grammar analyzer to analyze the source code text of the associated project to obtain second type information; the first type information is sub information of the second type information;
and obtaining the class information based on the first class information and the second class information.
In some possible embodiments, the processor 601 is configured to obtain a source code text of the target item, including:
acquiring a Git warehouse, wherein the Git warehouse is used for storing source code texts of a plurality of projects;
and scanning the Git warehouse based on the Git protocol to obtain the source code text of the target project.
In some possible embodiments, the processor 601 is configured to configure the target interface model based on an interface protocol, including:
configuring an initial interface model based on an interface protocol;
and acquiring an interface object in the class information, and adjusting the initial interface model based on the interface object to obtain a target interface model.
In some possible embodiments, the processor 601 is configured to adjust the initial interface model to obtain a target interface model based on the interface object, and includes:
and if the information of the acquired interface object is abnormal, adding an acquisition unit of error information in the initial interface model to obtain a target interface model.
In some possible embodiments, the processor 601 is further configured to:
acquiring interface information corresponding to a target interface object in a target interface document; the target interface object is any one of at least one interface object;
generating a test case of the target interface object based on the interface information corresponding to the target interface object;
and testing the target interface object through the test case.
In some possible embodiments, the processor 601 is further configured to:
checking the target interface document, and if the target interface document passes the checking, carrying out consensus verification on the target interface document through a consensus node in the block chain network;
and if the consensus verification is passed, packaging the target interface document into blocks, and writing the blocks into a block chain.
It can be understood that each unit of the interface document generating apparatus of this embodiment may be specifically implemented according to the method in the foregoing method embodiment fig. 2 or fig. 3, and a specific implementation process thereof may refer to the description related to the method embodiment fig. 2 or fig. 3, which is not described herein again.
In the embodiment of the application, in response to a trigger event of generating a target interface document of a target project, interface management equipment acquires a source code text of the target project and calls a parser to parse the source code text of the target project to obtain class information; acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol; and calling a target interface model to process the class information to generate a target interface document. The interface management equipment analyzes the source code text of the target project through the syntax analyzer, and directly analyzes the source code text based on the JAVA syntax without introducing an additional tool, so that the intrusiveness to the target project is avoided. Moreover, the class information obtained by the parser includes class comments, additional information of class attributes and additional information of class methods, so that more complete class information can be obtained, and a subsequently generated target interface document is more complete and accurate. In addition, the generation scheme of the interface document in the embodiment of the application does not need manual participation, and manpower resources and time resources can be saved.
It should be noted that the present application also provides a computer program product or a computer program, where the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the fault handling device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, causing the fault handling device to perform the steps performed in fig. 2 or fig. 4 of the above-described fault handling method embodiments.
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.

Claims (10)

1. A method for generating an interface document, the method comprising:
responding to a trigger event of generating a target interface document of a target project, and acquiring a source code text of the target project;
calling a syntax analyzer to analyze the source code text of the target project to obtain class information, wherein the class information is used for indicating at least one interface object;
acquiring a preset interface protocol, and configuring a target interface model based on the interface protocol;
and calling the target interface model to process the class information to generate a target interface document.
2. The method of claim 1, wherein the target item corresponds to an associated item,
the calling of the grammar analyzer analyzes the source code text of the target project to obtain class information, and the method comprises the following steps:
calling the grammar analyzer to analyze the source code text of the target project to obtain first type information, and calling the grammar analyzer to analyze the source code text of the associated project to obtain second type information; the first type information is sub information of the second type information;
and obtaining the class information based on the first class information and the second class information.
3. The method of claim 1 or 2, wherein the obtaining the source code text of the target item comprises:
acquiring a Git warehouse, wherein the Git warehouse is used for storing source code texts of a plurality of projects;
and scanning the Git warehouse based on Git protocol to obtain a source code text of the target project.
4. The method of claim 1, wherein said configuring a target interface model based on said interface protocol comprises:
configuring an initial interface model based on the interface protocol;
and acquiring an interface object in the class information, and adjusting the initial interface model based on the interface object to obtain a target interface model.
5. The method of claim 4, wherein said adjusting the initial interface model based on the interface object results in a target interface model, comprising:
and if the information of the interface object is acquired to be abnormal, adding an acquisition unit of error information in the initial interface model to acquire the target interface model.
6. The method of claim 1, wherein the method further comprises:
acquiring interface information corresponding to a target interface object in the target interface document; the target interface object is any one of at least one interface object;
generating a test case of the target interface object based on the interface information corresponding to the target interface object;
and testing the target interface object through the test case.
7. The method of claim 1, wherein the method further comprises:
the target interface document is verified, and if the verification is passed, the target interface document is subjected to consensus verification through a consensus node in a block chain network;
and if the consensus verification is passed, packaging the target interface document into a block, and writing the block into a block chain.
8. An apparatus for generating an interface document, the apparatus comprising:
the acquisition unit is used for responding to a trigger event of generating a target interface document of a target project and acquiring a source code text of the target project;
the parsing unit is used for calling a syntax analyzer to parse the source code text of the target item to obtain class information, and the class information is used for indicating at least one interface object;
the configuration unit is used for acquiring a preset interface protocol and configuring a target interface model based on the interface protocol;
and the processing unit is used for calling the target interface model to process the class information and generate a target interface document.
9. An interface management device comprising a processor, an input device, an output device and a memory, the processor, the input device, the output device and the memory being interconnected, wherein the memory is configured to store a computer program, the computer program comprising a program, the processor being configured to invoke the program to perform the method of generating an interface document according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a processor, cause the processor to execute the interface document generation method according to any one of claims 1 to 7.
CN202110693050.2A 2021-06-22 2021-06-22 Interface document generation method and device and interface management equipment Pending CN113419738A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110693050.2A CN113419738A (en) 2021-06-22 2021-06-22 Interface document generation method and device and interface management equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110693050.2A CN113419738A (en) 2021-06-22 2021-06-22 Interface document generation method and device and interface management equipment

Publications (1)

Publication Number Publication Date
CN113419738A true CN113419738A (en) 2021-09-21

Family

ID=77716103

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110693050.2A Pending CN113419738A (en) 2021-06-22 2021-06-22 Interface document generation method and device and interface management equipment

Country Status (1)

Country Link
CN (1) CN113419738A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114528013A (en) * 2021-12-27 2022-05-24 北京达佳互联信息技术有限公司 Text generation method and device, electronic equipment, storage medium and product
CN118394407A (en) * 2024-06-25 2024-07-26 中邮消费金融有限公司 Git source code-based interface scanning method, device, equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108282519A (en) * 2017-12-29 2018-07-13 深圳中兴网信科技有限公司 Interface realizing method, Interface for System based on middleware
CN108932122A (en) * 2018-06-19 2018-12-04 上海陆家嘴国际金融资产交易市场股份有限公司 Interface document generation method, device, computer equipment and storage medium
CN110162296A (en) * 2019-04-15 2019-08-23 平安科技(深圳)有限公司 Generation method, device and the terminal device of application programming interface document
CN110308930A (en) * 2019-06-18 2019-10-08 广州华多网络科技有限公司 Interface document generation method, device, computer equipment and storage medium
CN111638908A (en) * 2020-05-29 2020-09-08 深圳壹账通智能科技有限公司 Interface document generation method and device, electronic equipment and medium
CN112199331A (en) * 2020-10-09 2021-01-08 平安科技(深圳)有限公司 Automatic generation method, system, terminal and storage medium of interface document
CN112306549A (en) * 2020-10-30 2021-02-02 康键信息技术(深圳)有限公司 Interface document configuration method, device, equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108282519A (en) * 2017-12-29 2018-07-13 深圳中兴网信科技有限公司 Interface realizing method, Interface for System based on middleware
CN108932122A (en) * 2018-06-19 2018-12-04 上海陆家嘴国际金融资产交易市场股份有限公司 Interface document generation method, device, computer equipment and storage medium
CN110162296A (en) * 2019-04-15 2019-08-23 平安科技(深圳)有限公司 Generation method, device and the terminal device of application programming interface document
CN110308930A (en) * 2019-06-18 2019-10-08 广州华多网络科技有限公司 Interface document generation method, device, computer equipment and storage medium
CN111638908A (en) * 2020-05-29 2020-09-08 深圳壹账通智能科技有限公司 Interface document generation method and device, electronic equipment and medium
CN112199331A (en) * 2020-10-09 2021-01-08 平安科技(深圳)有限公司 Automatic generation method, system, terminal and storage medium of interface document
CN112306549A (en) * 2020-10-30 2021-02-02 康键信息技术(深圳)有限公司 Interface document configuration method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
董晓明 等: "元数据管理在作战系统数据集成设计中的应用", 《计算机与数字工程》, vol. 38, no. 7, 31 July 2010 (2010-07-31), pages 62 - 65 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114528013A (en) * 2021-12-27 2022-05-24 北京达佳互联信息技术有限公司 Text generation method and device, electronic equipment, storage medium and product
CN118394407A (en) * 2024-06-25 2024-07-26 中邮消费金融有限公司 Git source code-based interface scanning method, device, equipment and storage medium
CN118394407B (en) * 2024-06-25 2024-09-10 中邮消费金融有限公司 Git source code-based interface scanning method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
US10769228B2 (en) Systems and methods for web analytics testing and web development
CN110688307B (en) JavaScript code detection method, device, equipment and storage medium
CN108628748B (en) Automatic test management method and automatic test management system
CN107526676B (en) Cross-system test method and device
CN117370203B (en) Automatic test method, system, electronic equipment and storage medium
CN110716866A (en) Code quality scanning method and device, computer equipment and storage medium
CN114398673A (en) Application compliance detection method and device, storage medium and electronic equipment
CN115904989A (en) Interface testing method, device, equipment and readable storage medium
CN113419738A (en) Interface document generation method and device and interface management equipment
CN117632710A (en) Method, device, equipment and storage medium for generating test code
CN110598419B (en) Block chain client vulnerability mining method, device, equipment and storage medium
CN112286815A (en) Interface test script generation method and related equipment thereof
CN114816993A (en) Full link interface test method, system, medium and electronic equipment
CN111258562B (en) Java code quality inspection method, device, equipment and storage medium
CN116661758B (en) Method, device, electronic equipment and medium for optimizing log framework configuration
CN116361793A (en) Code detection method, device, electronic equipment and storage medium
CN115470152A (en) Test code generation method, test code generation device, and storage medium
CN111414525B (en) Method, device, computer equipment and storage medium for acquiring data of applet
CN115481023A (en) Interface data checking method and device, computer equipment and readable storage medium
CN114003317B (en) Inline implementation method and device, electronic equipment, storage medium and program product
US11960560B1 (en) Methods for analyzing recurring accessibility issues with dynamic web site behavior and devices thereof
Habibi et al. Sharif-TaaWS: a tool to automate unit testing of web services
US9471788B2 (en) Evaluation of software applications
CN117667716A (en) Page testing method and device and electronic equipment
CN118860880A (en) Interface test method, electronic device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination