CN112230904A - Code generation method and device based on interface document, storage medium and server - Google Patents
Code generation method and device based on interface document, storage medium and server Download PDFInfo
- Publication number
- CN112230904A CN112230904A CN202011112422.XA CN202011112422A CN112230904A CN 112230904 A CN112230904 A CN 112230904A CN 202011112422 A CN202011112422 A CN 202011112422A CN 112230904 A CN112230904 A CN 112230904A
- Authority
- CN
- China
- Prior art keywords
- interface
- code
- interface document
- document
- plug
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 46
- 230000015654 memory Effects 0.000 claims description 27
- 238000005034 decoration Methods 0.000 claims description 12
- 239000003607 modifier Substances 0.000 claims description 12
- 238000010276 construction Methods 0.000 claims description 11
- 238000004590 computer program Methods 0.000 claims description 6
- 238000004458 analytical method Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 description 6
- 238000011161 development Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 238000012360 testing method Methods 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 2
- 230000001413 cellular effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/37—Compiler construction; Parser generation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/447—Target code generation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a code generation method, a device, a storage medium and a server based on an interface document; wherein the method comprises the following steps: configuring an interface document code generation plug-in a software project, wherein the interface document code generation plug-in is a maven plug-in; configuring a path configuration file of an interface document, wherein the path configuration file is used for indicating an interface document address; analyzing the path configuration file by using a configuration analyzer of the interface document code generation plug-in to obtain an interface document address of the interface document; and determining the interface document according to the interface document address and acquiring the content of the interface document by using the interface document code generation plug-in, and generating an interface code according to the content of the interface document. The method can automatically generate the interface code according to the interface document without manual operation, can reduce the error probability of the interface code, and can improve the generation efficiency of the interface code.
Description
Technical Field
The present invention relates to the field of interface data processing technologies, and in particular, to a code generation method and apparatus based on an interface document, a storage medium, and a server.
Background
The current iterative flow for a development project version is shown in FIG. 1. The product manager organizes personnel such as the front end and the back end and testing to discuss the requirements, and determines the range of the requirements and related services in the meeting process. And after combing the service logic, the back-end developer writes an interface document, and the back-end developer manually writes the most original interface code according to the interface document. The front end writes the front end code according to the interface document at the same time. And the front end and the rear end carry out joint debugging work of codes after completing respective development work. And after the front end and the rear end are successfully linked, submitting the linked information to a tester for system testing, and enabling the tester to test the production environment by issuing a test report.
The current way of manually generating interface code has the following problems:
1. the whole process needs manual operation of developers, and the error probability is increased.
2. In the process of converting the interface document into the interface code, a large amount of repeated codes exist, time and labor are wasted when developers manually write all the codes, and the efficiency is reduced.
Disclosure of Invention
The invention aims to overcome the defects of the prior art, and provides a code generation method, a device, a storage medium and a server based on an interface document, which can automatically generate an interface code according to the interface document, do not need manual operation, reduce the error probability of the interface code and improve the generation efficiency of the interface code.
In order to solve the above technical problem, an embodiment of the present invention provides a code generation method based on an interface document, where the method includes:
configuring an interface document code generation plug-in a software project, wherein the interface document code generation plug-in is a maven plug-in;
configuring a path configuration file of an interface document, wherein the path configuration file is used for indicating an interface document address;
analyzing the path configuration file by using a configuration analyzer of the interface document code generation plug-in to obtain an interface document address of the interface document;
and determining the interface document according to the interface document address and acquiring the content of the interface document by using the interface document code generation plug-in, and generating an interface code according to the content of the interface document.
Optionally, the content of the interface document includes an interface name, a modifier, parameter content, and annotation content.
Optionally, the generating an interface code according to the content of the interface document includes:
determining the format layout of the interface code and a generation document of the interface code;
acquiring a first position of the interface name in the generated document corresponding to the format layout, and generating a code of the interface name at the first position according to the interface name;
obtaining a second position of the decoration symbol in the generated document corresponding to the format layout, and generating a code of the decoration symbol at the second position according to the decoration symbol;
acquiring a third position of the parameter content in the generated document according to the format layout, and generating a code of the parameter content at the third position according to the parameter content;
acquiring a fourth position of the annotation content in the generated document according to the format layout, and generating a code of the annotation content at the fourth position according to the annotation content;
and obtaining the interface code according to the code of the interface name, the code of the modifier symbol, the code of the parameter content and the code of the annotation content.
Optionally, the method further includes:
determining each construction step of the software project in a maven project object model;
and generating the interface document code generation plug-in according to each construction step.
Optionally, the interface document code generation plug-in is a Jar data package of aggregated Java class files, related metadata, texts, and pictures, and is used for implementing an interface of a maven plug-in.
Optionally, the parsing the path configuration file by using the configuration parser of the interface document code generation plug-in includes:
and referencing the interface document code generation plug-in a build tag of the pom file so as to analyze the path configuration file by using a configuration analyzer of the interface document code generation plug-in.
Optionally, after generating the interface code according to the content of the interface document, the method further includes:
running the interface code to obtain a running result of the interface code;
determining an error code in the interface code according to the operation result;
determining error content in the interface document according to the error code;
and modifying the interface document according to the error content.
In addition, an embodiment of the present invention further provides a code generation apparatus based on an interface document, where the apparatus includes:
a first configuration module: the system comprises a code generation plug-in module, a code generation plug-in module and a code generation plug-in module, wherein the code generation plug-in module is used for configuring an interface document code generation plug-in a software project, and the interface document code generation plug-in module is a maven plug-in module;
a second configuration module: a path configuration file for configuring the interface document, the path configuration file indicating an interface document address;
an analysis module: a configuration parser for generating plug-ins by using the interface document codes analyzes the path configuration file to obtain interface document addresses of the interface documents;
a generation module: the interface document generating plug-in is used for determining the interface document according to the interface document address and acquiring the content of the interface document by using the interface document code generating plug-in, and generating an interface code according to the content of the interface document.
In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the batch-of-program-refresh authentication method described in any one of the above.
In addition, an embodiment of the present invention further provides a server, including:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to: executing the program batch bill-swiping identification method.
In the embodiment of the invention, an interface document code generation plug-in is configured in a software project, and a path configuration file of an interface document is analyzed by a parser of the plug-in generated by the interface document code to obtain an interface document address; and finally, generating the plug-in by using the interface document code to generate the interface code according to the content of the interface document. Therefore, the original full-manual coding can be changed into the automatic generation interface code, the workload is reduced, the error rate in the code generation process is reasonably and effectively avoided, the efficiency of developers is improved, and the iteration time of the project is effectively shortened.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is an iterative flow of development project versions;
FIG. 2 is a flowchart illustrating a method for generating code based on an interface document according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an interface document-based code generation apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural component diagram of a server in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Examples
Referring to fig. 2, fig. 2 is a flowchart illustrating a code generation method based on an interface document according to an embodiment of the present invention.
As shown in fig. 2, a code generation method based on an interface document includes the steps of:
s21, configuring an interface document code generation plug-in the software project, wherein the interface document code generation plug-in is a maven plug-in.
In this embodiment, the software project is a maven project management tool. The interface document code generation plug-in is a maven plug-in. The maven plug-in can be configured in the maven project management tool and execute tasks in the maven project management tool. The interface document code generation plug-in can be a plug-in which is independently developed according to various corresponding interface characteristics. The interface document code generation plug-in may generate the interface code in reverse from the interface document.
And S22, configuring a path configuration file of the interface document, wherein the path configuration file is used for indicating the address of the interface document.
In the present embodiment, a path profile of an interface document is loaded in a software project. The path profile is used to indicate the interface document address. Specifically, the path configuration file includes stored path information for one or more interface documents. The address of the corresponding interface document can be determined by the path information. Finally, the storage position of the interface document can be determined by means of addressing.
S23, using the configuration analyzer of the interface document code generation plug-in to analyze the path configuration file to obtain the interface document address of the interface document.
In this embodiment, the interface document address of the interface document can be obtained by parsing the information in the path configuration file by using a configuration parser in the self-developed interface document code generation plug-in. In particular, the path configuration file may include path information of interface documents of the one or more interfaces, and thus the configuration parser of the interface document code generation plug-in is used to parse the path configuration file to obtain interface document addresses of the one or more interfaces.
S24, using the interface document code generation plug-in to determine the interface document according to the interface document address and obtain the content of the interface document, and generating the interface code according to the content of the interface document.
In the embodiment, the interface document code generation plug-in is used for reading the content in the interface document, and after the reading is finished, the code generation is carried out according to the read content to generate the interface code of the corresponding interface. Specifically, the content of an interface document is determined according to an interface document address, and then an interface code is generated according to the content of the interface document. And when the content of a plurality of interface documents of the plurality of interface documents is used, generating corresponding interface codes according to the content of each interface document.
The content of the interface document comprises an interface name, a modifier symbol, parameter content and annotation content.
Further, the generating an interface code according to the content of the interface document includes: determining the format layout of the interface code and a generation document of the interface code; acquiring a first position of the interface name in the generated document corresponding to the format layout, and generating a code of the interface name at the first position according to the interface name; obtaining a second position of the decoration symbol in the generated document corresponding to the format layout, and generating a code of the decoration symbol at the second position according to the decoration symbol; acquiring a third position of the parameter content in the generated document according to the format layout, and generating a code of the parameter content at the third position according to the parameter content; acquiring a fourth position of the annotation content in the generated document according to the format layout, and generating a code of the annotation content at the fourth position according to the annotation content; and obtaining the interface code according to the code of the interface name, the code of the modifier symbol, the code of the parameter content and the code of the annotation content.
Specifically, the content of the interface document includes an interface name, a modifier symbol, parameter content, and annotation content. The generated interface code should also include the code of the interface name, the code of the modifier symbol, the code of the parameter content, and the code of the comment content. The positions of the contents are determined through the format layout of the interface codes and the generation document of the interface codes, and then the codes corresponding to the contents are generated at the corresponding positions, so that the generated interface codes better meet the code format requirements, the generated interface codes do not need to be adjusted, manual operation is reduced, and code errors caused by the manual operation can be avoided.
The code generation method based on the interface document generates the plug-in by configuring the interface document code in the software project, and the parser of the plug-in is used for parsing the path configuration file of the interface document to obtain the address of the interface document; and finally, generating the plug-in by using the interface document code to generate the interface code according to the content of the interface document. Therefore, the original full-manual coding can be changed into the automatic generation interface code, the workload is reduced, the error rate in the code generation process is reasonably and effectively avoided, the efficiency of developers is improved, and the iteration time of the project is effectively shortened.
Preferably, before S21, the method further comprises: determining each construction step of the software project in a maven project object model; and generating the interface document code generation plug-in according to each construction step.
Specifically, the software project is a maven project management tool. The maven project management tool will correspond to each lifecycle when executing commands. Each lifecycle, when executed, determines which plug-ins are configured in the Project Object Model (pom) file and then run the plug-ins. The life cycle of the maven project management tool is bound with the plug-in to complete the actual construction task. More specifically, the stages of the lifecycle are bound to the objects of the plug-ins to accomplish a specific construction task, and a specific function is implemented by the plug-ins (plugins). One plug-in may achieve multiple goals. To decouple the plug-in's functional and engineering phases to achieve a high degree of configurability, the maven project management tool specifies that the plug-in is simply a function that implements the target, with the configuration deciding which target operations to perform at which phase.
Therefore, before the maven project management tool configures the interface document code generation plug-in, each building step of the software project in the maven project object model needs to be determined, and then the interface document code generation plug-in is generated according to each building step, so that the maven project management tool can utilize the generated interface document code generation plug-in to execute the corresponding interface code generation work.
Preferably, the interface document code generation plug-in is a Jar data package of aggregated Java class files, related metadata, texts, and pictures, and is used for implementing an interface of a maven plug-in.
In particular, the essence of the maven plug-in is a jar package that uses some java code written by maven and packages the java code into. Among them, jar package is a software package file format, and usually has a large amount of Java class files, associated metadata and resources aggregated. Resources include text, pictures, etc.
Preferably, the parsing the path configuration file by using the configuration parser of the interface document code generation plug-in includes: and referencing the interface document code generation plug-in a build tag of the pom file so as to analyze the path configuration file by using a configuration analyzer of the interface document code generation plug-in.
Specifically, when in use, the interface document code generation plug-in is referred to in the build tag of the pom file. And after the plug-in is manufactured, configuring an interface document address in the configuration file, then operating the plug-in the project, and searching the interface document according to the configuration information by the plug-in, reading the content in the interface document and generating a corresponding code in the project. Thus, automated generation of interface code may be achieved.
Preferably, after generating the interface code according to the content of the interface document, the method further includes: running the interface code to obtain a running result of the interface code; determining an error code in the interface code according to the operation result; determining error content in the interface document according to the error code; and modifying the interface document according to the error content.
Specifically, after the interface code is automatically generated by using the interface document code generation plug-in, the interface code may be further run to obtain a running result of the interface code. And when an error code occurs in the operation result, determining the error content in the interface document according to the error code, and finally modifying the interface document according to the error content. Therefore, automatic debugging can be carried out in a result feedback mode, and interface document content can be adjusted without human participation, so that the accuracy of the interface document content is improved.
Compared with the prior art, the code generation method based on the interface document reduces the process of manual development of developers, changes the original full-manual coding into the automatic code generation, reduces the workload, reasonably and effectively avoids the error rate in the coding process, improves the efficiency of the developers, and effectively shortens the iteration time of the project.
Examples
Referring to fig. 3, fig. 3 is a schematic structural component diagram of a code generating apparatus based on an interface document according to an embodiment of the present invention.
An apparatus for code generation based on an interface document, the apparatus comprising:
the first configuration module 31: the method is used for configuring an interface document code generation plug-in the software project, and the interface document code generation plug-in is a maven plug-in.
In this embodiment, the software project is a maven project management tool. The interface document code generation plug-in is a maven plug-in. The maven plug-in can be configured in the maven project management tool and execute tasks in the maven project management tool. The interface document code generation plug-in can be a plug-in which is independently developed according to various corresponding interface characteristics. The interface document code generation plug-in may generate the interface code in reverse from the interface document.
Second configuration module 32: a path configuration file for configuring the interface document, the path configuration file indicating an interface document address.
In the present embodiment, a path profile of an interface document is loaded in a software project. The path profile is used to indicate the interface document address. Specifically, the path configuration file includes stored path information for one or more interface documents. The address of the corresponding interface document can be determined by the path information. Finally, the storage position of the interface document can be determined by means of addressing.
The analysis module 33: and the configuration analyzer for generating the plug-in by using the interface document code analyzes the path configuration file to obtain an interface document address of the interface document.
In this embodiment, the interface document address of the interface document can be obtained by parsing the information in the path configuration file by using a configuration parser in the self-developed interface document code generation plug-in. In particular, the path configuration file may include path information of interface documents of the one or more interfaces, and thus the configuration parser of the interface document code generation plug-in is used to parse the path configuration file to obtain interface document addresses of the one or more interfaces.
The generation module 34: the interface document generating plug-in is used for determining the interface document according to the interface document address and acquiring the content of the interface document by using the interface document code generating plug-in, and generating an interface code according to the content of the interface document.
In the embodiment, the interface document code generation plug-in is used for reading the content in the interface document, and after the reading is finished, the code generation is carried out according to the read content to generate the interface code of the corresponding interface. Specifically, the content of an interface document is determined according to an interface document address, and then an interface code is generated according to the content of the interface document. And when the content of a plurality of interface documents of the plurality of interface documents is used, generating corresponding interface codes according to the content of each interface document.
The content of the interface document comprises an interface name, a modifier symbol, parameter content and annotation content.
Further, the generating an interface code according to the content of the interface document includes: determining the format layout of the interface code and a generation document of the interface code; acquiring a first position of the interface name in the generated document corresponding to the format layout, and generating a code of the interface name at the first position according to the interface name; obtaining a second position of the decoration symbol in the generated document corresponding to the format layout, and generating a code of the decoration symbol at the second position according to the decoration symbol; acquiring a third position of the parameter content in the generated document according to the format layout, and generating a code of the parameter content at the third position according to the parameter content; acquiring a fourth position of the annotation content in the generated document according to the format layout, and generating a code of the annotation content at the fourth position according to the annotation content; and obtaining the interface code according to the code of the interface name, the code of the modifier symbol, the code of the parameter content and the code of the annotation content.
Specifically, the content of the interface document includes an interface name, a modifier symbol, parameter content, and annotation content. The generated interface code should also include the code of the interface name, the code of the modifier symbol, the code of the parameter content, and the code of the comment content. The positions of the contents are determined through the format layout of the interface codes and the generation document of the interface codes, and then the codes corresponding to the contents are generated at the corresponding positions, so that the generated interface codes better meet the code format requirements, the generated interface codes do not need to be adjusted, manual operation is reduced, and code errors caused by the manual operation can be avoided.
Preferably, the interface document-based code generation apparatus further comprises a generation module (not shown in fig. 3) for determining each building step of the software project in the maven project object model; and generating the interface document code generation plug-in according to each construction step.
Specifically, the software project is a maven project management tool. The maven project management tool will correspond to each lifecycle when executing commands. Each lifecycle, when executed, determines which plug-ins are configured in the Project Object Model (pom) file and then run the plug-ins. The life cycle of the maven project management tool is bound with the plug-in to complete the actual construction task. More specifically, the stages of the lifecycle are bound to the objects of the plug-ins to accomplish a specific construction task, and a specific function is implemented by the plug-ins (plugins). One plug-in may achieve multiple goals. To decouple the plug-in's functional and engineering phases to achieve a high degree of configurability, the maven project management tool specifies that the plug-in is simply a function that implements the target, with the configuration deciding which target operations to perform at which phase.
Therefore, before the maven project management tool configures the interface document code generation plug-in, each building step of the software project in the maven project object model needs to be determined, and then the interface document code generation plug-in is generated according to each building step, so that the maven project management tool can utilize the generated interface document code generation plug-in to execute the corresponding interface code generation work.
Preferably, the interface document code generation plug-in is a Jar data package of aggregated Java class files, related metadata, texts, and pictures, and is used for implementing an interface of a maven plug-in.
In particular, the essence of the maven plug-in is a jar package that uses some java code written by maven and packages the java code into. Among them, jar package is a software package file format, and usually has a large amount of Java class files, associated metadata and resources aggregated. Resources include text, pictures, etc.
Preferably, the parsing module 33 is further configured to refer to the interface document code generation plug-in the build tag of the pom file, so as to parse the path configuration file by using a configuration parser of the interface document code generation plug-in.
Specifically, when in use, the interface document code generation plug-in is referred to in the build tag of the pom file. And after the plug-in is manufactured, configuring an interface document address in the configuration file, then operating the plug-in the project, and searching the interface document according to the configuration information by the plug-in, reading the content in the interface document and generating a corresponding code in the project. Thus, automated generation of interface code may be achieved.
Preferably, the code generation apparatus based on the interface document further includes a modification module (not shown in fig. 3) for executing the interface code to obtain an execution result of the interface code; determining an error code in the interface code according to the operation result; determining error content in the interface document according to the error code; and modifying the interface document according to the error content.
Specifically, after the interface code is automatically generated by using the interface document code generation plug-in, the interface code may be further run to obtain a running result of the interface code. And when an error code occurs in the operation result, determining the error content in the interface document according to the error code, and finally modifying the interface document according to the error content. Therefore, automatic debugging can be carried out in a result feedback mode, and interface document content can be adjusted without human participation, so that the accuracy of the interface document content is improved.
In the embodiment of the invention, an interface document code generation plug-in is configured in a software project, and a path configuration file of an interface document is analyzed by a parser of the plug-in generated by the interface document code to obtain an interface document address; and finally, generating the plug-in by using the interface document code to generate the interface code according to the content of the interface document. Therefore, the original full-manual coding can be changed into the automatic generation interface code, the workload is reduced, the error rate in the code generation process is reasonably and effectively avoided, the efficiency of developers is improved, and the iteration time of the project is effectively shortened.
The computer-readable storage medium stores thereon a computer program, and when the computer program is executed by a processor, the computer program implements the interface document based code generation method according to any one of the above embodiments. The computer-readable storage medium includes, but is not limited to, any type of disk including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks, ROMs (Read-Only memories), RAMs (Random AcceSS memories), EPROMs (EraSable Programmable Read-Only memories), EEPROMs (Electrically EraSable Programmable Read-Only memories), flash memories, magnetic cards, or optical cards. That is, a storage device includes any medium that stores or transmits information in a form readable by a device (e.g., a computer, a cellular phone), and may be a read-only memory, a magnetic or optical disk, or the like.
The embodiment of the present invention further provides a computer application program, which runs on a computer, and is configured to execute the interface document-based code generation method according to any one of the above embodiments.
Fig. 4 is a schematic structural diagram of a server in the embodiment of the present invention.
An embodiment of the present invention further provides a server, as shown in fig. 4. The server comprises a processor 402, a memory 403, an input unit 404, a display unit 405, etc. Those skilled in the art will appreciate that the device configuration means shown in fig. 4 do not constitute a limitation of all devices and may include more or less components than those shown, or some components in combination. The memory 403 may be used to store the application 401 and various functional modules, and the processor 402 executes the application 401 stored in the memory 403, thereby performing various functional applications of the device and data processing. The memory may be internal or external memory, or include both internal and external memory. The memory may comprise read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), flash memory, or random access memory. The external memory may include a hard disk, a floppy disk, a ZIP disk, a usb-disk, a magnetic tape, etc. The disclosed memory includes, but is not limited to, these types of memory. The disclosed memory is by way of example only and not by way of limitation.
The input unit 404 is used for receiving input of signals and receiving keywords input by a user. The input unit 404 may include a touch panel and other input devices. The touch panel can collect touch operations of a user on or near the touch panel (for example, operations of the user on or near the touch panel by using any suitable object or accessory such as a finger, a stylus and the like) and drive the corresponding connecting device according to a preset program; other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., play control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like. The display unit 405 may be used to display information input by a user or information provided to the user and various menus of the server. The display unit 405 may take the form of a liquid crystal display, an organic light emitting diode, or the like. The processor 402 is a control center of the server, connects various parts of the entire apparatus using various interfaces and lines, performs various functions and processes data by operating or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory.
As one embodiment, the server includes: one or more processors 402, a memory 403, one or more applications 401, wherein the one or more applications 401 are stored in the memory 403 and configured to be executed by the one or more processors 402, the one or more applications 401 being configured to perform the method of interface document based code generation in any of the above embodiments.
In addition, the above detailed descriptions of the code generation method, apparatus, storage medium and server based on the interface document provided by the embodiment of the present invention are provided, and a specific example should be used herein to explain the principle and the implementation of the present invention, and the above description of the embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (10)
1. A method for code generation based on an interface document, the method comprising:
configuring an interface document code generation plug-in a software project, wherein the interface document code generation plug-in is a maven plug-in;
configuring a path configuration file of an interface document, wherein the path configuration file is used for indicating an interface document address;
analyzing the path configuration file by using a configuration analyzer of the interface document code generation plug-in to obtain an interface document address of the interface document;
and determining the interface document according to the interface document address and acquiring the content of the interface document by using the interface document code generation plug-in, and generating an interface code according to the content of the interface document.
2. The code generation method of claim 1, wherein the content of the interface document includes an interface name, a modifier symbol, parameter content, and annotation content.
3. The code generation method according to claim 2, wherein the generating an interface code from the content of the interface document includes:
determining the format layout of the interface code and a generation document of the interface code;
acquiring a first position of the interface name in the generated document corresponding to the format layout, and generating a code of the interface name at the first position according to the interface name;
obtaining a second position of the decoration symbol in the generated document corresponding to the format layout, and generating a code of the decoration symbol at the second position according to the decoration symbol;
acquiring a third position of the parameter content in the generated document according to the format layout, and generating a code of the parameter content at the third position according to the parameter content;
acquiring a fourth position of the annotation content in the generated document according to the format layout, and generating a code of the annotation content at the fourth position according to the annotation content;
and obtaining the interface code according to the code of the interface name, the code of the modifier symbol, the code of the parameter content and the code of the annotation content.
4. The code generation method of claim 1, wherein the method further comprises:
determining each construction step of the software project in a maven project object model;
and generating the interface document code generation plug-in according to each construction step.
5. The code generation method of claim 4, wherein the interface document code generation plug-in is a Jar data package of aggregated Java class files, associated metadata, text, pictures, and is used to implement an interface of a maven plug-in.
6. The code generation method of claim 5, wherein parsing the path configuration file using a configuration parser of the interface document code generation plug-in comprises:
and referencing the interface document code generation plug-in a build tag of the pom file so as to analyze the path configuration file by using a configuration analyzer of the interface document code generation plug-in.
7. The code generation method according to claim 6, further comprising, after generating the interface code from the content of the interface document:
running the interface code to obtain a running result of the interface code;
determining an error code in the interface code according to the operation result;
determining error content in the interface document according to the error code;
and modifying the interface document according to the error content.
8. An apparatus for code generation based on an interface document, the apparatus comprising:
a first configuration module: the system comprises a code generation plug-in module, a code generation plug-in module and a code generation plug-in module, wherein the code generation plug-in module is used for configuring an interface document code generation plug-in a software project, and the interface document code generation plug-in module is a maven plug-in module;
a second configuration module: a path configuration file for configuring the interface document, the path configuration file indicating an interface document address;
an analysis module: a configuration parser for generating plug-ins by using the interface document codes analyzes the path configuration file to obtain interface document addresses of the interface documents;
a generation module: the interface document generating plug-in is used for determining the interface document according to the interface document address and acquiring the content of the interface document by using the interface document code generating plug-in, and generating an interface code according to the content of the interface document.
9. A computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, implementing the interface document based code generation method of any one of claims 1 to 7.
10. A server, characterized in that it comprises:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to: executing the interface document based code generation method according to any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011112422.XA CN112230904A (en) | 2020-10-16 | 2020-10-16 | Code generation method and device based on interface document, storage medium and server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011112422.XA CN112230904A (en) | 2020-10-16 | 2020-10-16 | Code generation method and device based on interface document, storage medium and server |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112230904A true CN112230904A (en) | 2021-01-15 |
Family
ID=74118535
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011112422.XA Pending CN112230904A (en) | 2020-10-16 | 2020-10-16 | Code generation method and device based on interface document, storage medium and server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112230904A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112988224A (en) * | 2021-01-21 | 2021-06-18 | 中信银行股份有限公司 | Interface file generation method of micro-service framework, electronic device and storage medium |
CN113050953A (en) * | 2021-04-21 | 2021-06-29 | 平安普惠企业管理有限公司 | Method, device and storage medium for generating code based on annotation |
CN113900706A (en) * | 2021-10-13 | 2022-01-07 | 中国银行股份有限公司 | Interface document generation method and device |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130232469A1 (en) * | 2012-03-02 | 2013-09-05 | Oracle International Corporation | System and method for automatically resolving dependencies of java archive files for use with maven |
CN103500087A (en) * | 2013-09-17 | 2014-01-08 | 福建亿榕信息技术有限公司 | Code generation method and device based on maven plug-in and freemarker template |
CN110362295A (en) * | 2019-05-27 | 2019-10-22 | 深圳壹账通智能科技有限公司 | Code generating method, device, computer installation and storage medium |
CN110515608A (en) * | 2019-08-30 | 2019-11-29 | 网易(杭州)网络有限公司 | A kind of generation method and device, electronic equipment, storage medium of interface code |
-
2020
- 2020-10-16 CN CN202011112422.XA patent/CN112230904A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130232469A1 (en) * | 2012-03-02 | 2013-09-05 | Oracle International Corporation | System and method for automatically resolving dependencies of java archive files for use with maven |
CN103500087A (en) * | 2013-09-17 | 2014-01-08 | 福建亿榕信息技术有限公司 | Code generation method and device based on maven plug-in and freemarker template |
CN110362295A (en) * | 2019-05-27 | 2019-10-22 | 深圳壹账通智能科技有限公司 | Code generating method, device, computer installation and storage medium |
CN110515608A (en) * | 2019-08-30 | 2019-11-29 | 网易(杭州)网络有限公司 | A kind of generation method and device, electronic equipment, storage medium of interface code |
Non-Patent Citations (1)
Title |
---|
是故城啊: "ymal、json通过swagger-codegen反向生成java接口代码", pages 1 - 2, Retrieved from the Internet <URL:https://blog.csdn.net/yunmengmin/article/details/84662994> * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112988224A (en) * | 2021-01-21 | 2021-06-18 | 中信银行股份有限公司 | Interface file generation method of micro-service framework, electronic device and storage medium |
CN113050953A (en) * | 2021-04-21 | 2021-06-29 | 平安普惠企业管理有限公司 | Method, device and storage medium for generating code based on annotation |
CN113900706A (en) * | 2021-10-13 | 2022-01-07 | 中国银行股份有限公司 | Interface document generation method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10162612B2 (en) | Method and apparatus for inventory analysis | |
US10579344B2 (en) | Converting visual diagrams into code | |
EP2368189B1 (en) | Debugging pipeline | |
CN111832236B (en) | Chip regression testing method and system, electronic equipment and storage medium | |
US20160357519A1 (en) | Natural Language Engine for Coding and Debugging | |
US8312417B2 (en) | Using dynamic call graphs for creating state machines | |
CN112000398B (en) | Method and device for determining bottom layer interface call link, computer equipment and medium | |
US20060230319A1 (en) | Automated migration of software instructions | |
US11593342B2 (en) | Systems and methods for database orientation transformation | |
CN112230904A (en) | Code generation method and device based on interface document, storage medium and server | |
EP2557499A1 (en) | A system and method for automatic impact variable analysis and field expansion in mainframe systems | |
CN112035443B (en) | Big data execution method, system, equipment and storage medium based on Linux platform | |
US11740875B2 (en) | Type inference in dynamic languages | |
CN112230988A (en) | Interface document generation method and device, computer equipment and storage medium | |
CN114253537A (en) | Form generation method and device, electronic equipment and storage medium | |
CN115525282A (en) | Method for realizing cross-platform desktop application program and related equipment thereof | |
US11755458B2 (en) | Automatic software behavior identification using execution record | |
CN110928760B (en) | Unit test method and device in embedded system | |
CN111159301A (en) | Data creating method, device, equipment and storage medium based on intelligent contract | |
US20130145343A1 (en) | Workspace model for interrelated projects | |
CN114201382A (en) | Test case generation method and device, storage medium and electronic equipment | |
CN114356783A (en) | Method and device for automatically generating unit test code, storage medium and equipment | |
CN113220586A (en) | Automatic interface pressure test execution method, device and system | |
Rayhan et al. | Model-Based Testing of IoT Mobile Controller Smart Light Systems Using Extended Finite State Machine | |
Xie et al. | CodeFuse-Query: A Data-Centric Static Code Analysis System for Large-Scale Organizations |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |