Interface document generation method and device, storage medium, and electronic device

In the project development separated by front and back end, the application process attribute information is obtained according to the container's running status and the interface document request address is automatically generated, which solves the problem of low efficiency in interface document generation in the existing technology, and realizes interface documents for different application processes Unified management and efficient generation.

CN113791819BActive Publication Date: 2025-02-21JINGDONG ALLIANZ GENERAL INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110244167.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-05
Publication Date
2025-02-21
Estimated Expiration
2041-03-05

AI Technical Summary

Technical Problem

During the project development process of separate front-end and back-end projects, it is difficult for the existing technology to achieve unified management and generation of interface documents of different application processes, resulting in low efficiency in interface documents generation.

Method used

By determining the target container based on the running status of the container, obtaining application process and its attribute information, generating configuration information, and then automatically generating interface document request addresses, and using document generation tools to generate interface documents in a unified format.

Benefits of technology

It realizes unified management and generation of interface documents of each application process, improves the processing efficiency of interface documents, and automatically generates interface documents without the need for maintenance personnel to change configuration information when the application service is online, improving the efficiency of interface documents generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113791819B_ABST
    Figure CN113791819B_ABST
Patent Text Reader

Abstract

The present disclosure is about an interface document generation method, an interface document generation device, a storage medium and an electronic device, and relates to the field of computer technology. The method comprises: determining at least one first target container according to the running state of the container, wherein the current state of the first target container is the running state; obtaining the application process running in the first target container, and the attribute information of the application process, and generating first configuration information corresponding to the application process according to the attribute information; generating a first request address according to the first configuration information, and reading the first request address through a document generation tool to obtain an interface document corresponding to the application process. The present disclosure improves the generation efficiency of the interface document.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In the process of project development with front-end and back-end separation, in order to facilitate communication between front-end and back-end engineers and review and maintenance by later maintenance personnel, front-end and back-end engineers need to jointly define the interface and write interface documents.

[0003] At present, the preparation of interface documents has evolved from manual preparation to programming to implement interface documents that comply with the openAPI 2.0 (open Application Programming Interface) specification. However, the following problems still exist: on the one hand, when the application includes different application processes, relevant personnel need to record the addresses of interface documents corresponding to different application services, and cannot perform unified operations on the interface documents corresponding to each application process; on the other hand, when the application is launched, maintenance personnel need to change the configuration information corresponding to the application process to ensure the normal launch of the application and the generation of the interface document, resulting in low efficiency in interface document generation.

[0004] Therefore, it is necessary to provide a new interface document generation method.

[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present invention, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention

[0006] The purpose of the present invention is to provide an interface document generation method, an interface document generation device, a storage medium and an electronic device, thereby at least to a certain extent overcoming the problem of low interface document generation efficiency caused by the limitations and defects of related technologies.

[0007] According to one aspect of the present disclosure, there is provided a method for generating an interface document, comprising:

[0008] Determine at least one first target container according to the running state of the container, wherein the current state of the first target container is a running state;

[0009] Acquire an application process running in the first target container and attribute information of the application process, and generate first configuration information corresponding to the application process according to the attribute information;

[0010] A first request address is generated according to the first configuration information, and the first request address is read by a document generation tool to obtain an interface document corresponding to the application process.

[0011] In an exemplary embodiment of the present disclosure, the interface document generation method further includes:

[0012] Acquire, from a preset configuration center, the second target container whose current state is a running state, and second configuration information of the application process running in the second target container;

[0013] A second request address is generated according to the second configuration information, and the second request address is read by the document generation tool to obtain an interface document corresponding to the second configuration information.

[0014] In an exemplary embodiment of the present disclosure, obtaining an application process running in the first target container and attribute information of the application process, and generating first configuration information corresponding to the application process according to the attribute information includes:

[0015] Obtain the namespace and name of the application process and the name of the container set where the application process is located;

[0016] First configuration information corresponding to the application process is generated according to the namespace, the name, and the name of the container set where the application process is located.

[0017] In an exemplary embodiment of the present disclosure, a first request address is generated according to the first configuration information, and the first request address is read by a document generation tool to obtain an interface document corresponding to the application process, including:

[0018] Generate the first request address according to the namespace, the name, and the name of the container set where the application process is located included in the first configuration information;

[0019] According to the first request address, an interface document corresponding to the application process is generated by the document generation tool.

[0020] In an exemplary embodiment of the present disclosure, generating an interface document corresponding to the application process by the document generation tool according to the first request address includes:

[0021] Introducing the dependency of the document generation tool into the project object model of the application process;

[0022] Based on the dependency, the interface data included in the application process is read, and the interface document corresponding to the application process is generated using the interface data.

[0023] In an exemplary embodiment of the present disclosure, an interface document corresponding to the application process is generated by the document generation tool, and the interface document generation method further includes:

[0024] Introducing document enhancement annotations in a framework configuration file of the application process;

[0025] The interface document is enhanced by setting the properties corresponding to the document enhancement annotation.

[0026] In an exemplary embodiment of the present disclosure, generating a second request address according to the second configuration information, and reading the second request address by the document generation tool includes:

[0027] Traversing the third configuration information of the target container in the running state included in the document generation tool, and determining whether the third configuration information is the same as the second configuration information;

[0028] When the third configuration information is different from the second configuration information, modifying the third configuration information to the configuration information included in the second configuration information, and generating a second request address recognizable by the document generation tool according to the modified third configuration information;

[0029] When the third configuration information is the same as the second configuration information, the third configuration information is converted into a second request address recognizable by the document generation tool.

[0030] According to one aspect of the present disclosure, there is provided an interface document generating device, comprising:

[0031] a target container acquisition module, configured to determine at least one first target container according to the running state of the container, wherein the current state of the first target container is the running state;

[0032] a first configuration information generating module, configured to obtain an application process running in the first target container and attribute information of the application process, and generate first configuration information corresponding to the application process according to the attribute information;

[0033] The interface document generation module is used to generate a first request address according to the first configuration information, and read the first request address through a document generation tool to obtain an interface document corresponding to the application process.

[0034] According to one aspect of the present disclosure, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the interface document generation method described in any one of the above is implemented.

[0035] According to one aspect of the present disclosure, there is provided an electronic device, including:

[0036] Processor; and

[0037] A memory, configured to store executable instructions of the processor;

[0038] Wherein, the processor is configured to execute any one of the above-mentioned interface document generation methods by executing the executable instructions.

[0039] The embodiment of the present disclosure provides an interface document generation method. On the one hand, at least one first target container is determined according to the running state of the container, wherein the current state of the first target container is the running state; the application process running in the first target container and the attribute information of the application process are obtained, and first configuration information corresponding to the application process is generated according to the attribute information; a first request address is generated according to the first configuration information, and the first request address is read by a document generation tool to obtain an interface document corresponding to the application process. Since the first request address is generated according to the first configuration information, the interface document corresponding to the application process is generated by the document generation tool using the first request address, so that the interface documents of each application process can be uniformly managed, which solves the problem in the prior art that the relevant technical personnel need to record the addresses of the interface documents corresponding to different application services before the interface documents can be uniformly processed, thereby improving the processing efficiency of the interface document; on the other hand, when the application service is online, that is, after the target container with the current state of the running state is obtained, the corresponding interface document can be automatically generated according to the first request address of the application process running in the target container, without the need for maintenance personnel to change the configuration information corresponding to the application service, thereby improving the efficiency of interface document generation.

[0040] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present invention, and together with the specification are used to explain the principles of the present invention. Obviously, the accompanying drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0042] Figure 1 A flowchart of a method for generating an interface document according to an exemplary embodiment of the present invention is schematically shown.

[0043] Figure 2 A block diagram of an interface document generation system according to an exemplary embodiment of the present invention is schematically shown.

[0044] Figure 3 The following schematically shows a flow chart of a method for generating an interface document for an online application service according to an exemplary embodiment of the present invention.

[0045] Figure 4A flow chart of a method for generating a second request address according to second configuration information according to an exemplary embodiment of the present invention is schematically shown.

[0046] Figure 5 A flowchart of a method for generating first configuration information corresponding to an application process according to attribute information of the application process according to an exemplary embodiment of the present invention is schematically shown.

[0047] Figure 6 The following schematically shows a flow chart of a method for a document generation tool to generate an interface document according to a request address according to an exemplary embodiment of the present invention.

[0048] Figure 7 A flow chart schematically illustrates a method for enabling enhanced functions for an interface document according to an exemplary embodiment of the present invention.

[0049] Figure 8 A flowchart of a method for generating an interface document according to an exemplary embodiment of the present invention is schematically output.

[0050] Fig. 9 A block diagram schematically shows a device for generating an interface document according to an exemplary embodiment of the present invention.

[0051] Fig.10 An electronic device for implementing the above-mentioned interface document generating method according to an exemplary embodiment of the present invention is schematically shown. DETAILED DESCRIPTION

[0052] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present invention will be more comprehensive and complete, and the concept of the example embodiments will be fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solutions of the present invention may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present invention.

[0053] In addition, the accompanying drawings are only schematic illustrations of the present invention and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0054] At present, in software development, the writing of back-end design documents has become an indispensable task for R&D personnel. The writing of related interface design documents has evolved from manual writing in the beginning to programming to implement interface documents that comply with the OpenAPI 2.0 specification, which has liberated some of the document writing work of R&D personnel to a certain extent.

[0055] In most of the current application software, the document definition of each application service included in the application software can be implemented through Swagger2 (Swagger is a standardized and complete framework for generating, describing, calling and visualizing web services, among which Swagger2 supports OpenAPI 2.0 development specifications). However, the interface documents corresponding to different application services cannot be managed uniformly; offline interface documents need to be provided in some application services, and the current Swagger-UI (document interface provided for the Swagger2 framework, used for front-end UI display and operation) does not support the export of offline documents; when the configuration file of the application service changes, the hot release of the application service cannot be realized; when the application service is online, the operation and maintenance personnel need to change the configuration of the application service to ensure the normal online launch of the application service and the generation of interface documents.

[0056] Based on one or more of the above problems, this example implementation first provides an interface document generation method, which can be run on a server, server cluster or cloud server, etc. Of course, those skilled in the art can also run the method of the present invention on other platforms as required, and this example implementation does not specifically limit this. Figure 1 As shown, the interface document generation method may include the following steps:

[0057] Step S110. Determine at least one first target container according to the running state of the container, wherein the current state of the first target container is the running state;

[0058] Step S120. Acquire the application process running in the first target container and attribute information of the application process, and generate first configuration information corresponding to the application process according to the attribute information;

[0059] Step S130: Generate a first request address according to the first configuration information, and read the first request address through a document generation tool to obtain an interface document corresponding to the application process.

[0060] The above-mentioned interface document generation method, on the one hand, determines at least one first target container according to the running state of the container, wherein the current state of the first target container is the running state; obtains the application process running in the first target container and the attribute information of the application process, and generates the first configuration information corresponding to the application process according to the attribute information; generates a first request address according to the first configuration information, and reads the first request address through a document generation tool to obtain the interface document corresponding to the application process. Since the first request address is generated according to the first configuration information, the interface document corresponding to the application process is generated through the document generation tool using the first request address, so that the interface documents of each application process can be uniformly managed, which solves the problem in the prior art that the relevant technical personnel need to record the addresses of the interface documents corresponding to different application services before the interface documents can be uniformly operated and processed, thereby improving the processing efficiency of the interface document; on the other hand, when the application service is online, that is, after obtaining the target container whose current state is the running state, the corresponding interface document can be automatically generated according to the first request address of the application process running in the target container, without the need for maintenance personnel to change the configuration information corresponding to the application service, thereby improving the efficiency of interface document generation.

[0061] The following is a detailed explanation and description of each step involved in the interface document generation method of the exemplary embodiment of the present disclosure.

[0062] First, the application scenarios and invention objectives of the exemplary embodiments of the present disclosure are explained and illustrated.

[0063] Specifically, the example embodiments of the present disclosure can be used in an application system with separated front-end and back-end, and are mainly used to automatically identify the online and offline status of application services in the application system. When an application service is online, the corresponding interface document can be automatically generated based on the attribute information of the application service. In addition, the interface documents of the application services that have been online are uniformly managed.

[0064] The example embodiment of the present disclosure is based on the target container in the running state, analyzes it to obtain the configuration information of the application process running in the target container, obtains the request address of the application process according to the configuration information, and automatically generates the interface document of the application process based on the request address, thereby improving the efficiency of generating the interface document. The specific reasons are as follows: On the one hand, by generating the document corresponding to the application process through the document generation tool, an interface document with a unified format can be generated for the application service that has been launched, thereby realizing the unified management of the interface document; on the other hand, when the application service is launched, the interface document is directly generated according to the request address of the newly launched application service, without the need for relevant personnel to modify the configuration file of the application service, thereby improving the efficiency of generating the interface document of the application service.

[0065] Next, the interface document generation system involved in the exemplary embodiment of the present disclosure is explained and illustrated. Figure 2 As shown, the interface document generation system may include: a configuration center 210 and a document aggregation center 220. Among them, the configuration center adopts Apollo, which can centrally manage the configurations of different application environments and different clusters. After the configuration is modified, it can be pushed to the application end in real time, which is used to uniformly manage the configuration files of the application processes that have been launched. When the configuration file of the application process is modified, the modified configuration file is directly sent to the document aggregation center 220 to generate the interface document of the application process according to the latest configuration file; the document aggregation center 220 is connected to the configuration center 210 network, and may include a container orchestration tool 221 and a document generation tool 222, wherein the container orchestration tool is kubernetes (k8s for short, used to manage multiple hosts in the cloud platform Containerized applications on it) are used to monitor application services and automatically identify the online and offline of application services. When the application service is online, configuration information is generated according to the attribute information of the application process corresponding to the application service, and then the configuration information is converted into a request address, and the request address is sent to the document generation tool 222; the document generation tool 222 is connected to the container orchestration tool network, which is knife4jAggregation (microservice aggregation middleware), which is used to receive the request address sent by the container orchestration tool 221, and generate an interface document of the application process according to the request address. Users can view the interface document on the display page of the application process and download it offline.

[0066] The following will be combined Figure 2 Steps S110 to S130 are explained and described.

[0067] In step S110, at least one first target container is determined according to the running state of the container, wherein the current state of the target container is the running state.

[0068] In this example implementation, in the container orchestration tool k8s, a pod (made of one or more containers, which is the smallest atomic unit that can be scheduled in k8s) represents a process running in the cluster. The pod encapsulates the container. Therefore, the running state of the container can be the life cycle of the pod. The life cycle of the pod can include: suspended, running, successful, reported, and unknown. Among them, suspended means that the pod has been created, but has not been scheduled, or is still in the process of downloading the image from the warehouse; running means that the pod has been scheduled to a certain node and all containers have been created; successful means that all containers in the pod have been successfully terminated and will not be restarted; failed means that all containers in the pod have been terminated, and at least one container is terminated due to failure, that is, the container exits with a non-zero status or is terminated by the system; unknown means that the status of the pod cannot be obtained for some reason, usually because of a failure to communicate with the host where the pod is located. When the application service is online, the state of the target container corresponding to the application service is running. Therefore, in order to automatically generate the interface document of the newly launched application service, it is first necessary to obtain the target container whose current state is running.

[0069] For the application services that have been launched, you can obtain the corresponding configuration information through the configuration center, generate the request address based on the configuration information, and then generate the corresponding interface document based on the request address. For details, refer to Figure 3 As shown, for an application service that has been launched, the interface document generation method may further include step S310 and step S320:

[0070] In step S310, the second target container whose current state is a running state and second configuration information of the application process running in the second target container are obtained from a preset configuration center;

[0071] In step S320, a second request address is generated according to the second configuration information, and the second request address is read by the document generation tool to obtain an interface document corresponding to the second configuration information.

[0072] Step S310 and step S320 will be explained and illustrated below. Specifically, first obtain the configuration file of the application process that has been online and is still providing services in the configuration center Apollo, that is, obtain the second target container whose current state is the running state, and the configuration information of the application process running in the second target container, wherein the configuration information of the application process may include: the name of the application service corresponding to the application process and the OpenAPI interface address (the address of the application service corresponding to the application process); after obtaining the configuration information of the application process, the request address of the application service interface document can be generated according to the configuration information; the document generation tool knife4jAggregation generates an interface document corresponding to the application process according to the request address of the interface document.

[0073] For further reference, Figure 4 As shown, generating a second request address according to the second configuration information and reading the second request address by the document generation tool may include steps S410 to S430:

[0074] In step S410, traverse the third configuration information of the target container in the running state included in the document generation tool to determine whether the third configuration information is the same as the second configuration information;

[0075] In step S420, when the third configuration information is different from the second configuration information, the third configuration information is modified to the configuration information included in the second configuration information, and a second request address recognizable by the document generation tool is generated according to the modified third configuration information;

[0076] In step S430, when the third configuration information is the same as the second configuration information, the third configuration information is converted into a second request address recognizable by the document generation tool.

[0077] Steps S410 to S430 will be explained and illustrated below. Specifically, for the application services that have been launched, the document generation tool knife4jAggregation uses an internal API configuration set to complete the interface document display. After obtaining the configuration file of the target container in the running state from the Apollo configuration center, it is necessary to traverse the interface document configuration set of the document generation tool to determine whether the configuration information of the second target container in the running state is the same as the configuration information of the target container included in the document generation tool. If they are the same, the configuration information of the target container included in the document generation tool is used to generate a different interface document request address for the document generation tool; when the configuration information obtained by the configuration center is different from the configuration information included in the document generation tool, the configuration information included in the document generation tool is updated, and the interface document request address is generated according to the updated configuration information.

[0078] In step S120, the application process running in the first target container and attribute information of the application process are obtained, and first configuration information corresponding to the application process is generated according to the attribute information.

[0079] In this example embodiment, reference Figure 5 As shown, obtaining the application process running in the first target container and the attribute information of the application process, and generating first configuration information corresponding to the application process according to the attribute information may include step S510 and step S520:

[0080] In step S510, the namespace and name of the application process and the name of the container set where the application process is located are obtained;

[0081] In step S520, first configuration information corresponding to the application process is generated according to the namespace, the name, and the name of the container set where the application process is located.

[0082] Below, step S510 and step S520 will be explained and illustrated. Specifically, the namespace of the application process refers to a scope. The scope means that when accessing the pod by establishing a service, if the namespace of the service is not specified correctly, it cannot be associated with the pod through the label; the name of the container set where the application process is located is the name of the pod where the application process is located. Specifically, first, the namespace, name and name of the container set where the application process is located are obtained through the interface KubernetesJava Client provided by the service orchestration tool k8s, and then the first configuration information corresponding to the application process is generated according to the obtained attribute information.

[0083] In step S130, a first request address is generated according to the first configuration information, and the first request address is read by a document generation tool to obtain an interface document corresponding to the application process.

[0084] Among them, the first request address is the request address of the interface document of the application service. The document generation tool is knife4jAggregation. The document generation tool provides the knife4j-aggregation-spring-boot-starter component, which is a starter based on the Spring Boot system (the starter is responsible for configuring the configuration and related dependencies related to spring integration). It provides the following capabilities: allowing all Spring Boot-based web systems to have the ability to easily aggregate OpenAPI, while being compatible with the OpenAPI2 specification and the OpenAPI3 specification. The interface document generated by the document generation tool can be displayed through the query request of the user client.

[0085] In this example embodiment, a first request address is generated according to the first configuration information, and the first request address is read by a document generation tool to obtain an interface document corresponding to the application process, including:

[0086] Generate the first request address according to the namespace, the name, and the name of the container set where the application process is located included in the first configuration information;

[0087] According to the first request address, an interface document corresponding to the application process is generated by the document generation tool.

[0088] Specifically, an interface document request address, that is, a first request address, can be generated according to the configuration information of the application process, wherein the interface document request address includes the namespace of the application process, the name of the application process, and the name of the pod where the application process is located, and the first request address can be recognized by the document generation tool; after obtaining the request address of the interface document, the document generation tool reads the request method, URL (Uniform Resource Locator), request parameters, and return parameters of the application process according to the request address, and generates an interface document according to the request method, URL, request parameters, and return parameters of the application process.

[0089] For further reference, Figure 6 As shown, the document generation tool generates an interface document according to the request address, which may include steps S610 and S620:

[0090] In step S610, the dependency of the document generation tool is introduced into the project object model of the application process;

[0091] In step S620, based on the dependency, the interface data included in the application process is read, and an interface document corresponding to the application process is generated using the interface data.

[0092] In the following, step S620 and step S620 are explained and illustrated. Specifically, the Project Object Model (POM) is a file in the project, represented by XML, named pom.xml, which is used to manage source code, configuration files, project URLs, and project dependencies, etc. The dependency of knife4j is introduced in the pom.xml file, which can be specifically: <artifactid> knife4j-spring-boot-starter< / artifactid> ; Secondly, create a Swagger configuration file, which includes annotations @EnableSwagger2 and @EnableKnife4j. The annotation @EnableSwagger2 is the Swagger annotation provided by the Springfox-swagger framework and must be added; the annotation @EnableKnife4j is an enhanced annotation provided by knife4j. This annotation must be added when the enhanced function is needed, otherwise it does not need to be added; after adding the annotation @EnableSwagger2, the interface data included in the application process can be obtained, where the interface data can include: the request method, URL, request parameters, and return parameters of the application process; finally, generate an interface document based on the interface data.

[0093] Further, refer to Figure 7 As shown, when it is necessary to enable enhanced functions for the interface document, the interface document generation method may include steps S710 and S720:

[0094] In step S710, document enhancement annotations are introduced into the framework configuration file of the application process;

[0095] In step S720, the interface document is enhanced by setting properties corresponding to the document enhancement annotation.

[0096] Step S710 and step S720 are explained and illustrated below. Specifically, the framework configuration file of the application process is a Swagger configuration file, the annotation for document enhancement is @EnableKnife4j, and the document enhancement includes one or more of request parameter cache, dynamic debugging parameters, and offline documents, wherein the property corresponding to the request parameter cache is knife4j.setting.enableRequestCache, the default value is true, the property corresponding to dynamic debugging is knife4j.setting.enableDynamicParameter, the default value is false, and the offline document can include exporting Markdown (a lightweight markup language) and offline HTML (Hyper TextMarkup Language), and the property corresponding to exporting Markdown is knife4j.setting.homeCustomLocation.

[0097] The interface document generation method and interface document generation system provided by the example embodiments of the present disclosure have at least the following advantages: on the one hand, for an application service that has been launched, by obtaining corresponding configuration information and generating an interface document request address according to the configuration information, a document generation tool generates an interface document in a unified format through the interface document request address, thereby improving the efficiency of interface document generation; on the other hand, when an application service is launched, an interface document request address can be generated according to the attribute information of the application service, and an interface document can be generated according to the interface document request address, without the need for maintenance personnel to change the configuration information of the application service, thereby improving the efficiency of interface document generation.

[0098] The following, combined Figure 8 The interface document generation method of the exemplary embodiment of the present disclosure is further explained and illustrated. The interface document generation method may include the following steps:

[0099] Step S810. Determine whether the application service is a newly launched service;

[0100] Step S820. When the application service is a newly launched service, obtain a target container whose current state is running;

[0101] Step S822. Acquire the application process running in the target container whose current state is running, and the attribute information of the application process;

[0102] Step S824. Generate first configuration information according to the attribute information of the application process, and generate a request address according to the first configuration information;

[0103] Step S830. When the application service is an online service, a target container whose current state is running is obtained from the configuration center;

[0104] Step S832. Obtain configuration information of the application process running in the target container;

[0105] Step S834. Generate a request address according to the configuration information of the application process running in the target container;

[0106] Step S840. The document generation tool reads the request address and generates an interface document according to the interface data of the application process corresponding to the request address.

[0107] The exemplary embodiment of the present disclosure also provides an interface document generation device, referring to Fig. 9 As shown, the interface document generation device may include: a target container acquisition module 910, a first configuration information generation module 920 and an interface document generation module 930. Among them:

[0108] A target container acquisition module 910 is used to determine at least one first target container according to the running state of the container, wherein the current state of the first target container is the running state;

[0109] A first configuration information generating module 920 is used to obtain the application process running in the first target container and the attribute information of the application process, and generate first configuration information corresponding to the application process according to the attribute information;

[0110] The interface document generation module 930 is used to generate a first request address according to the first configuration information, and read the first request address through a document generation tool to obtain an interface document corresponding to the application process.

[0111] In an exemplary embodiment of the present disclosure, the interface document generation method further includes:

[0112] Acquire, from a preset configuration center, the second target container whose current state is a running state, and second configuration information of the application process running in the second target container;

[0113] A second request address is generated according to the second configuration information, and the second request address is read by the document generation tool to obtain an interface document corresponding to the second configuration information.

[0114] In an exemplary embodiment of the present disclosure, obtaining an application process running in the first target container and attribute information of the application process, and generating first configuration information corresponding to the application process according to the attribute information includes:

[0115] Obtain the namespace and name of the application process and the name of the container set where the application process is located;

[0116] First configuration information corresponding to the application process is generated according to the namespace, the name, and the name of the container set where the application process is located.

[0117] In an exemplary embodiment of the present disclosure, a first request address is generated according to the first configuration information, and the first request address is read by a document generation tool to obtain an interface document corresponding to the application process, including:

[0118] Generate the first request address according to the namespace, the name and the name of the container set where the application process is located included in the first configuration information;

[0119] According to the first request address, an interface document corresponding to the application process is generated by the document generation tool.

[0120] In an exemplary embodiment of the present disclosure, generating an interface document corresponding to the application process by the document generation tool according to the first request address includes:

[0121] Introducing the dependency of the document generation tool into the project object model of the application process;

[0122] Based on the dependency, the interface data included in the application process is read, and the interface document corresponding to the application process is generated using the interface data.

[0123] In an exemplary embodiment of the present disclosure, an interface document corresponding to the application process is generated by the document generation tool, and the interface document generation method further includes:

[0124] Introducing document enhancement annotations in a framework configuration file of the application process;

[0125] The interface document is enhanced by setting the properties corresponding to the document enhancement annotation.

[0126] In an exemplary embodiment of the present disclosure, generating a second request address according to the second configuration information, and reading the second request address by the document generation tool includes:

[0127] Traversing the third configuration information of the target container in the running state included in the document generation tool, and determining whether the third configuration information is the same as the second configuration information;

[0128] When the third configuration information is different from the second configuration information, modifying the third configuration information to the configuration information included in the second configuration information, and generating a second request address recognizable by the document generation tool according to the modified third configuration information;

[0129] When the third configuration information is the same as the second configuration information, the third configuration information is converted into a second request address recognizable by the document generation tool.

[0130] The specific details of each module in the above-mentioned interface document generation device have been described in detail in the corresponding interface document generation method, so they will not be repeated here.

[0131] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0132] In addition, although the steps of the method of the present invention are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0133] In an exemplary embodiment of the present invention, an electronic device capable of implementing the above data conversion method is also provided.

[0134] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0135] Reference below Fig.10 The electronic device 1000 according to this embodiment of the present invention will be described. Fig.10 The electronic device 1000 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0136] like Fig.10As shown, the electronic device is in the form of a general computing device. The components of the electronic device may include, but are not limited to: the at least one processing unit 1010, the at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), and a display unit 1040.

[0137] The storage unit stores program codes, which can be executed by the processing unit 1010, so that the processing unit 1010 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 1010 can perform the following steps: Figure 1 The step S110 shown in the figure is: determining at least one first target container according to the running state of the container, wherein the current state of the first target container is the running state; step S120: acquiring the application process running in the first target container and the attribute information of the application process, and generating first configuration information corresponding to the application process according to the attribute information; step S130: generating a first request address according to the first configuration information, and reading the first request address through a document generation tool to obtain an interface document corresponding to the application process.

[0138] The storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 10201 and / or a cache storage unit 10202 , and may further include a read-only storage unit (ROM) 10203 .

[0139] The storage unit 1020 may also include a program / utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0140] Bus 1030 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0141] The electronic device 1000 may also communicate with one or more external devices 1100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or may communicate with any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1050. Furthermore, the electronic device 1000 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1060. As shown, the network adapter 1060 communicates with other modules of the electronic device 1000 via a bus 1030. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0142] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present invention.

[0143] In an exemplary embodiment of the present invention, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of this specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to perform the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification.

[0144] The program product for implementing the above method according to an embodiment of the present invention may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0145] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0146] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0147] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0148] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0149] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0150] Other embodiments of the invention will readily occur to those skilled in the art after considering the specification and practicing the invention invented herein. This application is intended to cover any variations, uses or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art that are not invented by the present invention. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the claims.

Claims

1. A method for generating an interface document, characterized in that: include: Determine at least one first target container according to the running state of the container, wherein the current state of the first target container is a running state; Acquire an application process running in the first target container and attribute information of the application process, and generate first configuration information corresponding to the application process according to the attribute information; Generate a first request address according to the first configuration information, and read the first request address through a document generation tool to obtain an interface document corresponding to the application process; Acquire the second target container whose current state is a running state and second configuration information of the application process running in the second target container from a preset configuration center; generate a second request address according to the second configuration information, read the second request address through the document generation tool, and obtain an interface document corresponding to the second configuration information; Traverse the third configuration information of the target container in the running state included in the document generation tool, and determine whether the third configuration information is the same as the second configuration information; when the third configuration information is different from the second configuration information, modify the third configuration information to the configuration information included in the second configuration information, and generate a second request address recognizable by the document generation tool according to the modified third configuration information; when the third configuration information is the same as the second configuration information, convert the third configuration information into a second request address recognizable by the document generation tool.

2. The interface document generation method according to claim 1, characterized in that: Acquiring an application process running in the first target container and attribute information of the application process, and generating first configuration information corresponding to the application process according to the attribute information, including: Obtain the namespace and name of the application process and the name of the container set where the application process is located; First configuration information corresponding to the application process is generated according to the namespace, the name, and the name of the container set where the application process is located.

3. The interface document generation method according to claim 2, characterized in that: Generate a first request address according to the first configuration information, and read the first request address through a document generation tool to obtain an interface document corresponding to the application process, including: Generate the first request address according to the namespace, the name, and the name of the container set where the application process is located included in the first configuration information; According to the first request address, an interface document corresponding to the application process is generated by the document generation tool.

4. The method for generating an interface document according to claim 3, characterized in that: Generating an interface document corresponding to the application process by the document generation tool according to the first request address includes: Introducing the dependency of the document generation tool into the project object model of the application process; Based on the dependency, interface data included in the application process is read, and an interface document corresponding to the application process is generated using the interface data.

5. The method for generating an interface document according to claim 4, characterized in that: Generate an interface document corresponding to the application process by using the document generation tool, and the interface document generation method further includes: Introducing document enhancement annotations in a framework configuration file of the application process; The interface document is enhanced by setting the properties corresponding to the document enhancement annotation.

6. An interface document generating device, characterized in that: include: A target container acquisition module, configured to determine at least one first target container according to the running state of the container, wherein the current state of the first target container is the running state; a first configuration information generating module, configured to obtain an application process running in the first target container and attribute information of the application process, and generate first configuration information corresponding to the application process according to the attribute information; An interface document generation module, configured to generate a first request address according to the first configuration information, and read the first request address through a document generation tool to obtain an interface document corresponding to the application process; Acquire the second target container whose current state is a running state and second configuration information of the application process running in the second target container from a preset configuration center; generate a second request address according to the second configuration information, read the second request address through the document generation tool, and obtain an interface document corresponding to the second configuration information; Traverse the third configuration information of the target container in the running state included in the document generation tool, and determine whether the third configuration information is the same as the second configuration information; when the third configuration information is different from the second configuration information, modify the third configuration information to the configuration information included in the second configuration information, and generate a second request address recognizable by the document generation tool according to the modified third configuration information; when the third configuration information is the same as the second configuration information, convert the third configuration information into a second request address recognizable by the document generation tool.

7. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the interface document generation method described in any one of claims 1 to 5 is implemented.

8. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the interface document generation method described in any one of claims 1-5 by executing the executable instructions.

Citation Information

Patent Citations

  • Interface document generation method and device, electronic equipment and storage medium

    CN110806863A

  • Real-time counting method and device for information assets in container and computing equipment

    CN111737089A