CN111767070A - API document management method and device, computer equipment and storage medium - Google Patents

API document management method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN111767070A
CN111767070A CN202010620487.9A CN202010620487A CN111767070A CN 111767070 A CN111767070 A CN 111767070A CN 202010620487 A CN202010620487 A CN 202010620487A CN 111767070 A CN111767070 A CN 111767070A
Authority
CN
China
Prior art keywords
target
class
directory
interface
creating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010620487.9A
Other languages
Chinese (zh)
Inventor
刘红波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202010620487.9A priority Critical patent/CN111767070A/en
Publication of CN111767070A publication Critical patent/CN111767070A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The embodiment of the invention discloses an API document management method, an API document management device, computer equipment and a storage medium. The method comprises the following steps: if the target interface document is detected to be completely created, acquiring a target address of a target interface, wherein the target interface is an interface defined when the target interface document is created; creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to parameters in the target interface document; and calling the target method according to the target class to generate a target program code corresponding to the target interface document. The method is applied to the field of development auxiliary tools, and can realize synchronous updating of the API document and the program code, improve the development efficiency and save system resources.

Description

API document management method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to an API document management method, an API document management apparatus, a computer device, and a storage medium.
Background
The API document is an important material in the software development and maintenance process, but the API document is time-consuming to write, and the API document is often inconsistent with the software program after the software program is changed. A disadvantage of this API document management approach of the prior art is that someone is required to specifically maintain the API document information because the API document and its corresponding code are separate. However, during the development process, the developer needs to modify the definition of the API frequently, which necessitates that the API document be updated synchronously, and the developer forgets to update the API document frequently, so that the API document description does not conform to the definition of the existing API, and the API document description lags behind the actual function of the current API. The most common development technology in Java development is Spring, and the current API document management tool is not well combined with Spring to realize automatic API document management.
Disclosure of Invention
The embodiment of the invention provides an API document management method, an API document management device, computer equipment and a storage medium, and aims to solve the problem that an API document and a program code cannot be kept consistent.
In a first aspect, an embodiment of the present invention provides an API document management method, including: if the target interface document is detected to be completely created, acquiring a target address of a target interface, wherein the target interface is an interface defined when the target interface document is created; creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to parameters in the target interface document; and calling the target method according to the target class to generate a target program code corresponding to the target interface document.
In a second aspect, an embodiment of the present invention further provides an API document management apparatus, which includes: the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring a target address of a target interface if the completion of the creation of a target interface document is detected, and the target interface is an interface defined when the target interface document is created; the creating unit is used for creating a target method corresponding to the target interface document according to the target address and creating a target class corresponding to the parameters in the target interface document; and the generating unit is used for calling the target method according to the target class to generate a target program code corresponding to the target interface document.
In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the above method when executing the computer program.
In a fourth aspect, the present invention also provides a computer-readable storage medium, which stores a computer program, and the computer program can implement the above method when being executed by a processor.
The embodiment of the invention provides an API document management method, an API document management device, computer equipment and a storage medium. Wherein the method comprises the following steps: if the target interface document is detected to be completely created, acquiring a target address of a target interface, wherein the target interface is an interface defined when the target interface document is created; creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to parameters in the target interface document; and calling the target method according to the target class to generate a target program code corresponding to the target interface document. According to the embodiment of the invention, the target method and the target class corresponding to the target interface document are created according to the target address, and the target program code corresponding to the target interface document is generated by calling the target method according to the target class, so that the synchronous updating of the API document and the program code can be realized, the development efficiency is improved, and the system resources are saved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flowchart illustrating an API document management method according to an embodiment of the present invention;
FIG. 2 is a sub-flow diagram of an API document management method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating an API document management method according to another embodiment of the present invention;
FIG. 4 is a flowchart illustrating an API document management method according to another embodiment of the present invention;
FIG. 5 is a sub-flow diagram of an API document management method according to an embodiment of the present invention;
FIG. 6 is a schematic block diagram of an API document management apparatus provided by an embodiment of the present invention;
FIG. 7 is a schematic block diagram of specific elements of an API document management apparatus provided by an embodiment of the present invention;
FIG. 8 is a schematic block diagram of an API document management apparatus according to another embodiment of the present invention;
FIG. 9 is a schematic block diagram of an API document management apparatus according to yet another embodiment of the present invention;
FIG. 10 is a schematic block diagram of an update unit of the API document management apparatus provided by the embodiment of the present invention;
FIG. 11 is a schematic block diagram of a computer device provided by an 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 some, not all, embodiments of the present invention. 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.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the specification of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
Referring to fig. 1, fig. 1 is a schematic flow chart of an API document management method according to an embodiment of the present invention. The API document management method is applied to a terminal, the embodiment of the invention is based on Spring, and Spring is an open-source lightweight Java development framework which is commonly used at present. The API document management tool is an automatic management platform for interface development and debugging, such as Swagger, Showdoc, apidoc and the like. However, current API document management tools do not effectively integrate with Spring, resulting in an inability to synchronize updates to API documents. The API document management method provided by the embodiment of the invention is applied to an API document management tool and can realize the synchronous update of the API document and the program code. That is, the developer automatically creates the relevant Java program code when the project starts to create the API document; when the user modifies the program code, the API document is also updated; the program code of the API document can be changed by the later user only by modifying the program code, or the API document can be automatically updated when the user modifies the program code.
Specifically, fig. 1 is a flowchart illustrating an API document management method according to an embodiment of the present invention. As shown, the method includes the following steps S110-S130.
S110, if the completion of the creation of the target interface document is detected, a target address of a target interface is obtained, wherein the target interface is an interface defined when the target interface document is created.
In one embodiment, the target interface document refers to an API document developed by a developer. And when the developer creates the target interface document, defining a target interface corresponding to the target interface document. When the developer finishes writing the target interface document, the written target interface document is saved, and at this time, it is detected that the target interface document is completely created, so as to obtain a target address, i.e. a URL, of the target interface, such as/user/info/getName.
S120, creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to the parameters in the target interface document.
In one embodiment, the target method refers to a method developed by a developer, for example, getName, which is a method for obtaining a name. The target class encapsulates the parameters that implement the target method. Specifically, after the target address is obtained, a target method is created in the target address, which is also a corresponding method in the target interface document, and in addition, for the parameters in the target interface document, a corresponding target class is created in the target address.
In one embodiment, as shown in FIG. 2, the step S120 may include steps S121-S123.
And S121, creating a control class according to the target address under the control directory, and creating a target method corresponding to the target interface document in the control class.
In one embodiment, a control directory, i.e., controller directory, is used to manage the directory in which the developed methods are stored. Specifically, a controller directory is searched first, if the controller directory does not exist, the prompt code does not meet the specification, if the controller directory exists, a control class is created according to the target address, and then the target method is created in the control class. For example,/user/info/getName, first find the controller directory, create a user directory (if existing, not create), then create an InfoController class (i.e., control class, if existing, not create), create a getName method in the InfoController class.
It should be noted that an @ RequestMapping annotation and an @ Controller annotation are required to be added to the InfoController class. RequestMapping is a notation for handling request address mapping, and may be used on classes or methods, where the method used to represent all response requests in a class is parent to the address. @ Controller is used to mark on a class, the class marked with it is a Spring's Controller class, and the distribution processor will scan the method using the annotated class and detect if the method uses the @ RequestMapping annotation. @ Controller defines only one Controller class, and the method using the @ RequestMapping notation is the processor that processes the request. Thus, the @ RequestMapping gives a path, or trigger path, to access the target method, a trigger condition.
And S122, creating a first target class directory under a parent directory of the control directory, and creating a reference class corresponding to a reference field in the target interface document according to the target address under the first target class directory.
In one embodiment, the first target class directory refers to a directory for managing the deposit reference field, i.e., a req directory. The enlistment class encapsulates the field of the target interface document enlistment. Specifically, a first target class directory is created first, and then the entry class is created according to the target address under the first target class directory. For example,/user/info/getName, a req directory is created under the parent directory of the controller directory (i.e., the first target class directory, if there is one, it is not created), then a user directory is created (if there is one, it is not created), then an info directory is created (if there is one, it is not created), and finally a getNameInput class (i.e., the entry class) is created, where the fields of the class are consistent with the entry fields in the API document. The entry parameter type of the getName method is a GetNameInput class, and comments of each field of the GetNameInput class correspond to descriptions of each field of entry parameters in the target interface document.
S123, creating a second target category directory under the parent directory of the control directory, and creating a reference category corresponding to the reference field in the target interface document according to the target address under the second target category directory.
In one embodiment, the second target class directory refers to a directory for managing the deposit-release parameter field, i.e., an rsp directory. The out-reference class encapsulates the out-reference fields of the target interface document. Specifically, a second target class directory is created first, and then a participating class is created according to a target address under the second target class directory. For example,/user/info/getName, an rsp directory is created under the parent directory of the controller directory (i.e., the second target class directory, if already existing, it is not created), then a user directory is created (if already existing, it is not created), then an info directory is created (if already existing, it is not created), and finally a GetNameResult class (out-reference class) is created, where the fields of the class are consistent with the out-reference fields in the API document. The return value type of the getName method is a GetNameResult type. Comments of each field of the GetNameResult class correspond to descriptions of each field in the target interface document.
S130, calling the target method according to the target class to generate a target program code corresponding to the target interface document.
In an embodiment, after the target method and the target class are created, the created target method is directly called according to the created target class, and then the target program code corresponding to the target interface document can be generated. Thereby, synchronous updating of the API document and the program code is realized. Specifically, after the target method, the participating class and the participating class are created, the created target method is called directly according to the created participating class and the participating class, and then the target program code corresponding to the target interface document can be generated. Thereby, synchronous updating of the API document and the program code is realized.
In an embodiment, as shown in fig. 3, before the step S130, steps S1301-S1303 are further included.
S1301, judging the type of the target method.
S1302, if the type of the target method is an acquisition type method, adding a first annotation to the target method.
S1303, if the type of the target method is a submission type method, adding a second annotation to the target method.
In an embodiment, the types of methods include a commit method (POST method), which is a method of committing data to be processed to a specified resource, and an acquire method (GET method), which is a method of requesting data from a specified resource. The first annotation refers to @ GetMapping, which is used to map a GET request. The second annotation refers to @ PostMapping, which is used to map a POST request. Specifically, it is first determined whether the type of the target method is an acquisition type method or a commit type method, for example, by a request getmethod () method, and if the type of the target method is an acquisition type method, an @ GetMapping annotation is added to the target method, and if the type of the target method is a commit type method, an @ PostMapping annotation is added to the target method. Thus, the target method can process the request of the corresponding target address path. For example, getName method, whereby requests for/user/info/getName paths can be processed.
In an embodiment, as shown in fig. 4, the method further comprises: S140-S160.
S140, if the files in the control directory or the first target class directory or the second target class directory are updated, the target method is obtained according to the class reference relationship between the control class and the target method.
S150, obtaining a target address corresponding to the target method, and searching the target interface document according to the target address.
And S160, updating the interface content in the target interface document according to the files in the control directory or the first target class directory or the second target class directory.
In one embodiment, during the process of modifying the program code by the developer, if a file in the control directory or the first target class directory or the second target class directory is changed, wherein the file is used for describing the interface content, the developer is instructed to change the interface content and the interface content needs to be updated. Specifically, because the control class and the target method in the control directory have a mutual reference relationship, the target method corresponding to the control class in the control directory can be obtained according to the class reference relationship, then the target address corresponding to the target method is obtained, the target interface document can be found according to the obtained target address, so that the interface content is obtained, and finally the updated content in the file is updated to the interface content.
In one embodiment, as shown in FIG. 5, the step S160 includes S161-S163.
S161, identifying the directory where the updated file exists.
S162, determining interface content needing to be updated according to a directory of the updated file, wherein the updated interface content comprises the participating class, the participating class and the target address.
And S163, updating the determined updated content into the interface content of the target interface document.
In an embodiment, the directory is identified according to the name of the directory where the updated file is located, and different interface contents are updated correspondingly by updating the files in different directories. Specifically, if the file under the control directory is updated, the interface content to be updated is the target interface address; updating the file in the first target category, wherein the interface content needing to be updated is the participating category; and updating the file in the second target category, wherein the interface content needing to be updated is the participating category. And after determining the interface content needing to be updated, correspondingly updating the interface content needing to be updated into the interface content of the target interface document. For example, if the values of @ RequestMapping, @ PostMapping, @ GetMapping are modified, the API document management tool automatically updates the URL address of the corresponding interface in the API document. For another example, if the file in the req directory has an update, such as adding, deleting, modifying a field, the API document management tool automatically updates the entry field of the target interface corresponding to the API document. If the field comments are modified, the corresponding field descriptions in the API document are also updated synchronously. For another example, if the file in the rsp directory has an update, such as adding, deleting, modifying a field, the API document management tool automatically updates the out-reference field of the target interface corresponding to the API document. If the field comments are modified, the corresponding field descriptions in the API document are also updated synchronously.
In addition, in the embodiment, when a subsequent developer modifies the API document, if the interface content is changed, the code is updated correspondingly. The specific process is similar to generating the target program code, for example, if the URL address is modified, the control directory is searched for the corresponding InfoController class (control class), and then the value of @ RequestMapping, @ PostMapping, or @ GetMapping is modified. As another example, if a reference is modified, such as adding, deleting, modifying a field, the API document management system searches the req directory in the code for the corresponding class and then updates the corresponding field. If a field in the API document indicates a modification, the corresponding field annotation in the reference is also updated synchronously. As another example, if a parameter is modified, such as adding, deleting, modifying a field, the API document management system searches the rsp directory in the code for a corresponding class and then updates the corresponding field. If a field in the API document indicates a modification, the field comments in the corresponding out-reference are also updated synchronously.
The embodiment of the invention provides an API document management method, which comprises the steps of obtaining a target address of a target interface if the completion of the creation of a target interface document is detected, wherein the target interface is an interface defined when the target interface document is created; creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to parameters in the target interface document; and calling the target method according to the target class to generate a target program code corresponding to the target interface document, so that the synchronous updating of the API document and the program code can be realized, the development efficiency is improved, and the system resources are saved.
FIG. 6 is a schematic block diagram of an API document management device 200 according to an embodiment of the present invention. As shown in FIG. 6, the present invention also provides an API document management device 200 corresponding to the above API document management method. The API document management apparatus 200 includes a unit for performing the API document management method, and may be configured in a desktop computer, a tablet computer, a portable computer, or the like. Specifically, referring to fig. 6, the API document management apparatus 200 includes an acquisition unit 210, a creation unit 220, and a generation unit 230.
An obtaining unit 210, configured to obtain a target address of a target interface if it is detected that creation of a target interface document is completed, where the target interface is an interface defined when the target interface document is created.
A creating unit 220, configured to create a target method corresponding to the target interface document according to the target address, and create a target class corresponding to the parameter in the target interface document.
In one embodiment, as shown in fig. 7, the creating unit 220 includes a first creating unit 221, a second creating unit 222, and a third creating unit 223.
A first creating unit 221, configured to create a control class according to the target address under the control directory, and create a target method corresponding to the target interface document in the control class.
The second creating unit 222 is configured to create a first target class directory in the parent directory of the control directory, and create, in the first target class directory, an entry class corresponding to the entry field in the target interface document according to the target address.
A third creating unit 223, configured to create a second target class directory in the parent directory of the control directory, and create a participating class corresponding to the participating field in the target interface document according to the target address in the second target class directory.
The generating unit 230 is configured to invoke the target method according to the target class to generate a target program code corresponding to the target interface document.
In one embodiment, as shown in fig. 8, the API document management apparatus further includes: a judging unit 2301, a first annotation unit 2302 and a second annotation unit 2303.
A judging unit 2301 for judging the type of the target method.
A first annotation unit 2302 for adding a first annotation to the target method if the type of the target method is an acquisition type method.
A second annotation unit 2303, configured to add a second annotation to the target method if the type of the target method is a commit type method.
In one embodiment, as shown in fig. 9, the API document management apparatus further includes: a reference unit 240, a lookup unit 250, and an update unit 260.
A reference unit 240, configured to, if a file in the control directory or the first target class directory or the second target class directory has an update, obtain the target method according to a class reference relationship between the control class and the target method;
a searching unit 250, configured to obtain a target address corresponding to the target method, and search the target interface document according to the target address;
an updating unit 260, configured to update the interface content in the target interface document according to a file in the control directory or the first target class directory or the second target class directory.
In one embodiment, as shown in fig. 10, the updating unit 260 includes: an identification unit 261, a determination unit 262 and an update sub-unit 263.
An identifying unit 261 is configured to identify a directory in which the updated file exists.
The determining unit 262 is configured to determine interface content that needs to be updated according to a directory in which an updated file exists, where the updated interface content includes the participating class, and the target address.
An updating sub-unit 263, configured to update the determined updated interface content into the interface content of the target interface document.
It should be noted that, as can be clearly understood by those skilled in the art, the specific implementation processes of the API document management apparatus 200 and each unit may refer to the corresponding descriptions in the foregoing method embodiments, and for convenience and brevity of description, no further description is provided herein.
The API document management apparatus described above may be implemented in the form of a computer program that can be run on a computer device as shown in fig. 11.
Referring to fig. 11, fig. 11 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 500 may be a terminal, wherein the terminal may be an electronic device with a communication function, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device.
Referring to fig. 11, the computer device 500 includes a processor 502, memory, and a network interface 505 connected by a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer programs 5032 include program instructions that, when executed, cause the processor 502 to perform an API document management method.
The processor 502 is used to provide computing and control capabilities to support the operation of the overall computer device 500.
The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503, and when the computer program 5032 is executed by the processor 502, the processor 502 may be caused to execute an API document management method.
The network interface 505 is used for network communication with other devices. Those skilled in the art will appreciate that the configuration shown in fig. 11 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation of the computer device 500 to which the present application may be applied, and that a particular computer device 500 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
Wherein the processor 502 is configured to run the computer program 5032 stored in the memory to implement the following steps: if the target interface document is detected to be completely created, acquiring a target address of a target interface, wherein the target interface is an interface defined when the target interface document is created; creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to parameters in the target interface document; and calling the target method according to the target class to generate a target program code corresponding to the target interface document.
In an embodiment, when implementing the steps of creating the target method corresponding to the target interface document according to the target address and creating the target class corresponding to the parameter in the target interface document, the processor 502 specifically implements the following steps: creating a control class according to the target address under a control directory, and creating a target method corresponding to the target interface document in the control class; creating a first target class directory under a parent directory of a control directory, and creating a reference class corresponding to a reference field in the target interface document according to the target address under the first target class directory; and creating a second target class directory under the parent directory of the control directory, and creating a participating class corresponding to a participating field in the target interface document according to the target address under the second target class directory.
In an embodiment, before implementing the step of invoking the target method according to the target class to generate the target program code corresponding to the target interface document, the processor 502 further implements the following steps: judging the type of the target method; if the type of the target method is an acquisition type method, adding a first annotation to the target method; and if the type of the target method is a submission type method, adding a second annotation to the target method.
In an embodiment, after implementing the step of invoking the target method according to the target class to generate the target program code corresponding to the target interface document, the processor 502 further implements the following steps: if the files in the control directory or the first target class directory or the second target class directory are updated, acquiring the target method according to the class reference relationship between the control class and the target method; acquiring a target address corresponding to the target method, and searching the target interface document according to the target address; and updating the interface content in the target interface document according to the files in the control directory or the first target class directory or the second target class directory.
In an embodiment, when the step of updating the interface content in the target interface document according to the file in the control directory or the first target class directory or the second target class directory is implemented by the processor 502, the following steps are specifically implemented: identifying a directory in which the updated file exists; determining interface contents needing to be updated according to a directory where an updated file exists, wherein the updated interface contents comprise the participating class, the participating class and the target address; updating the determined updated interface content into the interface content of the target interface document.
It should be understood that, in the embodiment of the present Application, the Processor 502 may be a Central Processing Unit (CPU), and the Processor 502 may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It will be understood by those skilled in the art that all or part of the flow of the method implementing the above embodiments may be implemented by a computer program instructing associated hardware. The computer program includes program instructions, and the computer program may be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the flow steps of the embodiments of the method described above.
Accordingly, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program comprises program instructions. The program instructions, when executed by the processor, cause the processor to perform the steps of: if the target interface document is detected to be completely created, acquiring a target address of a target interface, wherein the target interface is an interface defined when the target interface document is created; creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to parameters in the target interface document; and calling the target method according to the target class to generate a target program code corresponding to the target interface document.
In an embodiment, when the processor executes the program instruction to implement the steps of creating the target method corresponding to the target interface document according to the target address and creating the target class corresponding to the parameter in the target interface document, the following steps are specifically implemented: creating a control class according to the target address under a control directory, and creating a target method corresponding to the target interface document in the control class; creating a first target class directory under a parent directory of a control directory, and creating a reference class corresponding to a reference field in the target interface document according to the target address under the first target class directory; and creating a second target class directory under the parent directory of the control directory, and creating a participating class corresponding to a participating field in the target interface document according to the target address under the second target class directory.
In an embodiment, before executing the program instructions to implement the step of calling the target method according to the target class to generate the target program code corresponding to the target interface document, the processor further implements the following steps: judging the type of the target method; if the type of the target method is an acquisition type method, adding a first annotation to the target method; and if the type of the target method is a submission type method, adding a second annotation to the target method.
In an embodiment, after executing the program instructions to implement the step of calling the target method according to the target class to generate the target interface document, the processor further implements the following steps: if the files in the control directory or the first target class directory or the second target class directory are updated, acquiring the target method according to the class reference relationship between the control class and the target method; acquiring a target address corresponding to the target method, and searching the target interface document according to the target address; and updating the interface content in the target interface document according to the files in the control directory or the first target class directory or the second target class directory.
In an embodiment, when the processor executes the program instructions to implement the step of updating the interface content in the target interface document according to the file in the control directory or the first target class directory or the second target class directory, the following steps are specifically implemented: identifying a directory in which the updated file exists; determining interface contents needing to be updated according to a directory where an updated file exists, wherein the updated interface contents comprise the participating class, the participating class and the target address; updating the determined updated interface content into the interface content of the target interface document.
The storage medium may be a usb disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk, which can store various computer readable storage media.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, various elements or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented.
The steps in the method of the embodiment of the invention can be sequentially adjusted, combined and deleted according to actual needs. The units in the device of the embodiment of the invention can be merged, divided and deleted according to actual needs. In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a storage medium. Based on such understanding, the technical solution of the present invention essentially or partially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a terminal, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention.
While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. An API document management method, comprising:
if the target interface document is detected to be completely created, acquiring a target address of a target interface, wherein the target interface is an interface defined when the target interface document is created;
creating a target method corresponding to the target interface document according to the target address, and creating a target class corresponding to parameters in the target interface document;
and calling the target method according to the target class to generate a target program code corresponding to the target interface document.
2. The API document management method of claim 1, wherein the creating a target method corresponding to the target interface document according to the target address and creating a target class corresponding to a parameter in the target interface document comprises:
creating a control class according to the target address under a control directory, and creating a target method corresponding to the target interface document in the control class;
creating a first target class directory under a parent directory of a control directory, and creating a reference class corresponding to a reference field in the target interface document according to the target address under the first target class directory;
and creating a second target class directory under the parent directory of the control directory, and creating a participating class corresponding to a participating field in the target interface document according to the target address under the second target class directory.
3. The API document management method of claim 2, wherein before the calling the target method according to the target class to generate the target program code corresponding to the target interface document, further comprising:
judging the type of the target method;
if the type of the target method is an acquisition type method, adding a first annotation to the target method;
and if the type of the target method is a submission type method, adding a second annotation to the target method.
4. An API document management method according to any one of claims 2 to 3, wherein the method further includes:
if the files in the control directory or the first target class directory or the second target class directory are updated, acquiring the target method according to the class reference relationship between the control class and the target method;
acquiring a target address corresponding to the target method, and searching the target interface document according to the target address;
and updating the interface content in the target interface document according to the files in the control directory or the first target class directory or the second target class directory.
5. The API document management method of claim 4, wherein the updating the interface content in the target interface document according to the files under the control directory or the first target class directory or the second target class directory comprises:
identifying a directory in which the updated file exists;
determining interface contents needing to be updated according to a directory where an updated file exists, wherein the updated interface contents comprise the participating class, the participating class and the target address;
updating the determined updated interface content into the interface content of the target interface document.
6. An API document management apparatus, comprising:
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for acquiring a target address of a target interface if the completion of the creation of a target interface document is detected, and the target interface is an interface defined when the target interface document is created;
the creating unit is used for creating a target method corresponding to the target interface document according to the target address and creating a target class corresponding to the parameters in the target interface document;
and the generating unit is used for calling the target method according to the target class to generate a target program code corresponding to the target interface document.
7. The API document management apparatus according to claim 6, wherein said creating unit includes:
a first creating unit, configured to create a control class according to the target address under a control directory, and create a target method corresponding to the target interface document in the control class;
the second creating unit is used for creating a first target class directory under a parent directory of a control directory and creating a reference class corresponding to a reference field in the target interface document according to the target address under the first target class directory;
and the third creating unit is used for creating a second target class directory under the parent directory of the control directory and creating a reference class corresponding to the reference field in the target interface document according to the target address under the second target class directory.
8. The API document management apparatus according to claim 7, further comprising:
a reference unit, configured to, if a file in the control directory or the first target class directory or the second target class directory has an update, obtain the target method according to a class reference relationship between the control class and the target method;
the searching unit is used for acquiring a target address corresponding to the target method and searching the target interface document according to the target address;
and the updating unit is used for updating the interface content in the target interface document according to the files in the control directory or the first target class directory or the second target class directory.
9. A computer arrangement, characterized in that the computer arrangement comprises a memory having stored thereon a computer program and a processor implementing the method according to any of claims 1-5 when executing the computer program.
10. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when being executed by a processor, is adapted to carry out the method according to any one of claims 1-5.
CN202010620487.9A 2020-06-30 2020-06-30 API document management method and device, computer equipment and storage medium Pending CN111767070A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010620487.9A CN111767070A (en) 2020-06-30 2020-06-30 API document management method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010620487.9A CN111767070A (en) 2020-06-30 2020-06-30 API document management method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111767070A true CN111767070A (en) 2020-10-13

Family

ID=72724213

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010620487.9A Pending CN111767070A (en) 2020-06-30 2020-06-30 API document management method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111767070A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118276903A (en) * 2024-05-29 2024-07-02 暗物智能科技(广州)有限公司 Application programming interface API management method, device, equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN107515771A (en) * 2017-09-07 2017-12-26 蓝海天网科技有限公司 API document structure tree method and system based on SpringMVC
CN109614102A (en) * 2018-10-09 2019-04-12 平安科技(深圳)有限公司 Code automatic generation method, device, electronic equipment and storage medium
CN109683886A (en) * 2018-11-28 2019-04-26 国云科技股份有限公司 A kind of diversification interface document generation method
CN110471698A (en) * 2019-07-29 2019-11-19 深圳数位传媒科技有限公司 The generation method and device, storage medium and computer equipment of API document

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
CN107515771A (en) * 2017-09-07 2017-12-26 蓝海天网科技有限公司 API document structure tree method and system based on SpringMVC
CN109614102A (en) * 2018-10-09 2019-04-12 平安科技(深圳)有限公司 Code automatic generation method, device, electronic equipment and storage medium
CN109683886A (en) * 2018-11-28 2019-04-26 国云科技股份有限公司 A kind of diversification interface document generation method
CN110471698A (en) * 2019-07-29 2019-11-19 深圳数位传媒科技有限公司 The generation method and device, storage medium and computer equipment of API document

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118276903A (en) * 2024-05-29 2024-07-02 暗物智能科技(广州)有限公司 Application programming interface API management method, device, equipment and medium

Similar Documents

Publication Publication Date Title
RU2412474C2 (en) Method and system for creating, storing, managing and consuming culture specific data
US7653880B2 (en) Application of data-binding mechanism to perform command binding
US7844948B2 (en) Maintaining multiple valid concurrent serialized object versions
US9146735B2 (en) Associating workflows with code sections in a document control system
CN108762743B (en) Data table operation code generation method and device
US20110302565A1 (en) Implicit workspace dependencies
US10346159B2 (en) Systems and methods for software scanning tool
US8676768B1 (en) Collaborative modeling environment
US20230161746A1 (en) Data pipeline branching
US9483384B2 (en) Generation of software test code
US11475135B2 (en) Orchestration of vulnerability scanning and issue tracking for version control technology
CN111026568A (en) Data and task relation construction method and device, computer equipment and storage medium
US11397569B2 (en) Deploying micro frontends to different clusters from a single repository
US20220237057A1 (en) Code consolidation system
CN115576600A (en) Code change-based difference processing method and device, terminal and storage medium
CN116560683A (en) Software updating method, device, equipment and storage medium
CN111767070A (en) API document management method and device, computer equipment and storage medium
CN113721973A (en) Configuration file generation method, device, equipment and medium
TW201314482A (en) Method for analyzing dependency of target object
US10338891B2 (en) Migration between model elements of different types in a modeling environment
US10599424B2 (en) Committed program-code management
WO2022257588A1 (en) Code processing method and system, computer cluster, medium and program product
US7669200B2 (en) Resizing an install image
CN113806327A (en) Database design method and device and related equipment
US11775292B1 (en) Completing partially constructed designs and creating new designs based on existing designs

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20201013

RJ01 Rejection of invention patent application after publication