A method and device for automatically generating typescript type definition files from interface documents
By automatically generating TypeScript type definition files, the problem of manually writing interface documents being tedious and error-prone is solved, which improves development efficiency and accuracy and reduces costs.
Patent Information
- Application Number
- CN202210848839.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-19
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2042-07-19
AI Technical Summary
In front-end development, manually writing typescript type definition files for interface documents is tedious and error-prone, affecting development efficiency and accuracy.
Use preset plug-ins to automatically obtain interface documents, determine the names and types of request and return fields, and automatically generate typescript type definition files.
It improves the generation efficiency of TypeScript type definition files, reduces the error rate of manual input, and reduces the cost of software system development.
Smart Images

Figure CN115220784B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method and device for automatically generating a TypeScript type definition file from an interface document. Background Art
[0002] Currently, Typescript is used more and more widely in front-end development. As we all know, JavaScript is weakly typed, and many errors will only be discovered at runtime. Typescript is strongly typed and provides a set of static detection mechanisms. If the developer changes the type of the variable during the coding process, Typescript will report an error, helping us to detect errors in time. Especially in large projects, Typescript is the standard configuration for the front-end.
[0003] In order to fully utilize TypeScript's type capabilities to standardize the field types of the interface provided by the backend to the frontend, we usually write the type definition of the frontend code interface according to the interface documentation. In the actual development process, each interface may have a large number of fields. At this time, it has to be said that porting type definitions according to the interface documentation is very tedious, not to mention the possibility of errors during the porting process. Therefore, it is urgent to provide a method to automatically generate TypeScript type definition files from interface documents. Summary of the Invention
[0004] The present application provides a method and apparatus for automatically generating a TypeScript type definition file from an interface document, aiming to realize automatic generation of a TypeScript type definition file from an interface document, improve code development efficiency, and reduce the error rate caused by manual input.
[0005] In a first aspect, the present application provides a method for automatically generating a TypeScript type definition file from an interface document, comprising:
[0006] Use the preset plug-in to obtain the interface document of the current page;
[0007] Determine the request field and the return field respectively according to the interface document;
[0008] According to the source program type of the interface document, respectively obtain the field name and field type corresponding to the request field and the return field;
[0009] Automatically generate a typescript type definition file corresponding to the target program code according to the field names and field types corresponding to the request field and the return field respectively.
[0010] Optionally, the method of using a preset plug-in to obtain the interface document of the current page specifically includes:
[0011] After receiving the interface document generation request, call the implementation class of the ApplicationRunner interface of the interface document generation plug-in;
[0012] The interface document generation plug-in scans all classes ending with Controller or annotated with @RestController in the source code of the application system, and obtains the annotations of the class as the prefix of the interface access URL;
[0013] The interface document generation plug-in scans all methods of the class, obtains the value of the @RequestMapping annotation in the method as the suffix of the interface access URL, and obtains the MethodType in the @RequestMapping annotation as the method access type;
[0014] The interface document generation plug-in scans the @param annotations of all methods of the class, obtains the content of the @param annotations as interface input parameters, and then separates the input name, Chinese name, type, whether it is required, and remarks in the interface input parameters with vertical bars;
[0015] The interface document generation plug-in scans the @return annotations of all methods of the class and determines whether the @return annotation is scanned. If so, the @return annotation is obtained as the interface output parameter of the interface document generation plug-in. Otherwise, the interface document generation plug-in uses reflection to obtain the return object of the method and parses the annotations of the return object attributes, and obtains the parsed annotations as the interface output parameter of the interface document generation plug-in;
[0016] The interface document generation plug-in stores data in a local cache according to different interface categories, wherein the data includes the prefix of the interface access URL, the suffix of the interface access URL, the type of method access, interface output parameters, and interface output parameters;
[0017] The interface document generation plug-in receives the access instruction of the interface access URL and then obtains the corresponding interface content from the local cache and assembles it as an interface document.
[0018] Optionally, the automatically generating a typescript type definition file corresponding to the target program code according to the field names and field types corresponding to the request field and the return field, specifically includes:
[0019] Input the field name and field type corresponding to the request field and the return field, parse different interface documents, and output type scalars;
[0020] Determine whether the input interface document language is a basic type. If so, add its type scalar, type name, and type value to the type queue to be output. Otherwise, proceed to the next step.
[0021] Generate a new type, count all new types, and add properties of the upward connected type;
[0022] Merge all types in the type team to be output and add them to the output type queue, add non-empty attribute identifiers to the types and their corresponding fields, and output the final converted typescript type definition file.
[0023] Optionally, the output is a typescript type definition file after final conversion, specifically:
[0024] Obtaining a preset template corresponding to the target program code;
[0025] Determine the hierarchical relationships between all fields and all subfields;
[0026] The field name and field type of the field, as well as the field name and field type of the subfield corresponding to the field, are imported into the preset template according to the hierarchical relationship to generate a converted typescript type definition file.
[0027] In a second aspect, the present application provides a device for automatically generating a TypeScript type definition file from an interface document, comprising:
[0028] The acquisition module is used to obtain the interface document of the current page using the preset plug-in;
[0029] A determination module, configured to determine the request field and the return field respectively according to the interface document;
[0030] A processing module, configured to obtain, according to a source program type of the interface document, the field names and field types corresponding to the request field and the return field respectively;
[0031] A generation module is used to automatically generate a typescript type definition file corresponding to the target program code according to the field names and field types corresponding to the request field and the return field respectively.
[0032] Optionally, the acquisition module is specifically configured to:
[0033] After receiving the interface document generation request, call the implementation class of the ApplicationRunner interface of the interface document generation plug-in;
[0034] The interface document generation plug-in scans all classes ending with Controller or annotated with @RestController in the source code of the application system, and obtains the annotations of the class as the prefix of the interface access URL;
[0035] The interface document generation plug-in scans all methods of the class, obtains the value of the @RequestMapping annotation in the method as the suffix of the interface access URL, and obtains the MethodType in the @RequestMapping annotation as the method access type;
[0036] The interface document generation plug-in scans the @param annotations of all methods of the class, obtains the content of the @param annotations as interface input parameters, and then separates the input name, Chinese name, type, whether it is required, and remarks in the interface input parameters with vertical bars;
[0037] The interface document generation plug-in scans the @return annotations of all methods of the class and determines whether the @return annotation is scanned. If so, the @return annotation is obtained as the interface output parameter of the interface document generation plug-in. Otherwise, the interface document generation plug-in uses reflection to obtain the return object of the method and parses the annotations of the return object attributes, and obtains the parsed annotations as the interface output parameter of the interface document generation plug-in;
[0038] The interface document generation plug-in stores data in a local cache according to different interface categories, wherein the data includes the prefix of the interface access URL, the suffix of the interface access URL, the type of method access, interface output parameters, and interface output parameters;
[0039] The interface document generation plug-in receives the access instruction of the interface access URL and then obtains the corresponding interface content from the local cache and assembles it as an interface document.
[0040] Optionally, the generating module is specifically configured to:
[0041] Input the field name and field type corresponding to the request field and the return field, parse different interface documents, and output type scalars;
[0042] Determine whether the input interface document language is a basic type. If so, add its type scalar, type name, and type value to the type queue to be output. Otherwise, proceed to the next step.
[0043] Generate a new type, count all new types, and add properties of the upward connected type;
[0044] Merge all types in the type team to be output and add them to the output type queue, add non-empty attribute identifiers to the types and their corresponding fields, and output the final converted typescript type definition file.
[0045] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0046] The memory stores computer-executable instructions;
[0047] The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect above.
[0048] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect above.
[0049] In a fifth aspect, the present application provides a computer program product, comprising a computer program, which implements the method described in the first aspect when executed by a processor.
[0050] The present application provides a method and device for automatically generating a TypeScript type definition file from an interface document, which uses a preset plug-in to obtain the interface document of the current page; determines the request field and the return field respectively according to the interface document; obtains the field name and field type corresponding to the request field and the return field respectively according to the source program type of the interface document; and automatically generates a TypeScript type definition file corresponding to the target program code according to the field name and field type corresponding to the request field and the return field. This can avoid the phenomenon of users manually writing TypeScript type definition files for interface documents, thereby not only improving the efficiency of TypeScript type definition file generation, but also reducing the cost of software system development. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0052] Figure 1A flowchart of a method for automatically generating a TypeScript type definition file from an interface document provided by an exemplary embodiment of the present application;
[0053] Figure 2 A schematic diagram of a device for automatically generating a TypeScript type definition file from an interface document provided by another exemplary embodiment of the present application;
[0054] Figure 3 A schematic structural diagram of an electronic device provided as another exemplary embodiment of the present application.
[0055] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0056] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0057] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0058] Figure 1 A flowchart of a method for automatically generating a typescript type definition file from an interface document provided by an exemplary embodiment of the present application. Figure 1 As shown, the specific steps of a method for automatically generating a TypeScript type definition file from an interface document provided by an embodiment of the present invention are as follows:
[0059] Step S101: Use a preset plug-in to obtain the interface document of the current page.
[0060] Specifically, after receiving the interface document generation request, the implementation class of the ApplicationRunner interface of the interface document generation plug-in is called;
[0061] The interface document generation plug-in scans all classes ending with Controller or annotated with @RestController in the source code of the application system, and obtains the annotations of the class as the prefix of the interface access URL;
[0062] The interface document generation plug-in scans all methods of the class, obtains the value of the @RequestMapping annotation in the method as the suffix of the interface access URL, and obtains the MethodType in the @RequestMapping annotation as the method access type;
[0063] The interface document generation plug-in scans the @param annotations of all methods of the class, obtains the content of the @param annotations as interface input parameters, and then separates the input name, Chinese name, type, whether it is required, and remarks in the interface input parameters with vertical bars;
[0064] The interface document generation plug-in scans the @return annotations of all methods of the class and determines whether the @return annotation is scanned. If so, the @return annotation is obtained as the interface output parameter of the interface document generation plug-in. Otherwise, the interface document generation plug-in uses reflection to obtain the return object of the method and parses the annotations of the return object attributes, and obtains the parsed annotations as the interface output parameter of the interface document generation plug-in;
[0065] The interface document generation plug-in stores data in a local cache according to different interface categories, wherein the data includes the prefix of the interface access URL, the suffix of the interface access URL, the type of method access, interface output parameters, and interface output parameters;
[0066] The interface document generation plug-in receives the access instruction of the interface access URL and then obtains the corresponding interface content from the local cache and assembles it as an interface document.
[0067] Step S102: Determine the request field and the return field respectively according to the interface document.
[0068] Exemplarily, when determining the request field, multiple classes in the target program code can be obtained. For each class, if the code annotation corresponding to the class includes annotation information identified by the first identifier, and the class is determined to be a request class based on the annotation information identified by the first identifier, then the field in the request class is determined as the request field.
[0069] Step S103: According to the source program type of the interface document, the field names and field types corresponding to the request field and the return field are respectively obtained.
[0070] For any class, all of its properties and methods can be determined, and for any object, any method and property of that object can be called. Therefore, after determining the request and return fields, the terminal device can obtain the corresponding field names and field types of the request and return fields.
[0071] Step S104: automatically generating a typescript type definition file corresponding to the target program code according to the field names and field types corresponding to the request field and the return field.
[0072] Specifically, input the field name and field type corresponding to the request field and the return field, parse different interface documents, and output type scalars; determine whether the input interface document language is a basic type, if so, add its type scalar, type name and type value to the type queue to be output, otherwise proceed to the next step; generate a new type, count all new types, and add properties of upward connected types; merge all types in the type team to be output, and add them to the output type queue, add non-empty attribute identifiers to the types and their corresponding fields, and output the final converted typescript type definition file.
[0073] Parse different interface documents and output interface type scalars, which are used to map and convert interface document types to basic types of TypeScript. The basic type content of TypeScript includes: interface name and its corresponding interface type, and interface type field.
[0074] Furthermore, a preset template corresponding to the target program code is obtained; the hierarchical relationship between all fields and all subfields is determined; the field name and field type of the field, as well as the field name and field type of the subfield corresponding to the field, are imported into the preset template according to the hierarchical relationship to generate a converted typescript type definition file.
[0075] In this embodiment, by obtaining the interface document corresponding to the target program code and importing the interface document into the preset template, not only can the interface document be made more complete, but the interface documents of different interfaces can also be effectively distinguished, which is convenient for developers to use and improves the user experience. In addition, the preset template also includes relevant information about the request field and relevant information about the return field. Therefore, after determining the field name and field type corresponding to the request field and the return field, the terminal device can import the field name and field type corresponding to the request field and the return field into the preset template, thereby generating a typescript type definition file for the interface document.
[0076] Exemplarily, when generating a TypeScript type definition file for an interface document corresponding to a target program code, a preset template corresponding to the target program code can be obtained, and the hierarchical correspondence between all fields and all subfields can be determined. Then, the field name and field type of the field, as well as the field name and field type of the subfield corresponding to the field, can be imported into the preset template according to the hierarchical correspondence to generate a TypeScript type definition file for the interface document.
[0077] The present application provides a method and device for automatically generating a TypeScript type definition file from an interface document, which uses a preset plug-in to obtain the interface document of the current page; determines the request field and the return field respectively according to the interface document; obtains the field name and field type corresponding to the request field and the return field respectively according to the source program type of the interface document; and automatically generates a TypeScript type definition file corresponding to the target program code according to the field name and field type corresponding to the request field and the return field. This can avoid the phenomenon of users manually writing TypeScript type definition files for interface documents, thereby not only improving the efficiency of TypeScript type definition file generation, but also reducing the cost of software system development.
[0078] Figure 2 A schematic diagram of the structure of a device for automatically generating a typescript type definition file from an interface document provided by an exemplary embodiment of the present application. The device for automatically generating a typescript type definition file from an interface document provided by an embodiment of the present application can execute the processing flow provided by a method embodiment for automatically generating a typescript type definition file from an interface document. Figure 2 As shown, the present application provides an apparatus 20 for automatically generating a TypeScript type definition file from an interface document, comprising:
[0079] The acquisition module 201 is used to obtain the interface document of the current page using a preset plug-in;
[0080] Determining module 202, configured to determine the request field and the return field respectively according to the interface document;
[0081] Processing module 203, configured to obtain the field names and field types corresponding to the request field and the return field, respectively, according to the source program type of the interface document;
[0082] The generation module 204 is configured to automatically generate a typescript type definition file corresponding to the target program code according to the field names and field types corresponding to the request field and the return field.
[0083] Optionally, the acquisition module 201 is specifically configured to:
[0084] After receiving the interface document generation request, call the implementation class of the ApplicationRunner interface of the interface document generation plug-in;
[0085] The interface document generation plug-in scans all classes ending with Controller or annotated with @RestController in the source code of the application system, and obtains the annotations of the class as the prefix of the interface access URL;
[0086] The interface document generation plug-in scans all methods of the class, obtains the value of the @RequestMapping annotation in the method as the suffix of the interface access URL, and obtains the MethodType in the @RequestMapping annotation as the method access type;
[0087] The interface document generation plug-in scans the @param annotations of all methods of the class, obtains the content of the @param annotations as interface input parameters, and then separates the input name, Chinese name, type, whether it is required, and remarks in the interface input parameters with vertical bars;
[0088] The interface document generation plug-in scans the @return annotations of all methods of the class and determines whether the @return annotation is scanned. If so, the @return annotation is obtained as the interface output parameter of the interface document generation plug-in. Otherwise, the interface document generation plug-in uses reflection to obtain the return object of the method and parses the annotations of the return object attributes, and obtains the parsed annotations as the interface output parameter of the interface document generation plug-in;
[0089] The interface document generation plug-in stores data in a local cache according to different interface categories, wherein the data includes the prefix of the interface access URL, the suffix of the interface access URL, the type of method access, interface output parameters, and interface output parameters;
[0090] The interface document generation plug-in receives the access instruction of the interface access URL and then obtains the corresponding interface content from the local cache and assembles it as an interface document.
[0091] Optionally, the generating module 204 is specifically configured to:
[0092] Input the field name and field type corresponding to the request field and the return field, parse different interface documents, and output type scalars;
[0093] Determine whether the input interface document language is a basic type. If so, add its type scalar, type name, and type value to the type queue to be output. Otherwise, proceed to the next step.
[0094] Generate a new type, count all new types, and add properties of the upward connected type;
[0095] Merge all types in the type team to be output and add them to the output type queue, add non-empty attribute identifiers to the types and their corresponding fields, and output the final converted typescript type definition file.
[0096] The device provided in the embodiment of the present application can be specifically used to perform the above Figure 1 The solutions, specific functions and technical effects that can be achieved by the corresponding method embodiments will not be described in detail here.
[0097] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an exemplary embodiment of the present application. Figure 3 As shown, the electronic device 30 includes: a processor 301 and a memory 302 communicatively connected to the processor 301, and the memory 302 stores computer-executable instructions.
[0098] The processor executes the computer-executable instructions stored in the memory to implement the solution provided by any of the above method embodiments, and the specific functions and technical effects that can be achieved are not described in detail here. The electronic device can be the server mentioned above.
[0099] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement the solution provided by any of the above-mentioned method embodiments. The specific functions and technical effects that can be achieved are not repeated here.
[0100] An embodiment of the present application also provides a computer program product, which includes: a computer program, which is stored in a readable storage medium. At least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided by any of the above method embodiments. The specific functions and technical effects that can be achieved are not repeated here.
[0101] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0102] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for automatically generating a typescript type definition file from an interface document, characterized in that: The method for automatically generating a typescript type definition file from an interface document includes: Use the preset plug-in to obtain the interface document of the current page; Determine the request field and the return field respectively according to the interface document; According to the source program type of the interface document, respectively obtain the field name and field type corresponding to the request field and the return field; Automatically generate a typescript type definition file corresponding to the target program code according to the field names and field types corresponding to the request field and the return field; The method automatically generates a typescript type definition file corresponding to the target program code based on the field names and field types corresponding to the request field and the return field, specifically including: Input the field name and field type corresponding to the request field and the return field, parse different interface documents, and output type scalars; Determine whether the input interface document language is a basic type. If so, add its type scalar, type name, and type value to the type queue to be output. Otherwise, proceed to the next step. Generate a new type, count all new types, and add properties of the upward connected type; Merge all types in the type team to be output and add them to the output type queue, add non-empty attribute identifiers to the types and their corresponding fields, and output the final converted typescript type definition file, including: Obtaining a preset template corresponding to the target program code; Determine the hierarchical relationships between all fields and all subfields; The field name and field type of the field, as well as the field name and field type of the subfield corresponding to the field, are imported into the preset template according to the hierarchical relationship to generate a converted typescript type definition file.
2. The method for automatically generating a TypeScript type definition file from an interface document according to claim 1, characterized in that: The interface document of the current page is obtained by using a preset plug-in, specifically including: After receiving the interface document generation request, call the implementation class of the ApplicationRunner interface of the interface document generation plug-in; The interface document generation plug-in scans all classes ending with Controller or annotated with @RestController in the source code of the application system, and obtains the annotations of the class as the prefix of the interface access URL; The interface document generation plug-in scans all methods of the class, obtains the value of the @RequestMapping annotation in the method as the suffix of the interface access URL, and obtains the MethodType in the @RequestMapping annotation as the method access type; The interface document generation plug-in scans the @param annotations of all methods of the class, obtains the content of the @param annotations as interface input parameters, and then separates the input name, Chinese name, type, whether it is required, and remarks in the interface input parameters with vertical bars; The interface document generation plug-in scans the @return annotations of all methods of the class and determines whether the @return annotation is scanned. If so, the @return annotation is obtained as the interface output parameter of the interface document generation plug-in. Otherwise, the interface document generation plug-in uses reflection to obtain the return object of the method and parses the annotations of the return object attributes, and obtains the parsed annotations as the interface output parameter of the interface document generation plug-in; The interface document generation plug-in stores data in a local cache according to different interface categories, wherein the data includes the prefix of the interface access URL, the suffix of the interface access URL, the type of method access, interface output parameters, and interface output parameters; The interface document generation plug-in receives the access instruction of the interface access URL and then obtains the corresponding interface content from the local cache and assembles it as an interface document.
3. A device for automatically generating a typescript type definition file from an interface document, characterized in that: The device for automatically generating a typescript type definition file from an interface document includes: The acquisition module is used to obtain the interface document of the current page using the preset plug-in; A determination module, configured to determine the request field and the return field respectively according to the interface document; A processing module, configured to obtain, according to a source program type of the interface document, the field names and field types corresponding to the request field and the return field respectively; A generation module, configured to automatically generate a typescript type definition file corresponding to the target program code according to the field names and field types corresponding to the request field and the return field; The generating module is specifically used for: Input the field name and field type corresponding to the request field and the return field, parse different interface documents, and output type scalars; Determine whether the input interface document language is a basic type. If so, add its type scalar, type name, and type value to the type queue to be output. Otherwise, proceed to the next step. Generate a new type, count all new types, and add properties of the upward connected type; Merge all types in the type team to be output and add them to the output type queue, add non-empty attribute identifiers to the types and their corresponding fields, and output the final converted typescript type definition file. The output of the final converted typescript type definition file specifically includes: Obtaining a preset template corresponding to the target program code; Determine the hierarchical relationships between all fields and all subfields; The field name and field type of the field, as well as the field name and field type of the subfield corresponding to the field, are imported into the preset template according to the hierarchical relationship to generate a converted typescript type definition file.
4. The device for automatically generating a typescript type definition file from an interface document according to claim 3, characterized in that: The acquisition module is specifically used for: After receiving the interface document generation request, call the implementation class of the ApplicationRunner interface of the interface document generation plug-in; The interface document generation plug-in scans all classes ending with Controller or annotated with @RestController in the source code of the application system, and obtains the annotations of the class as the prefix of the interface access URL; The interface document generation plug-in scans all methods of the class, obtains the value of the @RequestMapping annotation in the method as the suffix of the interface access URL, and obtains the MethodType in the @RequestMapping annotation as the method access type; The interface document generation plug-in scans the @param annotations of all methods of the class, obtains the content of the @param annotations as interface input parameters, and then separates the input name, Chinese name, type, whether it is required, and remarks in the interface input parameters with vertical bars; The interface document generation plug-in scans the @return annotations of all methods of the class and determines whether the @return annotation is scanned. If so, the @return annotation is obtained as the interface output parameter of the interface document generation plug-in. Otherwise, the interface document generation plug-in uses reflection to obtain the return object of the method and parses the annotations of the return object attributes, and obtains the parsed annotations as the interface output parameter of the interface document generation plug-in; The interface document generation plug-in stores data in a local cache according to different interface categories, wherein the data includes the prefix of the interface access URL, the suffix of the interface access URL, the type of method access, interface output parameters, and interface output parameters; The interface document generation plug-in receives the access instruction of the interface access URL and then obtains the corresponding interface content from the local cache and assembles it as an interface document.
5. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 2.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 2 when executed by a processor.
7. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 2 when being executed by a processor.
Citation Information
Patent Citations
Customized document page generation method and related equipment
CN112307388A
Interface code generation method and device, electronic equipment, storage medium and product
CN113157256A