Interface document generation method and device, computer equipment and storage medium

By generating the program structure interface model and extracting interface information based on the analytical priority of multiple annotations and comments, the problem of missing information during interface document generation in the prior art is solved, and a more complete and flexible interface document generation is achieved.

CN119987851APending Publication Date: 2025-05-13SHANGHAI SHUHE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411837336.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

When generating API interface documents, existing IDEA plug-ins usually only support single-way annotations, resulting in missing some or all interface information in the presence of multiple annotations and annotations.

Method used

Provide an interface document generation method, by downloading the project source code of the target project, analyzing the project source code to generate the program structure interface model, determining the entry and exit information of the application programming interface and annotation and annotation information, and analyzing the priority information based on the preset annotation and annotation and explanation, extracting the interface information, and finally generating the interface document.

Benefits of technology

Improve the integrity of the generated interface information, supports the development habits of different developers, and ensures that the interface document can fully contain all necessary information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987851A_ABST
    Figure CN119987851A_ABST
Patent Text Reader

Abstract

The invention relates to an interface document generation method and device, computer equipment and a storage medium. The method comprises the following steps: downloading a project source code of a target project; the project source code comprises a plurality of specified annotations and at least one specified annotation; parsing the project source code to generate a program structure interface model of grammar and semantic code; determining access parameter information and annotation information corresponding to the application programming interface according to the program structure interface model; the number of the application programming interfaces is multiple; extracting interface information corresponding to each application programming interface from the access parameter information and the annotation information corresponding to each application programming interface according to preset annotation analysis priority information; and generating an interface document according to the interface information corresponding to each application programming interface. The interface information integrity of the generated interface document can be improved so as to support the development habits of different developers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of interface document generation, and in particular to an interface document generation method, apparatus, computer equipment and storage medium. Background Art

[0002] With the rapid development of software development, API (Application Programming Interface) has become an indispensable part of modern software systems. The management of API interface documents is crucial for developers because they provide the information needed to interact with the API. The current development model generally adopts a synchronous development method with front-end and back-end separation. Before the API function is implemented, the back-end developer needs to give the API interface document used by the front-end to the front-end developer.

[0003] In the past, API interface documents were usually manually written and maintained by back-end developers, which was not only time-consuming and laborious, but also prone to errors. At present, some IDEA (Integrated Development Environment) plug-ins have the function of generating API interface documents, and these IDEA plug-ins can be used to automatically generate API interface documents, improve document writing efficiency and reduce error rate. However, the inventor has noticed that these IDEA plug-ins generally only support the interface information of API based on a single mode (such as Swagger 2.0 annotations or Swagger 3.0 annotations or Java doc annotations), and in some scenes, the development habits of different developers may be different, so the code may include multiple annotations and even multiple comments, and the API interface document generated using the above-mentioned IDEA plug-in may be missing some API's part or all of the interface information. Summary of the invention

[0004] In response to the above-mentioned deficiencies or shortcomings, the present application provides an interface document generation method, apparatus, computer device and storage medium. The embodiments of the present application can improve the interface information integrity of the generated interface document to support the development habits of different developers.

[0005] According to a first aspect, the present application provides a method for generating an interface document. In some embodiments, the method is implemented based on an IDEA plug-in; the method includes:

[0006] Download the project source code of the target project; the project source code includes multiple specified annotations and at least one specified comment;

[0007] Parse the project source code to generate a program structure interface model of the syntactic and semantic code;

[0008] Determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model; the number of application programming interfaces is multiple;

[0009] Extracting interface information corresponding to each application programming interface from input and output parameter information and annotation information corresponding to each application programming interface according to preset annotation parsing priority information;

[0010] Generate interface documents based on the interface information corresponding to each application programming interface.

[0011] In some embodiments, the multiple specified annotations include multiple ones of Bean Validation annotations, Swagger3.0 annotations, and Swagger2.0 annotations; at least one specified annotation includes standard Java Doc annotations and / or non-standard JavaDoc annotations; the annotation parsing priority information includes each specified annotation and the parsing priority corresponding to each specified annotation; the parsing priorities corresponding to each specified annotation are, from high to low, Bean Validation annotations, Swagger3.0 annotations, Swagger2.0 annotations, standard JavaDoc annotations, and non-standard Java Doc annotations.

[0012] In some embodiments, the project source code of the target project also includes the second-party dependent JAR package source code and the third-party dependent JAR package source code; downloading the project source code of the target project includes:

[0013] Download the second-party dependency JAR package source code and the third-party dependency JAR package source code through the Maven project management interface.

[0014] In some embodiments, determining the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model includes:

[0015] Determine the application programming interface in the program structure interface model based on the first-category annotations and the second-category annotations; the application programming interface is a PSI method with the second-category annotations and the corresponding PSI class with the first-category annotations; the second-category annotations include @GetMapping, @PostMapping, @PutMapping, @DeleteMapping and @PatchMapping; the first-category annotations include @RestController and @Controller;

[0016] Obtain the input and output parameter information and annotation information corresponding to each application programming interface from the program structure interface model.

[0017] In some embodiments, determining an application programming interface in a program structure interface model according to the first type of annotations and the second type of annotations includes:

[0018] Find all PSI classes in the program structure interface model;

[0019] Find the PSI class with the first type of annotation from all PSI classes;

[0020] A PSI method with a second type of annotation is searched for in a PSI class with a first type of annotation, and the found PSI method with the second type of annotation is used as an application programming interface.

[0021] In some embodiments, the annotation annotation information includes annotation information and annotation information; the method further comprises:

[0022] When obtaining the input and output parameter information and annotation information corresponding to each application programming interface from the program structure interface model, it is detected whether each application programming interface has corresponding annotation information;

[0023] If not, prompt the user whether to generate standard JavaDoc comments for the application programming interface that lacks comment information;

[0024] Under the user's instruction, the large language model is called to generate standard JavaDoc comments for the application programming interface that lacks annotation information;

[0025] Modify the program structure interface model based on the generated standard JavaDoc comments and refresh them into the project source code.

[0026] In some embodiments, the interface information corresponding to each application programming interface includes field information and attribute information of multiple interface fields; the interface information corresponding to each application programming interface is extracted from the input and output parameter information and the annotation information corresponding to each application programming interface according to preset annotation parsing priority information, including:

[0027] Determine the request input parameter field information and the response output parameter field information corresponding to each application programming interface based on the input and output parameter information corresponding to each application programming interface;

[0028] According to preset annotation parsing priority information, field information of other interface fields corresponding to each application programming interface and attribute information of all interface fields are determined from the annotation information corresponding to each application programming interface.

[0029] According to a second aspect, the present application provides an interface document generation device. In some embodiments, the device is implemented based on an IDEA plug-in; the device includes:

[0030] The source code download module is used to download the project source code of the target project; the project source code includes multiple specified annotations and at least one specified comment;

[0031] PSI model generation module, which is used to parse the project source code to generate the program structure interface model of the grammatical and semantic codes;

[0032] A basic information determination module is used to determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model; the number of the application programming interface is multiple;

[0033] The interface information determination module is used to extract the interface information corresponding to each application programming interface from the input and output parameter information and the annotation information corresponding to each application programming interface according to the preset annotation parsing priority information;

[0034] The interface document generation module is used to generate interface documents according to the interface information corresponding to each application programming interface.

[0035] According to a third aspect, the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the interface document generation method provided in any of the above embodiments are implemented.

[0036] According to a fourth aspect, the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the interface document generation method provided in any of the above embodiments are implemented.

[0037] In the above-mentioned embodiment of the present application, developers can use the IDEA plug-in to automatically generate an API interface document for a specified project. The IDEA plug-in will download the project source code of the target project, which includes multiple specified annotations and at least one specified comment, and then parse the project source code to generate a program structure interface model of syntax and semantic code, and then determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model, and extract the interface information corresponding to each application programming interface from the input and output parameter information and annotation information corresponding to each application programming interface according to the preset annotation parsing priority information, and finally generate an interface document according to the interface information corresponding to each application programming interface. The IDEA plug-in supports the generation of API interface documents based on multiple annotations and comments, and can extract the interface information of each application programming interface (API) as much as possible, improve the interface information integrity of the API interface document, and can support the development habits of different developers. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1A flowchart of a method for generating an interface document provided by the present application according to one or more embodiments;

[0039] Figure 2 A schematic diagram of a process for automatically completing annotation information provided by the present application according to one or more embodiments;

[0040] Figure 3 A structural block diagram of an interface document generating device provided by the present application according to one or more embodiments;

[0041] Figure 4 This is a diagram of the internal structure of a computer device provided by the present application according to one or more embodiments. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0043] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0044] In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0045] In view of the deficiencies or defects of the relevant technology, the present application provides an interface document generation method, which is implemented based on an IDEA plug-in, and developers can use the IDEA plug-in to automatically generate an API interface document for a specified project. Wherein, under the user's instruction, the IDEA plug-in will start the interface document generation process, first download the project source code of the target project, and then parse the project source code to generate a program structure interface model of syntax and semantic code, and then determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model, and extract the interface information corresponding to each application programming interface from the input and output parameter information and annotation information corresponding to each application programming interface according to the preset annotation parsing priority information, and finally generate an interface document according to the interface information corresponding to each application programming interface. The IDEA plug-in supports the generation of API interface documents based on multiple annotations and comments, and can extract more complete interface information of each application programming interface (API) from the project source code, improve the interface information integrity of the API interface document, and can support the development habits of different developers.

[0046] In some embodiments, the method includes Figure 1 The steps shown are steps S110 to S150. The steps of the method are described in detail below.

[0047] S110: Download the project source code of the target project.

[0048] The target project refers to the project specified by the user (such as a back-end developer). The API interface document of the project specifically includes the interface information of each application programming interface in the project, and the interface information corresponding to each application programming interface includes the field information and attribute information of multiple interface fields. Exemplarily, the interface fields of each application programming interface generally include a request method (Method), a request link (referring to a uniform resource locator), a request method name, a method detailed description, whether it is expired, a request input parameter, and a plurality of response output parameters. The request input parameter and the response output parameter can be nested complex types, and each interface field has its own attributes, such as type, description, whether it is required, regular constraints, maximum, minimum, default value, etc. The IDEA plug-in in the related art usually only determines the interface fields of the application programming interface in the project and the attribute information of the interface fields based on Swagger 2.0 annotations, or Swagger 3.0 annotations, or Java doc annotations, and the IDEA plug-in provided in this application can support multiple annotations and multiple comments, and use these annotations and annotations to determine the interface fields of the application programming interface and the attribute information of the interface fields.

[0049] The project source code includes multiple specified annotations and at least one specified comment. In some embodiments, the multiple specified annotations include multiple of Bean Validation annotations, Swagger 3.0 annotations, and Swagger 2.0 annotations; and at least one specified comment includes standard Java Doc annotations and / or non-standard Java Doc annotations.

[0050] In some embodiments, the project source code includes the source code of the target project itself, which contains all the files and resources required to complete a software project, such as source code files, resource files, library files, configuration files, etc. Usually the source code of the project is packaged into a JAR package. The JAR (Java Archive) package is a packaging method for packaging Java class files, related metadata and resources (such as text, pictures, etc.) into a single file. The JAR package usually contains class files (.class files, bytecode files compiled from Java source code), resource files (such as configuration files, pictures, localization files, etc.), and manifest files (META-INF / MANIFEST.MF, containing metadata of the JAR file, such as the main class name, version information, etc.) and other data.

[0051] In some embodiments, in addition to the source code of the target project itself, the project source code of the target project also includes the second-party dependent JAR package source code and the third-party dependent JAR package source code. Accordingly, downloading the project source code of the target project includes: downloading the second-party dependent JAR package source code and the third-party dependent JAR package source code through the Maven project management interface.

[0052] Specifically, the IDEA plug-in can call the API of MavenProjectsManager in IntelliJ Platform to refresh the second-party and third-party JAR package source codes that Maven projects depend on. IntelliJ Platform is an integrated development environment (IDE) software suite developed by JetBrains.

[0053] Introducing JAR packages in software development is a common practice, which can help developers improve efficiency, reduce costs, improve software quality, and quickly integrate various services and functions. JAR packages can be divided into second-party libraries and third-party libraries according to their source and purpose. Second-party libraries refer to dependency libraries within a company (or unit, organization, etc.), which are usually JAR packages released by other projects within the company. These libraries are mainly used for dependencies between different projects within the company, for example, the core dependency packages of the company's project platform. Third-party libraries refer to JAR packages contributed by external open source libraries or open source projects, usually provided by other companies or organizations. The source code of the second-party (or third-party) dependent JAR package refers to the source code in the second-party (or third-party) dependent JAR package.

[0054] The source code of the second-party dependent JAR package and the third-party dependent JAR package may include some annotation information related to the application programming interface (such as Java Doc comments). Therefore, when downloading the project source code, triggering the download of the second-party dependent JAR package source code and the third-party dependent JAR package source code can enrich the basic information of the application programming interface (the interface information of the application programming interface will be extracted from these basic information later), which helps to improve the interface information integrity of the API interface document. Specifically, Java annotations can exist at different stages of the code (compile time, class loading time, runtime), mainly depending on how the annotations are defined. Swagger annotations usually exist at the runtime stage, so there will generally be Swagger annotations in the JAR. When generating interface documents, these Swagger annotations can be used to determine some properties of some interface fields of the relevant application programming interface, such as parameter descriptions. However, Swagger annotations are not mandatory, that is, they are not required by the code. Developers may not write Swagger annotations when writing code, so there will be no Swagger annotations in the JAR package. In this case, some attributes of some interface fields cannot be determined. If there is Java Doc and other annotation information related to the application programming interface, these annotation information can be combined to complete some attributes of some interface fields, so that the interface information of each application programming interface in the final generated interface document is more complete. For example, the code of a general third-party JAR will not write Swagger annotations, but common third-party JARs have Java Doc annotations. Therefore, these JavaDoc annotations can be used to determine some attributes of some interface fields of some application programming interfaces in the third-party JAR.

[0055] S120: Parse the project source code to generate a program structure interface model of syntax and semantic codes.

[0056] The Program Structure Interface model refers to the PSI (Program Structure Interface) model. The PSI model is a syntax tree containing the structure of the code. The PSI model contains many characteristic nodes, each of which is a PSI element, and each node contains its own child nodes, for example, the PsiClass element also contains some PsiMethod methods. The plug-in can use the infrastructure capabilities of the IntelliJ Platform itself to generate a PSI model of syntax and semantic code.

[0057] S130: Determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model.

[0058] There are multiple application programming interfaces. When programming, annotations are usually added to both the class and the method to represent an application programming interface. Therefore, the application programming interface is specifically a PSI method (i.e., PsiMethod) with the second-class annotations in the program structure interface model and the corresponding PSI class (i.e., PsiClass) with the first-class annotations. The first-class annotations include @RestController and @Controller. @RestController and @Controller are annotations used in the Spring framework to create controllers for Web applications. The @Controller annotation is used to define a Spring MVC controller, which is responsible for processing the user's HTTP request and returning the view name. The @RestController annotation is a combination of the @Controller and @ResponseBody annotations, which can be used to create a controller that returns a response body (i.e., the return value of the method). The second-class annotation refers to the annotation corresponding to the request method. If the protocol used by the application layer is HTTP (Hypertext Transfer Protocol), the second-class annotation can be @xxxMapping. @xxxMapping is a proxy, not a real annotation. For example, HTTP request methods include GET, POST, PUT, DELETE, PATCH, etc. The corresponding annotations for each request method are @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping, etc. For example, a PSI class is annotated with @Controller, and there are two PSI methods under the PSI class, one of which is annotated with @PostMapping and the other is not annotated. Then the PSI method annotated with @PostMapping is an application programming interface, while the PSI method without annotation is not an application programming interface.

[0059] The operations of determining the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model may include:

[0060] (1) Determine the application programming interface in the program structure interface model based on the first type of annotations and the second type of annotations. In this case, all PSI classes can be searched in the program structure interface model, and then PSI classes with the first type of annotations can be searched from all PSI classes; finally, PSI methods with the second type of annotations can be searched in the PSI classes with the first type of annotations, and the found PSI methods with the second type of annotations can be used as the application programming interface.

[0061] The SDK (Software Development Kit) provided by IDEA encapsulates methods for PSI search, such as psiClass.getSuperClass(), psiClass.getInterfaces(), etc. The plug-in can call these methods to find PSI classes and PSI methods.

[0062] (2) Obtain the input and output parameter information and annotation information corresponding to each application programming interface from the program structure interface model.

[0063] After finding the PSI methods with the second type of annotations and the corresponding PSI classes with the first type of annotations, the input and output parameter information and annotation comment information in the child nodes under these PSI methods are obtained.

[0064] The input and output parameter information includes interface fields such as request input parameter and response output parameter. The annotation information includes annotation information and comment information.

[0065] In some embodiments, Figure 2 As shown, the method also includes:

[0066] S210: When obtaining the input and output parameter information and annotation information corresponding to each application programming interface from the program structure interface model, detecting whether each application programming interface has corresponding annotation information;

[0067] S220: If not, prompt the user whether to generate standard JavaDoc comments for the application programming interface that lacks comment information;

[0068] S230: under the instruction of the user, calling the large language model to generate standard Java Doc comments for the application programming interface that lacks comment information;

[0069] S240: Modify the program structure interface model based on the generated standard Java Doc comments and refresh it into the project source code.

[0070] In some cases, some application programming interfaces may not have corresponding annotation information. In order to obtain more complete interface information of the application programming interface, a large language model (which may be a large language model already available on the market) may be used to generate annotation information.

[0071] It is possible to first detect whether each application programming interface found has corresponding annotation information. If not all application programming interfaces have corresponding annotation information, the application programming interfaces that lack annotation information are screened out. After that, it is possible to confirm with the user whether it is necessary to generate annotation information for the application programming interfaces that lack annotation information. In response to the confirmation instruction fed back by the user, the relevant source code of the interface is included in the prompt word (prompt) and input into the large language model, indicating the large language model to generate annotation information for the application programming interface that lacks annotation information based on the source code. The annotation information generated by the large language model is standard Java Doc annotation information. Among them, the Java Doc annotation information generated by the large language model must be correct, but the semantics may not completely conform to the current parameters. Therefore, in order to improve the accuracy of the interface information, the annotation information generated by the large language model for the application programming interface that lacks annotation information can be presented through a visual operation interface. The user can confirm or modify the annotation information through the interface, and the plug-in will obtain the annotation information fed back by the user through the interface. If the user does not modify it, the original annotation information generated by the large language model is obtained, and if the user modifies the annotation information, the user's modified annotation information is obtained. Finally, the API provided by the PSI model for adding new PSI elements can be called to add the obtained annotation information to the PSI model, and the added annotation information can be updated to the project source code.

[0072] This embodiment integrates artificial intelligence technology to automatically complete annotation information for application programming interfaces that are missing annotations, thereby improving the quality and completeness of interface documents.

[0073] S140: extracting interface information corresponding to each application programming interface from the input and output parameter information and the annotation information corresponding to each application programming interface according to preset annotation parsing priority information.

[0074] The interface document generally contains fields such as request method, request link (URL), request method name, method detailed description, expiration, request input parameter, response output parameter, etc. Request input parameter and response output parameter may be a nested complex type, so each parameter in the request input parameter and response output parameter usually corresponds to multiple attributes, such as type, description, required or not, regular constraint, maximum, minimum, default value, etc. The IDEA plug-in can obtain Bean Validation annotations, Swagger3.0 annotations, Swagger2.0 annotations, standard Java Doc annotations, and some non-standard Java annotations in the PSI model, and then obtain them from the above annotations and comments when obtaining the interface information of each application programming interface.

[0075] This embodiment fully supports the extraction and processing of multiple annotations, including but not limited to BeanValidation annotations, Swagger3.0 annotations, Swagger2.0 annotations and standard JavaDoc annotations, and can even be compatible with some non-standard JavaDoc annotations, thereby improving the information integrity of the interface document and supporting the development habits of different developers.

[0076] The interface information corresponding to each application programming interface includes field information and attribute information of multiple interface fields;

[0077] In some embodiments, interface information corresponding to each application programming interface is extracted from the input and output parameter information and annotation comment information corresponding to each application programming interface according to preset annotation comment parsing priority information, including: determining the request input parameter field information and response output parameter field information corresponding to each application programming interface based on the input and output parameter information corresponding to each application programming interface; determining the field information of other interface fields corresponding to each application programming interface and the attribute information of all interface fields from the annotation comment information corresponding to each application programming interface according to preset annotation comment parsing priority information.

[0078] The annotation parsing priority information includes each specified annotation and the parsing priority corresponding to each specified annotation. When obtaining the interface information of each application programming interface from the above annotations and comments, the IDEA plug-in can implement multi-level annotation parsing through the annotation parsing priority information, thereby improving the accuracy of the attribute information of the interface field.

[0079] The parsing priority of each annotation or comment can be determined based on the effectiveness and accuracy of the annotation or comment in actual use. For example, Swagger annotations (including Swagger2.0 and Swagger3.0) and Java Doc annotations are only descriptive annotations or comments and do not affect the operation of the program, while Bean Validation annotations are actually used and verified during operation, so the information of such annotations is more accurate and has a higher priority.

[0080] In some embodiments, the parsing priorities of the designated annotations and the designated comments are, from high to low, Bean Validation annotations, Swagger 3.0 annotations, Swagger 2.0 annotations, standard JavaDoc annotations, and non-standard JavaDoc annotations.

[0081] For each application programming interface, the IDEA plug-in first searches for the attribute information of each interface field of the application programming interface from the Bean Validation annotation. If the attribute information of any interface field is not found, it searches for its corresponding attribute information from the Swagger3.0 annotation. If there is still interface field attribute information that is not found, it searches for its corresponding attribute information from the Swagger2.0 annotation. If there is still interface field attribute information that is not found, it searches for its corresponding attribute information from the standard JavaDoc annotation. If there is still interface field attribute information that is not found, it searches for its corresponding attribute information from the non-standard JavaDoc annotation.

[0082] S150: Generate an interface document according to the interface information corresponding to each application programming interface.

[0083] After obtaining the interface information corresponding to each application programming interface, a document generation tool can be used to generate the interface document.

[0084] Among them, standard document templates and formats can be pre-established, and used to generate interface documents for various projects of the company to ensure the consistency and maintainability of the interface documents.

[0085] In some embodiments, the Java Swing development window can be used in the IDEA plug-in to display document content and control the function of displaying content. After the developer has written the code in the integrated development environment, the application programming interface that needs to be previewed can be clicked in the operation interface. At this time, the back end will parse the PSI model of the source code of the relevant project and then render the display window. When the code written by the developer changes, the PSI model will be adjusted together. By providing a real-time preview window in the integrated development environment (IDE, Integrated Development Environment), the developer can instantly view the generated interface document effect to ensure that the document is synchronized with the code.

[0086] In some embodiments, after generating the interface document according to the interface information corresponding to each application programming interface, the method further includes: uploading the interface document to a designated server. After the code of the target project is launched, the designated server merges the Swagger interface document generated by Jenkins using the Swagger plug-in with the interface document.

[0087] When the target project code is released, it will also be integrated into the CI / CD process. When using Jenkins to compile and build, other Maven-related Swagger plug-ins generate Swagger interface documents for the released code, but the interface information of some application programming interfaces in these interface documents may be incomplete. Therefore, these Swagger interface documents are merged with the interface documents previously uploaded by the IDEA plug-in to improve the information integrity of these Swagger interface documents.

[0088] It should be noted that, with respect to the various steps included in the interface document generation method provided in any of the above embodiments, unless otherwise clearly stated in this document, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of these steps may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0089] Based on the same inventive concept, the present application also provides an interface document generation device. In some embodiments, Figure 3 As shown, the interface document generation device is implemented based on the IDEA plug-in, and the device includes the following modules:

[0090] The source code download module 110 is used to download the project source code of the target project; the project source code includes multiple specified annotations and at least one specified comment;

[0091] A PSI model generation module 120, for parsing the project source code to generate a program structure interface model of syntax and semantic code;

[0092] The basic information determination module 130 is used to determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model; the number of the application programming interface is multiple;

[0093] The interface information determination module 140 is used to extract the interface information corresponding to each application programming interface from the input and output parameter information and the annotation information corresponding to each application programming interface according to the preset annotation parsing priority information;

[0094] The interface document generation module 150 is used to generate an interface document according to the interface information corresponding to each application programming interface.

[0095] In some embodiments, the multiple specified annotations include multiple ones of Bean Validation annotations, Swagger3.0 annotations, and Swagger2.0 annotations; at least one specified annotation includes standard Java Doc annotations and / or non-standard JavaDoc annotations; the annotation parsing priority information includes each specified annotation and the parsing priority corresponding to each specified annotation; the parsing priorities corresponding to each specified annotation are, from high to low, Bean Validation annotations, Swagger3.0 annotations, Swagger2.0 annotations, standard JavaDoc annotations, and non-standard Java Doc annotations.

[0096] In some embodiments, the project source code of the target project also includes the second-party dependent JAR package source code and the third-party dependent JAR package source code; the source code download module 110 includes:

[0097] The second-party and third-party source code ordering submodule is used to download the second-party dependency JAR package source code and the third-party dependency JAR package source code through the Maven project management interface.

[0098] In some embodiments, the basic information determination module 130 includes:

[0099] The interface determination submodule is used to determine the application programming interface in the program structure interface model according to the first-class annotations and the second-class annotations; the application programming interface is a PSI method with the second-class annotations and the corresponding PSI class with the first-class annotations; the second-class annotations include @GetMapping, @PostMapping, @PutMapping, @DeleteMapping and @PatchMapping; the first-class annotations include @RestController and @Controller;

[0100] The information acquisition submodule is used to obtain the input and output parameter information and annotation information corresponding to each application programming interface from the program structure interface model.

[0101] In some embodiments, the interface determination submodule includes:

[0102] A first search unit is used to search all PSI classes in the program structure interface model;

[0103] A second search unit is used to search for a PSI class with a first type of annotation from all PSI classes;

[0104] The third search unit searches for a PSI method with a second type of annotation in a PSI class with a first type of annotation, and uses the found PSI method with the second type of annotation as an application programming interface.

[0105] In some embodiments, the annotation information includes annotation information and annotation information; the apparatus further comprises:

[0106] A detection module, used to detect whether each application programming interface has corresponding annotation information when obtaining the input and output parameter information and annotation information corresponding to each application programming interface from the program structure interface model;

[0107] A prompt module, used for prompting a user whether to generate a standard JavaDoc comment for the application programming interface with missing comment information when it is determined that each application programming interface does not have corresponding comment information;

[0108] An annotation generation module, used for invoking a large language model to generate standard JavaDoc comments for an application programming interface lacking annotation information under the instruction of a user;

[0109] The code refresh module is used to modify the program structure interface model based on the generated standard JavaDoc comments and refresh it into the project source code.

[0110] In some embodiments, the interface information corresponding to each application programming interface includes field information and attribute information of multiple interface fields; the interface information determination module 140 includes:

[0111] A first information determination submodule, used to determine the request input parameter field information and the response output parameter field information corresponding to each application programming interface based on the input and output parameter information corresponding to each application programming interface;

[0112] The second information determination submodule is used to determine the field information of other interface fields corresponding to each application programming interface and the attribute information of all interface fields from the annotation information corresponding to each application programming interface according to preset annotation parsing priority information.

[0113] For the specific definition of the interface document generation device, please refer to the definition of the interface document generation method above, which will not be repeated here. Each module in the above-mentioned interface document generation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0114] The present application also provides a computer device. In some embodiments, the computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the clinical efficacy characteristic enhancement method provided in any of the above embodiments can be implemented.

[0115] Furthermore, in some embodiments, the internal structure diagram of the computer device may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as project source code, annotation parsing priority information, etc. The specific stored data can also be found in the definitions in the above method embodiments. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an interface document generation method is implemented.

[0116] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0117] The present application also provides a computer-readable storage medium. In some embodiments, a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the steps of the interface document generation method provided in any of the above embodiments are implemented.

[0118] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0119] Those skilled in the art can understand that all or part of the processes in the above method embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to memory, storage, database 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. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink), DRAM (SLDRAM), memory bus (Rambus), direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0120] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0121] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for generating an interface document, characterized in that: The method is implemented based on an IDEA plug-in; the method includes: Downloading a project source code of a target project; the project source code includes a plurality of specified annotations and at least one specified comment; Parsing the project source code to generate a program structure interface model of syntax and semantic code; Determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model; the number of the application programming interface is multiple; Extracting interface information corresponding to each of the application programming interfaces from the input and output parameter information and the annotation information corresponding to each of the application programming interfaces according to preset annotation parsing priority information; An interface document is generated according to the interface information corresponding to each of the application programming interfaces.

2. The method according to claim 1, characterized in that The multiple specified annotations include multiple ones of Bean Validation annotations, Swagger3.0 annotations, and Swagger2.0 annotations; the at least one specified annotation includes standard Java Doc annotations and / or non-standard Java Doc annotations; The annotation parsing priority information includes each of the specified annotations and the parsing priority corresponding to each of the specified annotations; the parsing priorities corresponding to each of the specified annotations and each of the specified annotations are, from high to low, BeanValidation annotation, Swagger3.0 annotation, Swagger2.0 annotation, standard JavaDoc annotation, and non-standard Java Doc annotation.

3. The method according to claim 1, characterized in that The project source code of the target project also includes the second-party dependent JAR package source code and the third-party dependent JAR package source code; Download the project source code of the target project, including: The second-party dependent JAR package source code and the third-party dependent JAR package source code are downloaded through the Maven project management interface.

4. The method according to claim 1, characterized in that Determining input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model includes: Determine an application programming interface in the program structure interface model according to the first type of annotations and the second type of annotations; the application programming interface is a PSI method with the second type of annotations and the corresponding PSI class with the first type of annotations; the second type of annotations include @GetMapping, @PostMapping, @PutMapping, @DeleteMapping and @PatchMapping; the first type of annotations include @RestController and @Controller; The input and output parameter information and annotation information corresponding to each of the application programming interfaces are obtained from the program structure interface model.

5. The method according to claim 4, characterized in that Determining the application programming interface in the program structure interface model according to the first type of annotations and the second type of annotations includes: Find all PSI classes in the program structure interface model; Find the PSI class with the first type of annotation from all the PSI classes; The PSI method with the second type of annotation is searched in the PSI class with the first type of annotation, and the found PSI method with the second type of annotation is used as an application programming interface.

6. The method according to claim 4, characterized in that The annotation information includes annotation information and comment information; the method further includes: When obtaining the input and output parameter information and annotation information corresponding to each of the application programming interfaces from the program structure interface model, detecting whether each of the application programming interfaces has corresponding annotation information; If not, prompt the user whether to generate standard JavaDoc comments for the application programming interface that lacks comment information; Under the user's instruction, the large language model is called to generate standard JavaDoc comments for the application programming interface that lacks annotation information; The program structure interface model is modified based on the generated standard JavaDoc comments and refreshed into the project source code.

7. The method according to claim 1, characterized in that The interface information corresponding to each of the application programming interfaces includes field information and attribute information of a plurality of interface fields; Extracting interface information corresponding to each application programming interface from the input and output parameter information and the annotation information corresponding to each application programming interface according to the preset annotation parsing priority information, including: Determine the request input parameter field information and the response output parameter field information corresponding to each of the application programming interfaces based on the input and output parameter information corresponding to each of the application programming interfaces; According to preset annotation parsing priority information, field information of other interface fields corresponding to each of the application programming interfaces and attribute information of all interface fields are determined from the annotation information corresponding to each of the application programming interfaces.

8. An interface document generating device, characterized in that: The device is implemented based on an IDEA plug-in; the device includes: A source code download module, used to download the project source code of the target project; the project source code includes multiple specified annotations and at least one specified comment; A PSI model generation module, used for parsing the project source code to generate a program structure interface model of syntax and semantic code; A basic information determination module, used to determine the input and output parameter information and annotation information corresponding to the application programming interface according to the program structure interface model; the number of the application programming interface is multiple; An interface information determination module, used to extract interface information corresponding to each of the application programming interfaces from the input and output parameter information and the annotation information corresponding to each of the application programming interfaces according to preset annotation parsing priority information; The interface document generation module is used to generate an interface document according to the interface information corresponding to each of the application programming interfaces.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.