Methods, apparatus, devices, and media for generating interface documentation based on front-end and back-end code.
By parsing the front-end and back-end code repositories to generate interface documentation, the problem of manually sorting out the front-end and back-end call relationships is solved, and unified storage and retrieval of interface documentation is achieved, which is suitable for fintech businesses.
Patent Information
- Application Number
- CN202611550701.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-08
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, the sorting out of front-end and back-end call relationships relies on manual work, resulting in scattered interface documents with large differences in format and content, making it difficult to form unified and easily searchable technical information. This is especially true in fintech businesses, where multiple versions of interface documents are scattered and difficult to find.
By obtaining the front-end and back-end code repository addresses and version identifiers, the code is parsed to form feature data, a correspondence between call feature data is established, a sequence diagram and a call relationship topology diagram are generated, and finally, interface documentation is generated and stored as index data.
It automates the sorting out of front-end and back-end call relationships, generates unified interface documentation, reduces manual workload, and improves the storage and retrieval efficiency of interface documentation, making it suitable for business scenarios such as fintech.
Smart Images

Figure CN123114535A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of development assistance techniques, and more particularly to a method, apparatus, device, and medium for generating interface documentation based on front-end and back-end code. Background Technology
[0002] In current software development processes, the sorting out of front-end and back-end call relationships and the maintenance of interface documentation usually rely on manual work. Interface descriptions, call relationship descriptions, and sequence diagrams are stored in a scattered manner, making it difficult to form unified and easily searchable technical information.
[0003] In the fintech business, insurance underwriting, policy management, claims processing, and risk control are typically implemented using multiple microservice modules and independent front-end code repositories. As financial products iterate and business processes adjust, the relationships between front-end page calls, back-end interfaces, and internal program calls constantly change, often involving multiple interfaces and multi-level program calls for a single business requirement.
[0004] Current technology typically involves developers manually reviewing frontend and backend API code, checking request paths and methods, and manually writing API documentation, sequence diagrams, and call relationship data. This manual review process is prone to missing APIs or creating incorrect correspondences, and the documentation written by different people varies in format and content. As more versions are released, the API documentation for each version is scattered across different directories, lacking a clear connection between the documentation and the corresponding version's code, making it difficult to find historical documentation and trace API call relationships. Summary of the Invention
[0005] The main objective of this invention is to provide a method, apparatus, device, and storage medium for generating interface documentation based on front-end and back-end code, aiming to solve the technical problem that existing technologies rely on manual sorting of front-end and back-end call relationships, making it difficult to generate interface documentation that corresponds to the code version and is uniformly searchable.
[0006] To achieve the above objectives, this invention provides a method for generating interface documentation based on front-end and back-end code, comprising: Obtain the front-end code repository address, the back-end code repository address, and the version identifier; and obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier. The front-end code and the back-end code are parsed to form front-end call feature data, back-end interface feature data, and back-end program call data. Establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data; Generate a sequence diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data; An interface document is generated based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram. The interface document is stored according to the version identifier, and document index data is generated based on the interface document.
[0007] Furthermore, to achieve the above objectives, the present invention provides an interface documentation generation device based on front-end and back-end code, comprising: The code acquisition module is used to obtain the front-end code repository address, the back-end code repository address, and the version identifier, and to obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier; The feature parsing module is used to parse the front-end code and the back-end code to form front-end call feature data, back-end interface feature data and back-end program call data; The interface matching module is used to establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data; The call graph generation module is used to generate a sequence diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data. The document management module is used to generate interface documents based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram, store the interface documents according to the version identifier, and generate document index data based on the interface documents.
[0008] Furthermore, to achieve the above objectives, the present invention also provides a computer device, the computer device including a memory, a processor, and an interface documentation generation program based on front-end and back-end code stored in the memory and executable on the processor, wherein when the interface documentation generation program based on front-end and back-end code is executed by the processor, it implements the steps of the interface documentation generation method based on front-end and back-end code as described above.
[0009] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing an interface documentation generation program based on front-end and back-end code, wherein when the interface documentation generation program based on front-end and back-end code is executed by a processor, it implements the steps of the interface documentation generation method based on front-end and back-end code as described above.
[0010] Beneficial Effects: This invention relates to the field of development assistance technology, and discloses a method, apparatus, device, and medium for generating interface documentation based on front-end and back-end code. The method includes: obtaining the front-end code repository address, back-end code repository address, and version identifier, and obtaining the corresponding versions of front-end and back-end code; parsing the front-end and back-end code to form front-end call characteristic data, back-end interface characteristic data, and back-end program call data; establishing a correspondence between the front-end call characteristic data and the back-end interface characteristic data, generating a sequence diagram and a call relationship topology diagram; generating interface documentation based on the analyzed data and graphs, storing the interface documentation according to the version identifier, and generating document index data. This invention can be applied to business scenarios such as fintech. By parsing the corresponding versions of front-end and back-end code, it establishes a correspondence between front-end calls and back-end interfaces, and combines back-end program call data to generate graphical call information and interface documentation. This associates the interface documentation with the code version, reducing the workload of manually sorting out call relationships and maintaining scattered documentation, and facilitating the unified storage and retrieval of interface documentation. Attached Figure Description
[0011] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 This is a schematic diagram of an application environment for an interface documentation generation method based on front-end and back-end code according to an embodiment of the present invention. Figure 2 This is a flowchart illustrating an embodiment of the interface documentation generation method based on front-end and back-end code according to the present invention. Figure 3 for Figure 2 A detailed flowchart of step S10; Figure 4 for Figure 2 A detailed flowchart of step S20; Figure 5 for Figure 2 A detailed flowchart of step S30; Figure 6 for Figure 2 A detailed flowchart of step S40; Figure 7 for Figure 2 A detailed flowchart of step S50; Figure 8 for Figure 2 A detailed flowchart illustrating the processing steps following step S50. Figure 9 This is a schematic diagram of the functional modules of a preferred embodiment of the interface documentation generation device based on front-end and back-end code of the present invention; Figure 10 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 11 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0012] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0013] The interface documentation generation method based on front-end and back-end code provided in this embodiment of the invention can be applied to, for example... Figure 1 In this application environment, the client communicates with the server via a network. The server can obtain the front-end code repository address, back-end code repository address, and version identifier from the client, and obtain the corresponding versions of the front-end and back-end code; parse the front-end and back-end code to form front-end call feature data, back-end interface feature data, and back-end program call data; establish the correspondence between the front-end call feature data and the back-end interface feature data, and generate a sequence diagram and call relationship topology diagram; generate interface documents based on the analyzed data and graphs, store the interface documents according to the version identifier, and generate document index data. This invention can be applied to business scenarios such as fintech. By parsing the corresponding versions of the front-end and back-end code, it establishes the correspondence between front-end calls and back-end interfaces, and combines the back-end program call data to generate graphical call data and interface documents, thus associating the interface documents with the code versions, reducing the workload of manually sorting out call relationships and maintaining scattered documents, and facilitating the unified storage and retrieval of interface documents. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a separate server or a server cluster composed of multiple servers. The invention will be described in detail below through specific embodiments.
[0014] Please see Figure 2 , Figure 2 This is a flowchart illustrating an embodiment of the interface documentation generation method based on front-end and back-end code provided by the present invention. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0015] like Figure 2 As shown, the interface documentation generation method based on front-end and back-end code proposed in this invention includes the following steps: S10, obtain the front-end code repository address, the back-end code repository address, and the version identifier, and obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier; In this embodiment, the front-end code repository address and the back-end code repository address can originate from project configuration, repository registration information, or external input parameters. The address content can include the access protocol, repository service location, and project path, respectively used to locate the repository space storing the front-end code and the back-end code. The version identifier can originate from the release configuration or iteration configuration and can use branch identifiers, tag identifiers, commit identifiers, or character sequences that can be resolved into code version references. After reading the repository address and version identifier, the repository access location is parsed and a connection is established. The code state pointed to by the version identifier is searched in both code repositories, and the file directory, file content, and file attributes contained in the code state are read. The front-end code includes front-end program files and associated configuration files, and the back-end code includes back-end program files and associated configuration files. Both types of code maintain the directory relationships and file content in the repository. If the version identifier cannot be resolved into a valid code state in either code repository, the current code reading can be terminated to avoid mixing in files from other versions.
[0016] When the code repository supports encrypted network access and branch reading, an encrypted transmission can be used to connect two code repositories, using the version identifier as the branch identifier or tag identifier to query code references, and then a repository copying method with limited read depth can be used to obtain the two code versions, reducing the amount of irrelevant version data transmitted.
[0017] When the code repository is large or network access is limited, key-based authentication can be used to connect to the repository service. Version identifiers are parsed into commit identifiers, the file tree and code objects associated with the commit identifiers are read, and missing files are supplemented through local code object caching. Front-end and back-end code can be written to separate directories or saved as collections of files with different code category tags, ensuring that files obtained from the two repositories remain distinguishable.
[0018] For example, when an agricultural insurance institution adjusts its underwriting rate rules, it inputs the address of the front-end code repository for underwriting operations, the address of the back-end code repository for premium processing services, and a rate adjustment version identifier. The repository service locates the release tag of the front-end page program and the version reference of the back-end service program based on the rate adjustment version identifier. It reads the underwriting page file, request configuration file, and build configuration file from the release tag, and reads the premium interface file, rate processing file, and service configuration file from the back-end version reference, obtaining the front-end code and back-end code for the rate adjustment version, respectively. If any repository does not provide a code status associated with the rate adjustment version identifier, code from other rate versions is not used as a substitute.
[0019] This embodiment locates the storage locations of the front-end and back-end code by using the repository address, and selects the code status in the two code repositories by using the version identifier. This ensures that the obtained front-end and back-end code have clear repository sources and version ranges, reducing file mixing caused by manual selection of repositories or code versions, and improving the verifiability of code reading results.
[0020] S20, parse the front-end code and the back-end code to form front-end call feature data, back-end interface feature data and back-end program call data; In this embodiment, front-end and back-end code are read according to file type, program declarations, configuration content, and calling expressions are identified, and the association between code content and source file location is preserved. Front-end code parsing can read request paths, request methods, and call locations from network request expressions and request encapsulation functions. When the path contains variables or string concatenation, path fragments can be parsed along variable assignments and function parameter passing relationships, recording the identifiable path content and preserved dynamic expressions as front-end call characteristic data. Back-end code parsing can read interface paths, request methods, and interface processing function identifiers from interface declarations and routing configurations, and record the structure of request and response parameters based on parameter declarations, type references, and return expressions, recording the interface entry information and parameter structure as back-end interface characteristic data. For call expressions within the back-end program, the call source and target can be identified based on function name, type, and reference location, recording the call location, statement order, and branch conditions to obtain back-end program call data. These three types of data can be saved as structured records, retaining file location or declaration identifiers; uncertain dynamic content can retain expressions and unparsed states to avoid recording speculative content as determined call information.
[0021] When the request path and interface declaration are mainly stored in the source file, a syntax tree traversal can be used to read the front-end request expression, back-end interface declaration, and function call expression. The request configuration, parameter declaration, and call content can be distinguished by node type, and the function to which it belongs can be identified based on the nesting relationship of the nodes.
[0022] When a request involves multiple layers of encapsulation or the backend code contains cross-file type references, the semantic information provided by the compiler can be used to analyze the frontend and backend code. Symbolic binding relationships can be used to associate function declarations and call locations, and import and parameter passing relationships can be used to reconstruct the request configuration. Nested parameter structures can be read from type information. For dynamic calls that cannot be statically determined, the calling expression, identifiable referenced objects, and source file locations can be saved, without forcibly specifying the call target.
[0023] For example, in the agricultural insurance underwriting verification function, the front-end page submits the policy identifier and insured area information through a request encapsulation function. The back-end code includes the underwriting verification entry point, the policy query function, and the risk check function. When parsing the front-end code, the request path, request method, and call location are read from the request configuration and encapsulation function parameters and recorded as front-end call characteristic data. When parsing the back-end code, the interface path, request parameter structure, and verification result structure are read from the interface declaration, parameter type, and return type and recorded as back-end interface characteristic data. For the program content where the underwriting verification entry point calls the policy query function and calls the risk check function when the check conditions are met, the call source, call target, statement order, and check conditions are recorded to obtain the back-end program call data, retaining the difference between conditional and unconditional calls.
[0024] This embodiment identifies request information, interface entry information, parameter structure, and program call information from the front-end and back-end code respectively, converting the content scattered in program declarations and call expressions into three types of structured data. This reduces information omissions caused by manual code reading and improves the verifiability of the parsing results by preserving code location and unparsed state.
[0025] S30, establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data; In this embodiment, the front-end call path and front-end request method are read from the front-end call feature data, and the back-end interface path and back-end request method are read from the back-end interface feature data. The front-end call path and back-end interface path can be converted into a unified path separation format, and the variable expressions and path parameter placeholders in the path can be converted into path markers with the same semantics. The front-end request method and the back-end request method are compared, and the two paths are compared according to the content, type, and arrangement position of the path segments. When the request methods and path structures are consistent, the corresponding front-end call feature data and back-end interface feature data are associated. The interface corresponding data can record the identifiers of the two types of data, their correspondence, and the path comparison results used. When multiple back-end interfaces simultaneously meet the comparison conditions, candidate association states can be retained to avoid arbitrarily selecting back-end interfaces.
[0026] When both the front-end call path and the back-end interface path consist of fixed strings, character-level comparison is used to verify the path content, and the associated result is determined in conjunction with the request method. When the path contains variable expressions, path parameter placeholders, or variable prefixes, path segment structure comparison is used to identify fixed and variable path segments. Variable path segments are converted into a unified tag, and then the content and arrangement of the fixed path segments are verified.
[0027] When multiple request methods are configured for the same path, the request method can be used as an independent comparison condition to establish a separate association between the frontend call record and the backend interface record. For call records with incomplete path information, the unassociated state and missing content can be saved, and the comparison can be re-established after the path content is completed.
[0028] For example, the front-end call characteristic data of the agricultural insurance policy query page includes the policy query path, request method, and call location, while the back-end interface characteristic data of the policy service includes the interface path, request method, and interface entry identifier. The policy number in the front-end path is represented by a variable expression, while the policy number in the back-end path is represented by a path parameter placeholder. After converting the two types of variable path segments into a unified identifier, the fixed path segments and their arrangement positions in the policy query path are compared, and the request method is verified. When the fixed path segments, arrangement positions, and request methods are consistent, the call record of the policy query page is associated with the interface record of the policy service to obtain interface corresponding data containing the identifiers and correspondences of the two types of records.
[0029] This embodiment reduces mismatches caused by differences in path writing by unifying the comparison format of front-end call paths and back-end interface paths, and establishes associations by combining request methods and path structures. This ensures that the corresponding data in the interface retains a clear data source and association basis, and reduces omissions caused by manual verification of front-end and back-end call relationships.
[0030] S40, Generate a timing diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data; In this embodiment, front-end call records, back-end interface records, and their associated information are read from the interface corresponding data. The call source, call target, and call order are read from the back-end program call data. Duplicate call participants are merged according to function identifiers or interface identifiers, and front-end calls, back-end interfaces, and back-end program functions are converted into distinguishable participants. Interface call messages pointing from front-end call participants to back-end interface participants are established based on the associated information. Back-end call messages are established based on the call source and call target, and the messages are arranged according to the call order. The sequence diagram can use lifelines to represent participants, with call direction and call content written between lifelines according to message order. The call relationship topology diagram can use nodes to represent participants and directed connections to represent interface call relationships and back-end call relationships. When conditional branches or duplicate calls exist, branch markers or call positions can be added to messages and directed connections to maintain the distinguishability of different calls between the same participants.
[0031] When the source and target of the call have stable identifiers, a graph data structure is used to store the participants and the call relationship. The identifiers of the participants are written into the nodes, and the call direction, call order and call position are written into the directed connections. Then, the lifelines and messages in the sequence graph are arranged according to the message order, and the call relationship topology graph is arranged according to the node connection relationship.
[0032] When the graphical content needs to be generated by an independent rendering program, a text-based graphical description can be used to store participant declarations, message declarations, and node connection declarations. A sequence diagram description arranges message declarations according to the call order, and a topology diagram description writes node connection declarations according to the call source and call target. When there are many call levels, node positions can be allocated according to the call depth; when multiple calls point to the same participant, participant nodes can be merged while retaining all directed connections.
[0033] In agricultural insurance underwriting verification, the interface corresponding to the data record establishes the association between the underwriting page call and the underwriting verification interface. The backend program call data record the direction and order of the underwriting verification interface's calls to the policy query function, regional verification function, and risk assessment function. The underwriting page, underwriting verification interface, and each backend function are converted into calling participants. Messages from the underwriting page to the underwriting verification interface are written into a sequence diagram, and messages between the underwriting verification interface and each backend function are arranged according to the calling order. Items with the same participants are used as topology nodes, and the calling relationships between the underwriting page, underwriting verification interface, policy query function, regional verification function, and risk assessment function are used as directed connections, generating a calling relationship topology graph.
[0034] This embodiment determines the participating items, message order, and node connection relationship by using interface association information and backend program call information. It can generate two types of graphs that reflect the call direction and program dependency relationship, reducing the omission of participating items and the error of call order that occur during manual drawing, and enabling the graph content to be traced back to the corresponding interface record and program call record.
[0035] S50, generate an interface document based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram; store the interface document according to the version identifier; and generate document index data based on the interface document.
[0036] In this embodiment, the interface path, request method, request parameter definition, and response parameter definition are read from the backend interface feature data, and the frontend call information is associated with the corresponding interface data. The sequence diagram can be written into the corresponding interface document items according to the interface association information, and the call relationship topology diagram can be written into the overall call relationship area. The interface document can be an editable document, a marked document, or a structured electronic file. The document content includes the interface identifier, frontend and backend call information, parameter structure, and graphical content. The version identifier can be used as a storage directory name, a component of the document name, or a version attribute of the stored object, keeping different versions of the interface document separate. After the interface document is written to the storage location, the interface path, request method, and number of interfaces can be read from the document content, and document index data can be generated by combining the version identifier, document identifier, and storage location. The document index data can be stored using structured records, with each record pointing to the corresponding version of the interface document.
[0037] When generating editable documents is required, placeholder content from the document template is used to receive interface paths, request methods, parameter definitions, and front-end call information. Sequence diagrams and call relationship topology diagrams are converted into image data and embedded into the graphical area. The generated interface documents are then written to a directory named after the version identifier. After the documents are written, the document name, interface entries, and storage path are read to generate structured index records.
[0038] When viewing via a browser is required, a markup document generator is used to convert API data into page elements, save sequence diagrams and call relationship topology diagrams as vector graphics and write them to the page, and record version identifiers as page metadata. When API documentation uses object storage, version identifiers and API paths can be written into object properties, and document index data can be generated based on the object address, version property, and API entry.
[0039] For example, after the agricultural insurance risk label function completes its version adjustment, the backend interface feature data includes the request methods, request parameter definitions, and response parameter definitions for the task query interface and the label submission interface. The corresponding interface data includes the association information between the underwriting management page and the two interfaces. Based on the interface association information, the sequence diagrams of the two interfaces are written into the corresponding interface document items, and the topology diagram of the call relationship between the underwriting management page, the interface entry point, and the backend program functions is written into the overall call relationship area. The generated interface documents are written into the directory corresponding to the risk label version identifier. The interface path, request method, and interface entry are read from the interface documents, and document index data is generated by combining the document name and storage location.
[0040] This embodiment generates a unified structured interface document by associating interface data, parameter definitions, and graphical content, and stores different versions of the document separately according to version identifiers, so that the document content is associated with the version range; generating document index data from the interface document and storage location can reduce omissions caused by manually organizing the document directory and facilitate the location of documents by version and interface information.
[0041] In one embodiment, such as Figure 3 As shown, step S10 above includes: S101, obtain the front-end code repository address, the back-end code repository address and the version identifier, access the front-end code repository pointed to by the front-end code repository address, read the front-end version reference information from the front-end code repository, access the back-end code repository pointed to by the back-end code repository address and read the back-end version reference information from the back-end code repository; S102, obtain version corresponding data, and read the front-end version reference identifier and back-end version reference identifier associated with the version identifier from the version corresponding data; S103, compare the front-end version reference identifier with the front-end version reference information to determine the front-end target version reference information, and compare the back-end version reference identifier with the back-end version reference information to determine the back-end target version reference information; S104, Establish the front-end code storage directory and the back-end code storage directory; S105, Read the front-end version file set from the front-end code repository according to the front-end target version reference information, and write the front-end version file set into the front-end code storage directory to form front-end code; S106, Read the backend version file set from the backend code repository according to the backend target version reference information, and write the backend version file set into the backend code storage directory to form backend code.
[0042] In this embodiment, the front-end and back-end code repository addresses can be read from code repository configuration records, project configuration files, or external input data. The code repository address may include the access protocol, repository service location, project group, and repository path. After parsing the code repository address, the front-end and back-end code repositories are connected respectively, and the version reference records stored in each repository are read. The front-end and back-end version reference information may include reference type, reference name, commit identifier, and file tree location. The reference type can be a branch, tag, or commit record. When the code repository uses access control, access credentials can be loaded during the connection process, and the version reference record can be read after the credentials are verified.
[0043] Version identifiers can originate from code release configurations, version configuration files, or external input data. Version mapping data stores the mapping between version identifiers and version reference identifiers used by different code repositories; this can be achieved using structured configuration files, data tables, or version metadata records. Based on the version identifier, the mapping record is searched in the version mapping data, and the front-end version reference identifier and back-end version reference identifier are retrieved from the mapping record. The front-end version reference identifier is used to select records with matching reference names or commit identifiers from the front-end version reference information to obtain the front-end target version reference information; the back-end version reference identifier is used to select records with matching reference names or commit identifiers from the back-end version reference information to obtain the back-end target version reference information. When branches and tags with the same name exist in the code repository, the reference type and commit identifier can be compared to avoid identifying version reference records with the same name but different code states as the target record.
[0044] The front-end code storage directory and the back-end code storage directory use different directory paths to isolate files read by the two code repositories. The directory creation process may include path generation, write permission verification, and cleanup of remaining files. The directory path may include version identifiers or task identifiers to ensure that files read by different versions are distinguishable. If the directory already exists, the repository address and version reference information recorded in the directory can be verified; if the records are inconsistent, a new directory can be created to avoid mixing files from different repositories or different versions.
[0045] The frontend target version reference information points to the file tree in the frontend code repository. Based on the file tree, file objects and relative paths are read to obtain the frontend version file set. The frontend version file set can include program files, configuration files, and build files, and can cover the entire file tree or a pre-configured range of file paths. Each frontend version file is written to the frontend code storage directory according to its relative path, preserving the file name, directory level, and file content, thus obtaining the frontend code. The backend target version reference information points to the file tree in the backend code repository. Based on the file tree, the backend version file set is read and written to the backend code storage directory according to its relative path, thus obtaining the backend code. File reading can be done via repository copying, file object reading, or version archive reading. After file writing is complete, the commit identifier in the target version reference information can be checked against the commit identifier recorded in the code directory. If the target version reference information is not found or the file reading is incomplete, the corresponding code output can be stopped.
[0046] This embodiment reads version reference information by accessing the front-end code repository and the back-end code repository respectively, and uses version correspondence data to convert the unified version identifier into the version reference identifier used by the two code repositories. This can accurately determine the front-end target version reference information and the back-end target version reference information. By storing the file sets of the two target versions separately, the front-end code and the back-end code have clear repository sources, version ranges and directory boundaries, reducing version reference selection errors and the mixing of files from different repositories, and improving the completeness and verifiability of the code reading results.
[0047] In one embodiment, such as Figure 4 As shown, step S20 above includes: S201, parse the class declarations, method declarations, annotations and call statements in the backend code to obtain the backend syntax hierarchy, and construct the backend abstract syntax tree based on the backend syntax hierarchy; S202, locate the interface method from the backend abstract syntax tree, read the method declaration information of the interface method from the backend abstract syntax tree to form an interface method identifier, extract the class-level path value, method-level path value and request method from the backend abstract syntax tree, concatenate the class-level path value and the method-level path value to form a backend interface path, determine the request method as the backend request method, parse the interface request parameters and interface response parameters of the interface method from the backend abstract syntax tree to form interface request parameter definitions and interface response parameter definitions respectively, and form backend interface feature data based on the backend interface path, the backend request method, the interface method identifier, the interface request parameter definitions and the interface response parameter definitions; S203, Read the call statements within the interface method from the backend abstract syntax tree, recursively read the called method along the call statements, and record the association between the interface method identifier, call source, call target and the order of the call statements to form backend program call data; S204, parse the function declarations, request call statements and path expressions in the front-end code to obtain the front-end call attribution relationship and the front-end path reference relationship, and construct the front-end abstract syntax tree based on the front-end call attribution relationship and the front-end path reference relationship; S205, locate the request call node from the front-end abstract syntax tree, read the request method and path expression from the request call node and the encapsulated function node referenced by the request call node, concatenate the path fragments according to the order of the path fragments in the path expression to form the front-end call path, determine the request method as the front-end request method, and form front-end call feature data based on the front-end call path and the front-end request method.
[0048] In this embodiment, the character content in the backend code is read, and keywords, identifiers, annotation symbols, delimiters, and operators are identified according to the lexical structure of the programming language. Then, class declarations, method declarations, annotations, and call statements are identified according to the syntactic structure. The inclusion relationship between class declarations and method declarations, the attachment relationship between annotations and annotated objects, and the inclusion relationship between method declarations and call statements constitute the backend syntactic hierarchy. Different types of syntactic nodes are established based on the backend syntactic hierarchy, and parent-child relationships, source file locations, and character ranges are recorded between nodes to obtain the backend abstract syntax tree. Local code that cannot be parsed can have its exception location recorded, and the parsing of other complete syntactic structures can continue.
[0049] The backend abstract syntax tree (API) locates method declaration nodes with interface mapping annotations and identifies these nodes as interface methods. Method declaration information can include the class name, method name, parameter type sequence, return type, and source file location. An interface method identifier can be generated from this information, ensuring that interface methods with the same name but different classes or parameter types are distinguishable. The class-level path value is read from the API annotation attached to the class declaration node, and the method-level path value is read from the API annotation attached to the interface method. These two path values are concatenated, with the class-level path value preceding the method-level path value, to obtain the backend API path. The request method can be read from the attributes of the method-level API annotation; if the annotation does not directly configure the request method, it can be determined based on the annotation type.
[0050] Interface request parameters can be parsed from the parameter declarations, parameter annotations, and parameter types of the interface method. Parameter declarations are used to obtain the parameter name and parameter type, parameter annotations are used to obtain the parameter source, path binding name, or request body binding relationship, and parameter types are used to recursively read object fields and nested types. The aforementioned content is recorded as the interface request parameter definition according to the parameter hierarchy. Interface response parameters can be parsed from the return type, generic parameters, and return expression of the interface method, and the interface response parameter definition is obtained by recursively reading the field declarations of the returned object. The backend interface path, backend request method, interface method identifier, interface request parameter definition, and interface response parameter definition are associated according to the same interface method to obtain backend interface characteristic data.
[0051] The call statements are read from the method body node of the interface method, and the called method is located based on the calling object, function name, and parameter types in the call statements. If the called method can be located in the backend code, the call statements within that method can be read recursively. During this process, the identifiers of already visited methods are recorded to avoid redundant readings due to circular calls. The method identifier of the call statement constitutes the call source, and the method identifier of the called method constitutes the call target. The order of the call statements can be determined based on their node position in the syntax tree, their character position in the source file, and their corresponding statement block. The interface method identifier, call source, call target, and the order of the call statements are associated according to the call records to obtain the backend program call data. For external calls whose declarations cannot be located, the calling object, function name, parameter content, and unresolved state are retained.
[0052] The process involves reading function declarations, request / call statements, and path expressions from the front-end code. Based on function scope and statement inclusion relationships, the function to which the request / call statement belongs is determined, thus obtaining the front-end call attribution relationship. When path expressions reference variables, function parameters, or configuration items, the source of the path content can be traced along variable assignment, parameter passing, and import relationships, yielding the front-end path reference relationship. Function declaration nodes, request / call nodes, and path expression nodes are connected according to the front-end call attribution relationship and the front-end path reference relationship, forming the front-end abstract syntax tree.
[0053] The request invocation node can be either the node that directly initiates the network request or the node that references the request encapsulation function. The request method and path expression are read from the parameters and attributes of the request invocation node. When the request method or path expression is inside the encapsulation function, the corresponding content in the encapsulation function node can be read along the function reference relationship. When the path expression contains strings, template expressions, variable references, or string concatenation operations, the path fragments are read according to their order in the expression. Parsable variable references can be replaced with their corresponding string content; variable references that cannot be statically determined can retain their variable expressions and positions. The path fragments are connected according to their order to obtain the front-end invocation path, and the read request method is recorded as the front-end request method. The front-end invocation path and the front-end request method are associated with the same request invocation node to obtain front-end invocation feature data.
[0054] This embodiment establishes front-end and back-end abstract syntax trees separately through syntax structure parsing, which can preserve the subordinate and referential relationships between code declarations, annotations, call statements, and path expressions. By parsing interface paths, request methods, request parameters, response parameters, and front-end request content, it can convert information scattered in different code locations into structured front-end call feature data and back-end interface feature data. By recursively reading back-end call statements and recording the call source, call target, and order, it can obtain back-end program call data with clear code sources, reduce information omissions caused by manual code reading, and improve the completeness and verifiability of the parsing results.
[0055] In one embodiment, such as Figure 5 As shown, step S30 above includes: S301, Read the front-end call path and front-end request method from the front-end call feature data, and read the back-end interface path and back-end request method from the back-end interface feature data; S302, unify the path separation form in the front-end call path and the back-end interface path, identify the front-end dynamic path segment formed by variable expression and the back-end dynamic path segment formed by path parameter placeholder from the front-end call path and the back-end interface path respectively, and replace the front-end dynamic path segment and the back-end dynamic path segment with path parameter markers to form a standard front-end call path and a standard back-end interface path. S303, when the front-end request method is consistent with the back-end request method, compare the path segment content and path segment arrangement order in the standard front-end call path and the standard back-end interface path. When the path segment content and the path segment arrangement order are the same, complete path corresponding data is formed. S304, when the front-end request method and the back-end request method are consistent and no complete path corresponding data is formed, the case of characters in the standard front-end call path and the standard back-end interface path are unified to form a fuzzy front-end call path and a fuzzy back-end interface path. Path segments other than path prefixes and path parameter markers are read from the fuzzy front-end call path to form a front-end path segment to be compared. Path segments other than path prefixes and path parameter markers are read from the fuzzy back-end interface path to form a back-end path segment to be compared. The content and arrangement order of the front-end path segment to be compared and the back-end path segment to be compared are compared. When the content and arrangement order of the front-end path segment to be compared and the back-end path segment to be compared are the same, fixed path corresponding data is formed. S305, based on the complete path corresponding data or the fixed path corresponding data, establish the correspondence between the front-end call feature data and the back-end interface feature data, record the correspondence, the front-end call feature data and the back-end interface feature data, and obtain the interface corresponding data.
[0056] In this embodiment, after reading the front-end call feature data, the front-end call path and front-end request method are obtained according to the field identifier; after reading the back-end interface feature data, the back-end interface path and back-end request method are obtained. The request method can be stored in a uniform character format to distinguish interfaces with the same path but different request operations. The path content is divided into multiple path segments according to the separator, and the arrangement position of each path segment is preserved so that path comparison can be performed on a segment-by-segment basis.
[0057] Path delimiters can be formatted by replacing reverse delimiters, merging consecutive delimiters, and unifying start and end delimiters. Variable expressions in the front-end call path can originate from template expressions, variable references, or string concatenation. The position of the variable expression within the path identifies the front-end dynamic path segment. Path parameter placeholders in the back-end interface path indicate the location where variable path values are received. The path segment containing the placeholder identifies the back-end dynamic path segment. Both front-end and back-end dynamic path segments are converted into path parameter markers, while other path segments retain their original content and arrangement, resulting in the standard front-end call path and standard back-end interface path.
[0058] When the frontend and backend request methods are consistent, the path segments in the two standard paths are compared one by one. The comparison includes the number of path segments, the character content of each path segment, the position of path parameter markers, and the order of the path segments. If all comparison content is consistent, the two standard paths, request methods, and path segment comparison results are recorded to obtain the complete path data. When the request methods are inconsistent, no association is established between the two sets of data to avoid merging different interface operations under the same path.
[0059] When complete path data is unavailable, the characters in the two standard paths can be converted to a uniform case to obtain the fuzzy frontend call path and the fuzzy backend interface path, respectively. The path prefix can be determined based on the frontend request configuration, the backend service entry configuration, or the position of the suffix of a fixed path segment. The path prefix and path parameter markers are removed from both fuzzy paths, retaining the fixed path segments used for interface identification, resulting in the frontend and backend path segments to be compared. The content and order of the two types of path segments are compared one by one according to their position. If no unmatched fixed path segment exists, the comparison results of the two fuzzy paths, request methods, and fixed path segments are recorded to obtain the data corresponding to the fixed path.
[0060] Complete path correspondence data indicates that two interface paths have the same structure after a unified delimiter and dynamic path tagging. Fixed path correspondence data indicates that two interface paths have the same fixed content after excluding path prefixes, character case differences, and dynamic path differences. The system associates frontend call feature data and backend interface feature data with either type of data, recording the association type, the identifiers of the two types of data, and the comparison result to obtain the interface correspondence data. When multiple backend interfaces meet the same comparison condition, candidate correspondences can be saved separately to avoid arbitrarily selecting a backend interface when distinguishing information is lacking.
[0061] This embodiment reduces the impact of path writing format and dynamic content on comparison results by unifying the path separation format and converting dynamic path segments from different sources into path parameter tags. By combining request methods, complete path structures, and fixed path segments for hierarchical comparison, it can identify front-end and back-end interfaces with differences in path prefixes or character case, and reduce erroneous associations caused by different request methods for the same path. The interface corresponding data retains the data identifiers, association types, and comparison results involved in the comparison, improving the accuracy and verifiability of front-end and back-end call relationships.
[0062] In one embodiment, such as Figure 6 As shown, step S40 above includes: S401, read the front-end call feature data, back-end interface feature data and corresponding relationship from the interface corresponding data, read the front-end call path from the front-end call feature data, read the back-end interface path and interface method identifier from the back-end interface feature data, and read the call source, call target and call statement order associated with the interface method identifier from the back-end program call data; S402, determine the front-end call participation items according to the front-end call path, determine the back-end method participation items according to the call source and the call target, determine the interface method participation items identified by the interface method identifier from the back-end method participation items, and associate the back-end interface path with the interface method participation items to form call participation item data; S403, taking the front-end call participation item as the interface call source and the interface method participation item as the interface call target, form interface call message data containing interface call messages according to the correspondence; taking the back-end method participation item corresponding to the call source as the back-end call source and the back-end method participation item corresponding to the call target as the back-end call target, form back-end call message data containing back-end call messages according to the order of the call statements. S404, establish a timing lifeline based on the call participant data, and for each correspondence, write the interface call message between the timing lifeline corresponding to the interface call source and the interface call target according to the interface call message data. Write the backend call message between the timing lifeline corresponding to the backend call source and the backend call target in sequence according to the order of the call statements to form timing description data, and generate a timing diagram based on the timing description data. S405, using the call participants in the call participant data as topology nodes, establish topology connections based on the call relationship between the interface call source and the interface call target and the call relationship between the backend call source and the backend call target to form topology description data, and generate a call relationship topology graph based on the topology description data.
[0063] In this embodiment, the front-end call characteristic data, back-end interface characteristic data, and corresponding relationships are read from the interface-corresponding data, and the two types of data belonging to the same interface call are determined according to the corresponding relationships. The front-end call path is read from the front-end call characteristic data, and the back-end interface path and interface method identifier are read from the back-end interface characteristic data. The back-end program call data saves the corresponding call records according to the interface method identifier, and the call source, call target, and call statement order are read from the call records. The call source and call target can be distinguished by the class identifier, function name, and parameter type sequence to avoid functions with the same name in different classes being identified as the same call object.
[0064] Frontend call participation items are generated based on the frontend call path. Each participation item can include a participation item identifier, participation item type, and frontend call path. Backend method participation items are generated separately based on the call source and call target. Call sources and calls with the same call object identifier can be merged into the same backend method participation item. When the interface method identifier matches the call object identifier of a backend method participation item, the corresponding backend method participation item is identified as an interface method participation item, and the backend interface path is written into the interface method participation item. Frontend call participation items, interface method participation items, and other backend method participation items are saved as call participation item data according to their participation item identifiers.
[0065] The mapping relationships in the interface mapping data are used to connect front-end call participants and interface method participants. Front-end call participant records represent the interface call source, and interface method participant records represent the interface call target. The front-end call path, back-end interface path, and participant identifier can be written into the interface call message to obtain the interface call message data. Each call record in the back-end program call data is mapped to two back-end method participants. The participant record associated with the call source is the back-end call source, and the participant record associated with the call target is the back-end call target. The order of the call statements, along with the back-end call source and back-end call target, are written into the back-end call message to obtain the back-end call message data. Recursive or repeated calls can be retained as multiple back-end call messages, distinguished by the call position and order.
[0066] A timing lifeline is established for each call participant based on the call participant data, with the lifeline identifier consistent with the participant identifier. For each correspondence, an interface call message is written between the timing lifeline of the front-end call participant and the interface method participant. Then, timing positions are assigned to the back-end call messages according to the order of the call statements, and the message direction and message content are written between the lifelines corresponding to the back-end call source and the back-end call target. When different call messages have the same source and target, different timing positions can be set according to the order of arrangement. Lifeline information, message endpoints, message content, and timing positions constitute timing description data. The timing description data can be converted into graphical drawing instructions or structured graphical files to generate a timing diagram.
[0067] Each call participant in the call participant data is converted into a topology node, with the node identifier using the participant identifier. An interface topology connection is established between the interface call source and the interface call target, and a backend topology connection is established between the backend call source and the backend call target, with the connection direction consistent with the call direction. When multiple call messages have the same source and target, multiple topology connections can be retained, or multiple call positions can be recorded within the same topology connection. Topology nodes, node types, connection directions, and call content constitute the topology description data. The topology description data can arrange nodes according to the call hierarchy, or allocate node positions based on node connection relationships to generate a call relationship topology graph.
[0068] This embodiment identifies the data corresponding to the associated interface and the backend program call data through an interface method, which can distinguish backend call records according to specific interfaces and reduce the mixing of different interface call content; by unifying the participant item identification and establishing interface call messages and backend call messages, it can maintain the continuous call relationship between frontend calls, interface entry points and backend functions; by generating a sequence diagram according to the order of call statements and generating a call relationship topology diagram according to the call source and call target, it can accurately present the call order, call direction and program dependency relationship, and improve the completeness and verifiability of the graphical content.
[0069] In one embodiment, such as Figure 7 As shown, step S50 above includes: S501, Read the front-end call feature data and corresponding relationship from the interface corresponding data, and associate the front-end call feature data with the back-end interface feature data according to the corresponding relationship to form interface document item data; S502, read the front-end call path and front-end request method from the front-end call feature data, read the back-end interface path, back-end request method, interface request parameter definition and interface response parameter definition from the back-end interface feature data, and determine the interface timing image segment from the timing diagram based on the front-end call path, the front-end request method and the back-end interface path and the back-end request method, and determine the interface topology image segment from the call relationship topology diagram; S503, generate request example data according to the interface request parameter definition, generate response example data according to the interface response parameter definition, obtain a document template, and write the front-end call path, the front-end request method, the back-end interface path, the back-end request method, the interface request parameter definition, the interface response parameter definition, the request example data, the response example data, the interface timing image segment, and the interface topology image segment into the document template according to the interface document item data, and generate an interface document; S504, establish a version document storage directory according to the version identifier, write the interface document into the version document storage directory, and obtain the interface document storage location; S505, Read the backend interface path and the backend request method from the interface document, and generate document index data based on the version identifier, the backend interface path, the backend request method, and the interface document storage location.
[0070] In this embodiment, front-end call feature data and corresponding relationships are read from the interface corresponding data, and back-end interface feature data associated with the front-end call feature data are determined based on the corresponding relationships. Each set of associated data can be saved as an interface document item, and the interface document item data includes a corresponding relationship identifier, a front-end call feature data identifier, and a back-end interface feature data identifier. When multiple front-end calls point to the same back-end interface, multiple interface document items can be saved separately, or multiple front-end call feature data identifiers can be recorded in the same interface document item to keep the sources of each call distinguishable.
[0071] The front-end call path and request method are read from the front-end call feature data, and the back-end interface path, request method, interface request parameter definition, and interface response parameter definition are read from the back-end interface feature data. The front-end call path, request method, back-end interface path, and request method can all be used as search criteria for graphical content. When a sequence diagram saves message content according to the interface call source and target, the corresponding participants, lifelines, and call messages can be determined based on the aforementioned search criteria to obtain the interface sequence image segment. When a call relationship topology diagram contains topology nodes and topology connections for multiple interfaces, the interface participants can be located based on the back-end interface path and request method, and the front-end call nodes, back-end program nodes, and topology connections connected to the interface participants can be read to obtain the interface topology image segment. When a sequence diagram or call relationship topology diagram is generated separately for each interface, a complete graph with consistent search criteria can be used as the corresponding image segment.
[0072] Interface request parameter definitions can include parameter names, parameter types, parameter levels, parameter sources, and optional attributes. Interface response parameter definitions can include response field names, field types, field levels, and nesting relationships. When generating request sample data, the request data structure is built according to the parameter level, and sample values matching the parameter types are written. When generating response sample data, the response data structure is built according to the field level and nesting relationships. If sample values or default values are already recorded in the parameter definitions, the corresponding values can be used; if no numerical content is recorded, the corresponding sample content can be read from the type mapping data based on character, number, boolean, set, and object types. The generated sample data for both types maintains the same field names and hierarchical relationships as the parameter definitions.
[0073] The document template can be an editable template, a tagged template, or a structured template, and can include an interface information area, a parameter area, an example area, and a graphics area. A document area is created for each interface based on the interface document item data. The front-end call path, front-end request method, back-end interface path, and back-end request method are written to the interface information area; the interface request parameter definition and interface response parameter definition are written to the parameter area; the request example data and response example data are written to the example area; and the interface sequence image segment and interface topology image segment are written to the graphics area. The interface areas in the document template can be copied cyclically, allowing multiple interface document items to be written into the same interface document with the same content structure.
[0074] The version identifier can be converted from directory characters and used as the directory name for the version document storage directory, or it can be associated with the directory path as a directory attribute. After the version document storage directory is established, the interface document is written to the directory, and the document name and directory path are recorded to obtain the interface document storage location. After the interface document is written, the backend interface path and backend request method are read from the interface information area of the interface document, and the version identifier, backend interface path, backend request method, and interface document storage location are written to the structured index record to obtain the document index data. When an interface document contains multiple interfaces, an index record can be created for each interface, and all index records can point to the same interface document storage location.
[0075] This embodiment associates front-end call information with back-end interface information through a correspondence, and writes parameter definitions, sample data, and interface graphics into a unified structured interface document, which can reduce misalignment of data from different sources during the document generation process; it locates time-series image segments and topology image segments by interface path and request method, which can keep the graphic content associated with the interface document items; it separates and stores interface documents according to version identifiers, and generates document index data from the interface document content and storage location, which can improve the distinguishability, content completeness, and retrieval accuracy of interface documents of different versions.
[0076] In one embodiment, such as Figure 8 As shown, after step S50 above, the following steps are also included: S601, Obtain the actual test data of the interface after the front-end code and the back-end code are deployed, and read the actual request path, actual request method, actual request data and actual response data from the actual test data, wherein the actual request data and the actual response data come from the same interface interaction; S602, read backend interface feature data from the interface corresponding data, read backend interface path and backend request method from the backend interface feature data, read backend fixed path segments (excluding path parameter placeholders) from the backend interface path, read the measured fixed path segments corresponding to the positions of the backend fixed path segments from the measured request paths, compare the content and arrangement order of the backend fixed path segments and the measured fixed path segments, and compare the measured request method and the backend request method. When the path segment content, path segment arrangement order, and request method are all the same, determine the target interface corresponding item. S603, based on the target interface corresponding item, locate the target interface document item in the interface document, and locate the target document index item in the document index data; S604, update the request example data in the target interface document item to the actual request data, update the response example data in the target interface document item to the actual response data, and obtain the updated interface document; S605, the updated interface document is overwritten with the updated interface document, the document update time is recorded, and the document update time is written into the target document index item to update the document index data.
[0077] In this embodiment, after the front-end and back-end code are deployed, interface interaction content can be collected at the request sending location, interface receiving location, or network proxy location. Each piece of interface test data can record the test request path, test request method, actual request data, actual response data, and interface interaction identifier. Actual request data may include path parameters, query parameters, request headers, and request body; actual response data may include response status, response headers, and response body. Request sending records and response return records can be paired using interface interaction identifiers, or they can be paired based on connection identifiers, request order, and time information, ensuring that the actual request data and actual response data belong to the same interface interaction. Data that cannot be paired with a response can be retained in an unpaired state and not written to the interface documentation.
[0078] Read backend interface feature data from the corresponding interface data, and obtain the backend interface path and backend request method. The backend interface path is divided into multiple path segments according to the path separator. The path segment containing the path parameter placeholder is not included in the fixed content comparison. Other path segments are recorded as backend fixed path segments. The actual request path is divided using the same path separator method. Based on the position of the backend fixed path segment in the backend interface path, the actual fixed path segment is read from the corresponding position in the actual request path. Compare the character content, number of path segments, and order of the backend fixed path segments and the actual fixed path segments one by one, and compare the actual request method and the backend request method. When all comparison contents are consistent, the corresponding interface data is determined as the target interface corresponding item. When multiple matching results exist, candidate items can be retained by combining the complete path length, fixed path segment position, or interface interaction identifier association information to avoid writing the actual data to irrelevant interfaces.
[0079] The target interface corresponding item can include front-end call feature data identifiers, back-end interface feature data identifiers, and corresponding relationship identifiers. Based on the back-end interface feature data identifiers, the document item with the same back-end interface path and request method is searched in the interface information area of the interface document to obtain the target interface document item. When document index data is stored according to version identifier, back-end interface path, back-end request method, and interface document storage location, the corresponding index record can be found using the back-end interface information in the target interface corresponding item to obtain the target document index item. When the interface document contains multiple versions or multiple interfaces with the same path, the document item and index item can be distinguished by combining the version identifier and request method.
[0080] The actual request data is written to the request example area of the target API document item, and the actual response data is written to the response example area of the target API document item. When the API document uses a structured file, the field values of the request example field and the response example field can be replaced; when the API document uses an editable document or a markup document, the content boundaries of the two example areas can be located, and the content of the areas can be replaced with the serialized actual request data and the actual response data. When the data has a nested structure, the objects and collection relationships are saved according to the field hierarchy. After replacing the content of the two example areas, the table of contents, content references, and graphic references of the API document are rewritten to obtain the updated API document.
[0081] After updating, the API documentation can be written to a temporary storage location first. Once the file content is fully written, the API documentation will be replaced, reducing the possibility of incomplete files during the overwrite process. The document update time can be obtained from the time information at the time of replacement and written to the target document index entry using a uniform time format. The storage location of the API documentation in the target document index entry remains unchanged, the document update time is replaced with the current record value, and the index records of other APIs are retained, resulting in the updated document index data.
[0082] This embodiment pairs actual request data and actual response data using interface interaction identifiers, and determines the corresponding item of the target interface by combining fixed path segments, path segment locations, and request methods. This reduces data mismatches caused by dynamic path content and different request methods on the same path. By locating the target interface document item and replacing the request example data and response example data, the example content in the interface document is kept consistent with the interface interaction content after deployment. By overwriting the interface document and synchronously updating the document update time in the target document index item, the content association and time consistency between the interface document and the document index data can be maintained.
[0083] In one embodiment, the agricultural insurance business platform needs to iterate on the high-risk land parcel tagging function. The front-end page is used to submit land parcel information, query tagging tasks, and view risk levels. The back-end service is used to receive interface requests, verify the relationship between policies and land parcels, query risk data, and return tagging results. When creating an analysis task, the front-end code repository address, the back-end code repository address, and the 2026.07.22 version identifier are input. The front-end code repository stores the task list page, task details page, request encapsulation file, and page routing configuration. The back-end code repository stores the interface control file, business processing file, data access file, and parameter object file. The version correspondence data records the mapping relationship between the 2026.07.22 version identifier and the front-end release tag and back-end iteration branch. After accessing the two code repositories, the front-end version reference information and the back-end version reference information are read respectively. The two version reference identifiers are compared with the branches, tags, and commit records in the corresponding repositories to determine the front-end target version reference information and the back-end target version reference information. Based on the front-end and back-end target version reference information, the front-end and back-end code repositories are switched to their respective code states, and the front-end and back-end version file sets are read from these states. The front-end version file set is written to the front-end code storage directory, and the back-end version file set is written to the back-end code storage directory, resulting in the 2026.07.22 version of the front-end and back-end code, respectively.
[0084] The backend code is parsed using a backend code syntax parsing method, and an Abstract Syntax Tree (AST) is constructed based on the parsed syntax units and their hierarchical relationships. The parsed syntax includes class declarations, method declarations, interface mapping annotations, parameter declarations, return types, and call statements. The class-level path value of the risk label interface control class is the risk label business path, and the method-level path value of the task pagination interface is the task pagination path. Concatenating these two path values yields ` / api / riskLabel / taskPageList` (the risk label task pagination interface path), and a POST (submission request method) is read from the interface mapping annotation. An interface method identifier is generated based on the class name, function name, parameter type, and source file location. The request parameters for the task pagination interface include the current page, number of tasks per page, task status, and risk level. The response parameters include the total number of records, the task list, and the task identifier, task name, task status, risk level, and creation time for each item in the list. When the parameter object contains nested objects, the nested fields and their hierarchical relationships are recursively read according to field type. The backend interface path, backend request method, interface method identifier, request parameter definition, and response parameter definition are written into the backend interface feature data.
[0085] The system reads call statements from the function bodies of the task pagination interface, identifying calls from the interface control function to the task query function, calls from the task query function to the data access function, and calls from the data access function to the database query operation. The function to which the call statement belongs is recorded as the call source, the called function as the call target, and the position of the call statement within the function body is recorded as the call statement order. If there are further calls within the called function, the system continues reading the call statements within the corresponding function body, avoiding circular reading by identifying already accessed functions. For interfaces such as task submission, task detail query, file upload, and risk type query, the system records the interface method identifier, call source, call target, and call statement order to obtain the backend program call data.
[0086] After syntax parsing, the script files and front-end component files in the front-end code identify the request call nodes generated by network request components, network request functions, and custom request encapsulation functions. The task list page initiates task pagination requests through request encapsulation functions, reading the request method and path expression from the request call node and associated encapsulation function node. The path expression is constructed by concatenating the basic business path, risk label path, and task pagination path, and the front-end call path is obtained according to the order of path fragments. The read POST is recorded as the front-end request method. The task identifier in the task details page is written into the path using a variable expression, and the location of the variable expression is retained as a front-end dynamic path segment. Each front-end call path and front-end request method is associated according to the request call node to obtain front-end call feature data.
[0087] The front-end call feature data and back-end interface feature data are matched. For task pagination requests, the front-end call path and back-end interface path share the same path segment, and both the front-end and back-end request methods are POST, forming complete path-corresponding data. The front-end path for task detail requests includes a gateway prefix and variable expressions, while the back-end path includes path parameter placeholders. After standardizing the separator format in both paths, both front-end and back-end dynamic path segments are replaced with path parameter markers. If prefix differences still exist in the complete path, character case is standardized, and path prefixes and path parameter markers are excluded. The content and order of the remaining fixed path segments are compared. When the fixed path segments and GET (query request method) match, fixed path-corresponding data is formed. Based on the two types of path-corresponding data, the front-end call feature data, back-end interface feature data, and their corresponding relationships are recorded to obtain interface-corresponding data. Matching is performed on the eight APIs (Application Programming Interfaces) discovered in version 2026.07.22, and each interface-corresponding data retains the front-end call path, request method, back-end interface path, interface method identifier, and matching type.
[0088] The interface data and backend program call data are associated according to the interface method identifier. The task pagination interface generates frontend task list pages, interface control functions, task query functions, and data access functions as call participants. The frontend task list page records the interface call source, the interface control function records the interface call target, and a task pagination interface call message is written between them. The interface control function, task query function, and data access function are respectively used as backend method participants and written into the backend call message according to the order of the call statements. A timing lifeline is established based on the call participants, and messages such as page request, interface reception, business query, database access, and result return are written sequentially between the corresponding lifelines to generate the timing description data of the task pagination interface. The call participants, timing lifelines, and message order in the timing description data are converted into graphical elements to generate a timing diagram for document use; the timing description data is also converted into webpage-renderable graphical description data to generate a timing diagram for webpage use. The call participants are converted into topology nodes. The call relationships between the front-end page and the interface control function, the interface control function and the task query function, and the task query function and the data access function are converted into topology connections. The topology nodes and connection lines are drawn according to the positional relationship between the topology nodes and the topology connections to generate a call relationship topology graph.
[0089] The interface data is associated with front-end call feature data and back-end interface feature data according to the corresponding relationship, and interface document item data is created for each of the 8 interfaces. Based on the front-end call path, front-end request method, back-end interface path, and back-end request method, the time sequence image segment of each interface is determined from the time sequence diagram, and the topology nodes and topology connections connected to the interface participants are read from the call relationship topology diagram to obtain the interface topology image segment. The request parameter definition of the task pagination interface is converted into a request parameter table, and request example data is generated according to parameter name, parameter type, and parameter level; the response parameter definition is converted into a response parameter table, and response example data is generated according to response fields and nesting relationships. The document template adopts an editable text processing document format, setting the requirement overview, overall call relationship, interface path, request method, parameter table, JSON (JavaScript Object Notation) example, and graphic area. The path, request method, parameter definition, example data, time sequence image segment, and topology image segment of each interface are written into the corresponding document area to generate the interface document version 2026.07.22.
[0090] A version document storage directory is established based on the version identifier of 2026.07.22, and the interface documents are written to the high-risk land parcel tag requirement directory in the network auxiliary storage. Directory writing can be completed via the network storage access interface. The interface document storage location is recorded as a combination of the requirement directory, version directory, and document name. After the interface documents are written, the paths and corresponding request methods of eight backend interfaces are read from the document content, and document index data is generated by combining the version identifier and the interface document storage location. The index record includes the requirement identifier, version identifier, number of interfaces, interface path, request method, generation time, and document storage location, ensuring that different versions of the same requirement remain distinguishable.
[0091] After deploying the front-end and back-end code to the test environment, developers started request recording on the high-risk plot label page. They collected HTTP (Hypertext Transfer Protocol) interface interaction data using the request and response interceptors of the front-end network request component. A single functional operation collected three types of interface test data: task pagination, task details, and task submission. Each data item saved the test request path, test request method, actual request data, actual response data, and interface interaction identifier. Request and response records were paired based on the interface interaction identifier to ensure that the actual request and response data came from the same interface interaction.
[0092] For the task details interface, the backend fixed path segment (excluding path parameter placeholders) is read from the backend interface path, and the tested fixed path segment is read from the corresponding position in the tested request path. The content and order of the backend fixed path segment and the tested fixed path segment are consistent. When both the tested request method and the backend request method are GET, the corresponding item for the task details interface is determined. Based on the corresponding item, the task details interface document item is located in the interface documentation, and the target document index item for version 2026.07.22 is located in the document index data. The actual request data is written to the request example area of the task details interface document item, and the actual response data is written to the response example area, resulting in the updated interface document. The updated interface document overwrites the interface document in the version directory, the overwrite completion time is recorded as the document update time, and it is written to the target document index item, ensuring that the request example, response example, and document index data in the interface document reflect the interface interaction content after this deployment.
[0093] In one embodiment, an interface documentation generation apparatus based on front-end and back-end code is provided, which corresponds one-to-one with the interface documentation generation method based on front-end and back-end code in the above embodiments. (Refer to...) Figure 9 , Figure 9This is a schematic diagram of the functional modules of a preferred embodiment of the interface documentation generation device based on front-end and back-end code of the present invention. The interface documentation generation device based on front-end and back-end code includes: a code acquisition module 10, a feature parsing module 20, an interface matching module 30, a call graph generation module 40, and a document management module 50. Detailed descriptions of each functional module are as follows: The code acquisition module 10 is used to acquire the front-end code repository address, the back-end code repository address, and the version identifier, and to acquire the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier; Feature parsing module 20 is used to parse the front-end code and the back-end code to form front-end call feature data, back-end interface feature data and back-end program call data; Interface matching module 30 is used to establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain interface corresponding data; Call graph generation module 40 is used to generate a timing diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data; The document management module 50 is used to generate interface documents based on the backend interface feature data, the corresponding interface data, the timing diagram and the call relationship topology diagram, store the interface documents according to the version identifier, and generate document index data based on the interface documents.
[0094] In one embodiment, the code acquisition module 10 is specifically used for: Obtain the front-end code repository address, back-end code repository address, and version identifier; access the front-end code repository pointed to by the front-end code repository address; read the front-end version reference information from the front-end code repository; access the back-end code repository pointed to by the back-end code repository address; and read the back-end version reference information from the back-end code repository. Obtain version-corresponding data, and read the front-end version reference identifier and back-end version reference identifier associated with the version identifier from the version-corresponding data; The front-end version reference identifier is compared with the front-end version reference information to determine the front-end target version reference information, and the back-end version reference identifier is compared with the back-end version reference information to determine the back-end target version reference information; Establish a front-end code storage directory and a back-end code storage directory; Based on the front-end target version reference information, the front-end version file set is read from the front-end code repository, and the front-end version file set is written to the front-end code storage directory to form the front-end code; Based on the backend target version reference information, the backend version file set is read from the backend code repository and written to the backend code storage directory to form the backend code.
[0095] In one embodiment, the feature parsing module 20 is specifically used for: Parse the class declarations, method declarations, annotations, and call statements in the backend code to obtain the backend syntax hierarchy, and construct the backend abstract syntax tree based on the backend syntax hierarchy; The interface method is located in the backend abstract syntax tree. The method declaration information of the interface method is read from the backend abstract syntax tree to form an interface method identifier. The class-level path value, method-level path value, and request method are extracted from the backend abstract syntax tree. The class-level path value and the method-level path value are concatenated to form a backend interface path. The request method is determined as the backend request method. The interface request parameters and interface response parameters of the interface method are parsed from the backend abstract syntax tree to form interface request parameter definitions and interface response parameter definitions, respectively. Backend interface feature data is formed based on the backend interface path, the backend request method, the interface method identifier, the interface request parameter definitions, and the interface response parameter definitions. Read the call statements within the interface method from the backend abstract syntax tree, recursively read the called method along the call statements, and record the association between the interface method identifier, call source, call target, and the order of the call statements to form backend program call data; The function declarations, request call statements, and path expressions in the front-end code are parsed to obtain the front-end call attribution relationship and the front-end path reference relationship. Based on the front-end call attribution relationship and the front-end path reference relationship, a front-end abstract syntax tree is constructed. The request call node is located in the front-end abstract syntax tree. The request method and path expression are read from the request call node and the encapsulated function node referenced by the request call node. The path fragments are concatenated according to the order of the path fragments in the path expression to form the front-end call path. The request method is determined as the front-end request method. Front-end call feature data is formed based on the front-end call path and the front-end request method.
[0096] In one embodiment, the interface matching module 30 is specifically used for: Read the front-end call path and front-end request method from the front-end call feature data, and read the back-end interface path and back-end request method from the back-end interface feature data; The path separation format in the front-end call path and the back-end interface path is unified. The front-end dynamic path segment formed by variable expression and the back-end dynamic path segment formed by path parameter placeholder are identified from the front-end call path and the back-end interface path respectively. The front-end dynamic path segment and the back-end dynamic path segment are replaced with path parameter markers to form a standard front-end call path and a standard back-end interface path. When the front-end request method is the same as the back-end request method, the path segment content and the path segment arrangement order in the standard front-end call path and the standard back-end interface path are compared. When the path segment content and the path segment arrangement order are the same, complete path corresponding data is formed. When the front-end request method and the back-end request method are the same and no complete path corresponding data is formed, the case of characters in the standard front-end call path and the standard back-end interface path are unified to form a fuzzy front-end call path and a fuzzy back-end interface path. The path segment excluding the path prefix and path parameter mark is read from the fuzzy front-end call path to form a front-end path segment to be compared. The path segment excluding the path prefix and path parameter mark is read from the fuzzy back-end interface path to form a back-end path segment to be compared. The content and arrangement order of the front-end path segment to be compared and the back-end path segment to be compared are compared. When the content and arrangement order of the front-end path segment to be compared and the back-end path segment to be compared are the same, fixed path corresponding data is formed. Based on the complete path corresponding data or the fixed path corresponding data, establish the correspondence between the front-end call feature data and the back-end interface feature data, record the correspondence, the front-end call feature data and the back-end interface feature data, and obtain the interface corresponding data.
[0097] In one embodiment, the graph generation module 40 is invoked, specifically for: Read front-end call feature data, back-end interface feature data and their corresponding relationships from the interface corresponding data; read the front-end call path from the front-end call feature data; read the back-end interface path and interface method identifier from the back-end interface feature data; and read the call source, call target and call statement order associated with the interface method identifier from the back-end program call data. The front-end call participation items are determined based on the front-end call path, the back-end method participation items are determined based on the call source and the call target, the interface method participation items identified by the interface method identifier are determined from the back-end method participation items, and the back-end interface path is associated with the interface method participation items to form call participation item data; Using the front-end call participants as the source of the interface call and the interface method participants as the target of the interface call, interface call message data containing interface call messages is formed according to the correspondence; using the back-end method participants corresponding to the call source as the back-end call source and the back-end method participants corresponding to the call target as the back-end call target, back-end call message data containing back-end call messages is formed according to the order of the call statements. Establish a timeline lifeline based on the call participant data. For each correspondence, write the interface call message between the timeline lifeline corresponding to the interface call source and the interface call target according to the interface call message data. Write the backend call message between the timeline lifeline corresponding to the backend call source and the backend call target according to the order of the call statements to form timeline description data. Generate a timeline diagram based on the timeline description data. Using the call participants in the call participant data as topology nodes, a topology connection is established based on the call relationship between the interface call source and the interface call target, as well as the call relationship between the backend call source and the backend call target, forming topology description data, and a call relationship topology graph is generated based on the topology description data.
[0098] In one embodiment, the document management module 50 is specifically used for: Read the front-end call feature data and corresponding relationship from the interface corresponding data, and associate the front-end call feature data with the back-end interface feature data according to the corresponding relationship to form interface document item data; Read the front-end call path and front-end request method from the front-end call feature data, and read the back-end interface path, back-end request method, interface request parameter definition and interface response parameter definition from the back-end interface feature data. Based on the front-end call path, the front-end request method, the back-end interface path and the back-end request method, determine the interface timing image segment from the timing diagram, and determine the interface topology image segment from the call relationship topology diagram. Generate request example data based on the interface request parameter definition, generate response example data based on the interface response parameter definition, obtain a document template, and write the front-end call path, the front-end request method, the back-end interface path, the back-end request method, the interface request parameter definition, the interface response parameter definition, the request example data, the response example data, the interface timing image segment, and the interface topology image segment into the document template based on the interface document item data, thereby generating the interface document; Establish a version document storage directory based on the version identifier, write the interface document into the version document storage directory, and obtain the interface document storage location; The backend interface path and the backend request method are read from the interface document. Based on the version identifier, the backend interface path, the backend request method, and the interface document storage location, document index data is generated.
[0099] In one embodiment, the document management module 50 is specifically used for: Obtain the actual test data of the interface after the front-end code and the back-end code are deployed, and read the actual request path, actual request method, actual request data and actual response data from the interface test data. The actual request data and the actual response data come from the same interface interaction. Read backend interface feature data from the interface corresponding data, read backend interface path and backend request method from the backend interface feature data, read backend fixed path segments (excluding path parameter placeholders) from the backend interface path, read the measured fixed path segments corresponding to the positions of the backend fixed path segments from the measured request paths, compare the content and arrangement order of the backend fixed path segments and the measured fixed path segments, and compare the measured request method and the backend request method. When the path segment content, path segment arrangement order, and request method are all the same, determine the corresponding item of the target interface. Based on the corresponding item of the target interface, locate the target interface document item in the interface document, and locate the target document index item in the document index data; Update the request example data in the target interface document item to the actual request data, and update the response example data in the target interface document item to the actual response data to obtain the updated interface document; The updated interface document is overwritten with the updated interface document, the document update time is recorded, and the document update time is written into the target document index item to update the document index data.
[0100] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a server-side interface documentation generation method based on front-end and back-end code.
[0101] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements client-side functions or steps of an interface documentation generation method based on front-end and back-end code.
[0102] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Obtain the front-end code repository address, the back-end code repository address, and the version identifier; and obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier. The front-end code and the back-end code are parsed to form front-end call feature data, back-end interface feature data, and back-end program call data. Establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data; Generate a sequence diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data; An interface document is generated based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram. The interface document is stored according to the version identifier, and document index data is generated based on the interface document.
[0103] In one embodiment, a computer-readable storage medium is provided, which may be non-volatile or volatile, and a computer program is stored thereon, which, when executed by a processor, performs the following steps: Obtain the front-end code repository address, the back-end code repository address, and the version identifier; and obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier. The front-end code and the back-end code are parsed to form front-end call feature data, back-end interface feature data, and back-end program call data. Establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data; Generate a sequence diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data; An interface document is generated based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram. The interface document is stored according to the version identifier, and document index data is generated based on the interface document.
[0104] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0105] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0106] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0107] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
[0108] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for generating interface documentation based on front-end and back-end code, characterized in that, Includes the following steps: Obtain the front-end code repository address, the back-end code repository address, and the version identifier; and obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier. The front-end code and the back-end code are parsed to form front-end call feature data, back-end interface feature data, and back-end program call data. Establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data; Generate a sequence diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data; An interface document is generated based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram. The interface document is stored according to the version identifier, and document index data is generated based on the interface document.
2. The interface documentation generation method based on front-end and back-end code according to claim 1, characterized in that, Obtain the front-end code repository address, the back-end code repository address, and the version identifier; obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier, including: Obtain the front-end code repository address, back-end code repository address, and version identifier; access the front-end code repository pointed to by the front-end code repository address; read the front-end version reference information from the front-end code repository; access the back-end code repository pointed to by the back-end code repository address; and read the back-end version reference information from the back-end code repository. Obtain version-corresponding data, and read the front-end version reference identifier and back-end version reference identifier associated with the version identifier from the version-corresponding data; The front-end version reference identifier is compared with the front-end version reference information to determine the front-end target version reference information, and the back-end version reference identifier is compared with the back-end version reference information to determine the back-end target version reference information; Establish a front-end code storage directory and a back-end code storage directory; Based on the front-end target version reference information, the front-end version file set is read from the front-end code repository, and the front-end version file set is written to the front-end code storage directory to form the front-end code; Based on the backend target version reference information, the backend version file set is read from the backend code repository and written to the backend code storage directory to form the backend code.
3. The interface documentation generation method based on front-end and back-end code according to claim 1, characterized in that, The front-end code and the back-end code are parsed to form front-end call characteristic data, back-end interface characteristic data, and back-end program call data, including: Parse the class declarations, method declarations, annotations, and call statements in the backend code to obtain the backend syntax hierarchy, and construct the backend abstract syntax tree based on the backend syntax hierarchy; The interface method is located in the backend abstract syntax tree. The method declaration information of the interface method is read from the backend abstract syntax tree to form an interface method identifier. The class-level path value, method-level path value, and request method are extracted from the backend abstract syntax tree. The class-level path value and the method-level path value are concatenated to form a backend interface path. The request method is determined as the backend request method. The interface request parameters and interface response parameters of the interface method are parsed from the backend abstract syntax tree to form interface request parameter definitions and interface response parameter definitions, respectively. Backend interface feature data is formed based on the backend interface path, the backend request method, the interface method identifier, the interface request parameter definitions, and the interface response parameter definitions. Read the call statements within the interface method from the backend abstract syntax tree, recursively read the called method along the call statements, and record the association between the interface method identifier, call source, call target, and the order of the call statements to form backend program call data; The function declarations, request call statements, and path expressions in the front-end code are parsed to obtain the front-end call attribution relationship and the front-end path reference relationship. Based on the front-end call attribution relationship and the front-end path reference relationship, a front-end abstract syntax tree is constructed. The request call node is located in the front-end abstract syntax tree. The request method and path expression are read from the request call node and the encapsulated function node referenced by the request call node. The path fragments are concatenated according to the order of the path fragments in the path expression to form the front-end call path. The request method is determined as the front-end request method. Front-end call feature data is formed based on the front-end call path and the front-end request method.
4. The interface documentation generation method based on front-end and back-end code according to claim 1, characterized in that, Establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data, including: Read the front-end call path and front-end request method from the front-end call feature data, and read the back-end interface path and back-end request method from the back-end interface feature data; The path separation format in the front-end call path and the back-end interface path is unified. The front-end dynamic path segment formed by variable expression and the back-end dynamic path segment formed by path parameter placeholder are identified from the front-end call path and the back-end interface path respectively. The front-end dynamic path segment and the back-end dynamic path segment are replaced with path parameter markers to form a standard front-end call path and a standard back-end interface path. When the front-end request method is the same as the back-end request method, the path segment content and the path segment arrangement order in the standard front-end call path and the standard back-end interface path are compared. When the path segment content and the path segment arrangement order are the same, complete path corresponding data is formed. When the front-end request method and the back-end request method are the same and no complete path corresponding data is formed, the case of characters in the standard front-end call path and the standard back-end interface path are unified to form a fuzzy front-end call path and a fuzzy back-end interface path. The path segment excluding the path prefix and path parameter mark is read from the fuzzy front-end call path to form a front-end path segment to be compared. The path segment excluding the path prefix and path parameter mark is read from the fuzzy back-end interface path to form a back-end path segment to be compared. The content and arrangement order of the front-end path segment to be compared and the back-end path segment to be compared are compared. When the content and arrangement order of the front-end path segment to be compared and the back-end path segment to be compared are the same, fixed path corresponding data is formed. Based on the complete path corresponding data or the fixed path corresponding data, establish the correspondence between the front-end call feature data and the back-end interface feature data, record the correspondence, the front-end call feature data and the back-end interface feature data, and obtain the interface corresponding data.
5. The interface documentation generation method based on front-end and back-end code according to claim 1, characterized in that, Generate a sequence diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data, including: Read front-end call feature data, back-end interface feature data and their corresponding relationships from the interface corresponding data; read the front-end call path from the front-end call feature data; read the back-end interface path and interface method identifier from the back-end interface feature data; and read the call source, call target and call statement order associated with the interface method identifier from the back-end program call data. The front-end call participation items are determined based on the front-end call path, the back-end method participation items are determined based on the call source and the call target, the interface method participation items identified by the interface method identifier are determined from the back-end method participation items, and the back-end interface path is associated with the interface method participation items to form call participation item data; Using the front-end call participants as the source of the interface call and the interface method participants as the target of the interface call, interface call message data containing interface call messages is formed according to the correspondence; using the back-end method participants corresponding to the call source as the back-end call source and the back-end method participants corresponding to the call target as the back-end call target, back-end call message data containing back-end call messages is formed according to the order of the call statements. Establish a timeline lifeline based on the call participant data. For each correspondence, write the interface call message between the timeline lifeline corresponding to the interface call source and the interface call target according to the interface call message data. Write the backend call message between the timeline lifeline corresponding to the backend call source and the backend call target according to the order of the call statements to form timeline description data. Generate a timeline diagram based on the timeline description data. Using the call participants in the call participant data as topology nodes, a topology connection is established based on the call relationship between the interface call source and the interface call target, as well as the call relationship between the backend call source and the backend call target, forming topology description data, and a call relationship topology graph is generated based on the topology description data.
6. The method for generating interface documentation based on front-end and back-end code according to claim 1, characterized in that, An interface document is generated based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram. The interface document is stored according to the version identifier, and document index data is generated based on the interface document, including: Read the front-end call feature data and corresponding relationship from the interface corresponding data, and associate the front-end call feature data with the back-end interface feature data according to the corresponding relationship to form interface document item data; Read the front-end call path and front-end request method from the front-end call feature data, and read the back-end interface path, back-end request method, interface request parameter definition and interface response parameter definition from the back-end interface feature data. Based on the front-end call path, the front-end request method, the back-end interface path and the back-end request method, determine the interface timing image segment from the timing diagram, and determine the interface topology image segment from the call relationship topology diagram. Generate request example data based on the interface request parameter definition, generate response example data based on the interface response parameter definition, obtain a document template, and write the front-end call path, the front-end request method, the back-end interface path, the back-end request method, the interface request parameter definition, the interface response parameter definition, the request example data, the response example data, the interface timing image segment, and the interface topology image segment into the document template based on the interface document item data, thereby generating the interface document; Establish a version document storage directory based on the version identifier, write the interface document into the version document storage directory, and obtain the interface document storage location; The backend interface path and the backend request method are read from the interface document. Based on the version identifier, the backend interface path, the backend request method, and the interface document storage location, document index data is generated.
7. The method for generating interface documentation based on front-end and back-end code according to claim 1, characterized in that, After generating an interface document based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram, storing the interface document according to the version identifier, and generating document index data based on the interface document, the process further includes: Obtain the actual test data of the interface after the front-end code and the back-end code are deployed, and read the actual request path, actual request method, actual request data and actual response data from the interface test data. The actual request data and the actual response data come from the same interface interaction. Read backend interface feature data from the interface corresponding data, read backend interface path and backend request method from the backend interface feature data, read backend fixed path segments (excluding path parameter placeholders) from the backend interface path, read the measured fixed path segments corresponding to the positions of the backend fixed path segments from the measured request paths, compare the content and arrangement order of the backend fixed path segments and the measured fixed path segments, and compare the measured request method and the backend request method. When the path segment content, path segment arrangement order, and request method are all the same, determine the corresponding item of the target interface. Based on the corresponding item of the target interface, locate the target interface document item in the interface document, and locate the target document index item in the document index data; Update the request example data in the target interface document item to the actual request data, and update the response example data in the target interface document item to the actual response data to obtain the updated interface document; The updated interface document is overwritten with the updated interface document, the document update time is recorded, and the document update time is written into the target document index item to update the document index data.
8. An interface documentation generation device based on front-end and back-end code, characterized in that, The interface documentation generation device based on front-end and back-end code includes: The code acquisition module is used to obtain the front-end code repository address, the back-end code repository address, and the version identifier, and to obtain the front-end code and the back-end code based on the front-end code repository address, the back-end code repository address, and the version identifier; The feature parsing module is used to parse the front-end code and the back-end code to form front-end call feature data, back-end interface feature data and back-end program call data; The interface matching module is used to establish the correspondence between the front-end call feature data and the back-end interface feature data to obtain the interface corresponding data; The call graph generation module is used to generate a sequence diagram and a call relationship topology diagram based on the interface corresponding data and the backend program call data. The document management module is used to generate interface documents based on the backend interface feature data, the corresponding interface data, the timing diagram, and the call relationship topology diagram, store the interface documents according to the version identifier, and generate document index data based on the interface documents.
9. A computer device, characterized in that, The computer device includes a memory, a processor, and an interface documentation generation program based on front-end and back-end code stored in the memory and executable on the processor. When the interface documentation generation program based on front-end and back-end code is executed by the processor, it implements the steps of the interface documentation generation method based on front-end and back-end code as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores an interface documentation generation program based on front-end and back-end code. When the interface documentation generation program based on front-end and back-end code is executed by a processor, it implements the steps of the interface documentation generation method based on front-end and back-end code as described in any one of claims 1-7.
