A method and device for processing Proto files
By extracting and converting the interface information and comments in the Proto file, the problem of unreadable Proto files in unsupported systems is solved, and the annotated gRPC interface document can be directly viewed in the Yapi system, improving development and testing efficiency.
Patent Information
- Application Number
- CN202210382482.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-12
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-04-12
AI Technical Summary
In the existing technology, Proto files that use gRPC for communication cannot directly obtain their contents in systems that do not support Proto files, making it difficult for developers and testers to understand the document content and reducing work efficiency.
By extracting the interface information and annotations in the Proto file, storing them in JSON file format, and filling them into supported data formats, they can be parsed and viewed in other systems.
It enables users in systems that do not support Proto file systems to directly obtain the contents of Proto files, which improves document readability and processing efficiency, especially in regression testing, which significantly improves efficiency.
Smart Images

Figure CN114816246B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text processing, and in particular to a method and device for processing Proto files. Background Art
[0002] gRPC (gRPC Remote Procedure Calls) is an open source remote procedure call system initiated by Google. The system is based on HTTP / 2 protocol transmission. When the user-edited document uses gRPC for communication, the content in the document has no annotations or specific meanings. The user who receives the document performs other operations based on the document. Since the content in the document has no annotations or specific meanings, it is difficult for the user who receives the document to understand the document content, which reduces work efficiency. For example, developers use gRPC for communication and deliver the developed code files to testers. When the testers perform regression tests and other tests, because the fields in the code files are not labeled with meanings, testers encounter resistance when executing the test process, which reduces work efficiency.
[0003] In the prior art, the editing tool protoc is used to obtain the relevant parameters and annotations of the document transmitted through gRPC communication, but the editing tool protoc forms a proto document after editing, and the industry usually uses other systems. Taking the Yapi system as an example, the proto document is incompatible with the document format that can be viewed by the Yapi system. People who use the Yapi document still cannot view the content in the proto document, as well as the annotations or specific meanings corresponding to the document content. Especially for testers, even if the developer has annotated and explained the fields in the code file in the code file, the tester using the Yapi system still cannot view the developer's annotations and explanations.
[0004] Therefore, a method for processing Proto files is needed so that users using other systems can directly obtain the content of the Proto files. Summary of the invention
[0005] In view of this, the present invention provides a method and device for processing Proto files, which can solve the technical problem that users using other systems cannot directly obtain the content of Proto files.
[0006] The present invention provides a method for processing a Proto file. The method comprises:
[0007] For at least one interface included in the Proto file, extract interface information of each interface and parameters included in each interface;
[0008] Extracting comments corresponding to the parameters included in each interface;
[0009] storing the interface information extracted for each interface, the parameters included in each interface, the extracted parameters, and the comments corresponding to the extracted parameters in a first JSON file in a first data format; and
[0010] The data associated and stored in the first JSON file is filled into a second JSON file having a second data format.
[0011] Optionally, extracting comments corresponding to parameters included in each interface includes:
[0012] Based on the parameter annotation adding format of the Proto file, the annotations corresponding to the parameters of each interface are extracted.
[0013] Optionally, the second data format includes: a data format supported by the Yapi system.
[0014] Optionally, the second JSON file is stored in a pre-specified storage location, wherein the storage location is specified when the user uploads the Proto file.
[0015] Optionally, for at least one interface included in the Proto file, extract comments corresponding to each interface;
[0016] The extracted comments and the corresponding interfaces for each interface are stored in a first JSON file in the first data format; and
[0017] The annotations extracted from the interfaces and the corresponding interfaces stored in association in the first JSON file are also filled into the second JSON file having the second data format.
[0018] The present invention provides a method for processing a Proto file, comprising:
[0019] For at least one interface included in the Proto file, extract interface information of each interface and parameters included in each interface;
[0020] Extracting comments corresponding to the parameters included in each interface;
[0021] The interface information extracted for each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters are associated and stored in a second JSON file in a second data format.
[0022] The present invention provides a processing device for Proto files. The device comprises:
[0023] Information extraction module: configured to extract interface information of each interface and parameters contained in each interface for at least one interface contained in the Proto file;
[0024] Annotation extraction module: configured to extract annotations corresponding to the parameters included in each interface;
[0025] A first storage module: configured to store the interface information extracted for each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters in a first JSON file in a first data format;
[0026] The second storage module is configured to fill the data associated and stored in the first JSON file into a second JSON file having a second data format.
[0027] The present invention provides a storage medium, wherein a plurality of instructions are stored in the storage medium; the plurality of instructions are used for a processor to load and execute the method as described in any of the preceding items.
[0028] The present invention provides a processing device for Proto files. The device comprises:
[0029] Information extraction module: configured to extract interface information of each interface and parameters contained in each interface for at least one interface contained in the Proto file;
[0030] Annotation extraction module: configured to extract annotations corresponding to the parameters included in each interface;
[0031] The second storage module is configured to store the interface information extracted for each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters in a second JSON file in a second data format.
[0032] The present invention provides an electronic device, comprising:
[0033] A processor, which is used to execute multiple instructions;
[0034] A memory for storing a plurality of instructions;
[0035] Wherein, the multiple instructions are used to be stored by the memory, and loaded and executed by the processor as the method described in any of the previous items.
[0036] The present invention enables users of other systems that do not support Proto files, such as the Yapi system, to directly obtain the content of the Proto file. The user uploads the Proto file and specifies the location of the content corresponding to the file in the Yapi system. Then, the user using the Yapi system can directly obtain the content of the Proto file, thereby improving the processing efficiency of the Proto file content.
[0037] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The above and other purposes, features and advantages of the present invention will become more apparent by describing the embodiments of the present invention in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings, the same reference numerals generally represent the same components or steps.
[0039] Figure 1 It is a flowchart of a method provided by an exemplary embodiment of the present invention.
[0040] Figure 2 It is a schematic diagram of the effect of a document with annotations after executing a program provided by an exemplary embodiment of the present invention.
[0041] Figure 3 It is a schematic diagram of specifying a storage location of a converted file provided by an exemplary embodiment of the present invention.
[0042] Figure 4 It is a schematic diagram of the structure of a device provided by an exemplary embodiment of the present invention.
[0043] Figure 5 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0044] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.
[0045] It should be noted that the relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
[0046] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present invention are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.
[0047] It should also be understood that, in the embodiments of the present invention, “plurality” may refer to two or more than two, and “at least one” may refer to one, two or more than two.
[0048] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0049] In addition, the term "and / or" in the present invention is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects before and after are in an "or" relationship.
[0050] It should also be understood that the description of the various embodiments of the present invention focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0051] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0052] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0053] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0054] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0055] Embodiments of the present invention can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0056] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0057] Exemplary Methods
[0058] Figure 1 is a flow chart of a method for processing a Proto file provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices, such as Figure 1 As shown, the following steps are included:
[0059] Step S1: for at least one interface included in the Proto file, extracting interface information of each interface and parameters included in each interface;
[0060] Step S2: extracting annotations corresponding to the parameters included in each interface;
[0061] Step S3: storing the interface information extracted for each interface, the parameters included in each interface, the extracted parameters, and the comments corresponding to the extracted parameters in a first JSON file in a first data format; and
[0062] Step S4: Fill the data associated and stored in the first JSON file into a second JSON file having a second data format.
[0063] The present invention enables users of other systems that do not support Proto files, such as the Yapi system, to directly obtain the content of the Proto file. The user uploads the Proto file and specifies the location of the content corresponding to the file in the Yapi system. Then, the user using the Yapi system can directly obtain the content of the Proto file, thereby improving the processing efficiency of the Proto file content.
[0064] For example, it can automatically import and include comments contained in all Proto files. After the developer completes the development, he uploads the annotated proto file. After clicking upload and specifying the location of the corresponding content in the Yapi system, the gRPC interface document with comments can be seen in the Yapi system. This solves the technical problem that testers cannot see comments from the document after the developer develops when using gRPC communication, which greatly improves the efficiency of testing work, especially the efficiency of regression testing. It solves the problem of document incommunicability between developers and testers caused by gRPC communication. After the developer adds comments to the Proto file as agreed, he can see the annotated document in the Yapi system after uploading the Proto file to the processor, which improves the development efficiency and testing efficiency of using gRPC for communication.
[0065] In step S1, for at least one interface included in the Proto file, interface information of each interface and parameters included in each interface are extracted.
[0066] The Proto file contains at least one interface, such as a method defined in the Proto file. In the Proto file, there is usually illustrative interface information for the defined method, and the defined method usually includes several parameters. For the Proto file, the interface information of each interface of the Proto file and the parameters contained in each interface can be extracted. Here, the first-level correspondence is obtained, that is, the correspondence between the interface information of each interface and the parameters contained in each interface.
[0067] Wherein, step S1 also includes: generating the Proto file according to a preset template, parsing the Proto file based on the template, and extracting interface information of each interface of the Proto file and parameters contained in each interface.
[0068] The step S2: extracting annotations corresponding to the parameters included in each interface.
[0069] The interface usually needs to obtain parameter information to implement the function corresponding to the interface. When the interface corresponds to parameters, the number of parameters is not fixed. In order to improve the readability of the Proto file code, the meaning and purpose of the parameters are usually explained and described in the Proto file, and the annotation information plays the role of explanation and description.
[0070] The following situations exist: the interface has no corresponding parameters, that is, the interface does not contain parameters and therefore has no annotations corresponding to the parameters; the interface has several corresponding parameters, and each parameter corresponding to the interface has an annotation corresponding to the parameter; the interface has several corresponding parameters, and some of the parameters corresponding to the interface have annotations corresponding to the parameters; the interface has several corresponding parameters, and the parameters corresponding to the interface do not have annotations corresponding to the parameters.
[0071] In this embodiment, the annotations corresponding to the parameters contained in each interface are extracted, that is, the interface with parameter annotations, the annotated parameters corresponding to the interface, and the annotations of the parameters are extracted. The extraction of the annotations corresponding to the parameters contained in each interface includes: adding a format for the parameter annotations of the Proto file, and extracting the annotations corresponding to the parameters of each interface. At this time, the second-level correspondence is obtained, that is, the correspondence between the interface with parameter annotations, the annotated parameters corresponding to the interface, and the annotations of the parameters.
[0072] In this embodiment, by forming two layers of correspondence, all parameters included in each interface, as well as the correspondence between the parameters with annotations in each interface and the annotations corresponding to the parameters can be quickly determined, which saves both time and storage space.
[0073] Taking the comments in the Proto file as an example, the comments are set in the Proto file according to the preset template, and the parameters corresponding to the comments and the interfaces in the Proto file corresponding to the parameters are parsed based on the template. Specifically, the Proto file stored in the server is parsed by the server, and the server obtains the comment rules of the Proto file according to the preset template, and parses the parameters corresponding to the comments in the Proto file and the interfaces in the Proto file corresponding to the parameters.
[0074] The step S3: storing the interface information extracted for each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters in a first JSON file in a first data format.
[0075] The interface information extracted from each interface, the parameters contained in each interface, the extracted parameters and the comments corresponding to the extracted parameters are stored as the first JSON file, which is generated by compiling. That is, the two-layer correspondence relationship is stored in the first JSON file.
[0076] The step S4: filling the data associated and stored in the first JSON file into a second JSON file having a second data format.
[0077] Further, the step S4 includes: obtaining the file content of the first JSON file, filling the associated stored data in the first JSON file into the second JSON file, and the second JSON file is in a format that can be parsed by other systems that do not support proto files. For example, the second JSON file is a data format supported by the Yapi system. In other words, the first JSON file is a json intermediate state generated by template parsing of the proto file that depends on gRPC, but does not conform to the Yapi official json template. The first JSON file is parsed and combined into the JSON file format of the Yapi official import document, which is the second JSON file.
[0078] In this embodiment, for example, the first JSON file is obtained from the server, and the content of the first JSON file is parsed, wherein the content of the first JSON file includes the interface information extracted for each interface and the parameters contained in each interface, as well as the extracted parameters and the annotations corresponding to the extracted parameters, i.e., a two-layer correspondence relationship. The content of the first JSON file is filled into the second JSON file, and the second JSON file is in a document format that conforms to the Yapi system, and the second JSON file can be imported through the Yapi system.
[0079] like Figure 2 As shown, after the second JSON file is imported into the Yapi system, it is displayed in the Yapi system. Based on the pre-designed specifications, for example, the parameters and comments are parsed into the first JSON file through template rules. In order for the tester to use the corresponding parameters and comments, the first JSON file needs to be parsed and the parsed content is filled into the second JSON file. The result after the second JSON file is imported into the Yapi system is displayed in Figure 2 The purpose of setting the second JSON file in this embodiment is to improve flexibility and is designed for docking with other display platforms, so that the first JSON file can be easily converted into a docking file suitable for other display platforms.
[0080] Furthermore, if Figure 3 As shown, the following steps are also included:
[0081] The second JSON file is stored in a pre-specified storage location, wherein the storage location is specified when the user uploads the Proto file.
[0082] For example, a location is specified in the Yapi system for storing the Proto file content that conforms to the Yapi system format in the Yapi system. The user uploads the Proto file and specifies the storage location of the Proto file content in the Yapi system, specifically, the storage location of the second JSON file in the Yapi system.
[0083] Furthermore, after step S4, the following steps are also included:
[0084] The second JSON file is stored in the storage location.
[0085] Specifically, based on the storage location, the second JSON file is imported into the Yapi system to obtain the content of the second JSON file. For example, the second JSON file is uploaded to the Yapi server and the content of the second JSON file is returned.
[0086] Furthermore, in the Yapi system, the second JSON file is opened, where the second JSON file is a gRPC interface document, and the content of the second JSON file is obtained.
[0087] Furthermore, usually, each interface of the Proto file has a comment corresponding to the interface, that is, the implementation function and role of each interface are explained and illustrated. In this embodiment, for at least one interface contained in the Proto file, the comments corresponding to each interface are extracted; the comments extracted for each interface and the corresponding interface are also stored in the first JSON file in association with the first data format; and the comments extracted from each interface and the corresponding interface stored in association in the first JSON file are also filled into the second JSON file with the second data format. At this time, the first JSON file also has the correspondence between each interface of the Proto file and the comments of each interface. By further filling it into the second JSON file, the correspondence between each interface of the Proto file and the comments of each interface is stored in the second JSON file, which can be obtained by users of other systems.
[0088] Another embodiment of the present invention provides a method for processing a Proto file. In this embodiment, the intermediate state is omitted, that is, the first JSON file is omitted, and the two-layer correspondence relationship obtained, that is, the interface information extracted for each interface and the parameters contained in each interface, and the extracted parameters and the annotations corresponding to the extracted parameters are directly stored in the second JSON file, and the second JSON file is in a format that can be parsed by other systems that do not support proto files. For example, the second JSON file is a data format supported by the Yapi system.
[0089] The processing method for the Proto file includes: for at least one interface included in the Proto file, extracting interface information of each interface and parameters included in each interface;
[0090] Extracting comments corresponding to the parameters included in each interface;
[0091] The interface information extracted for each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters are associated and stored in a second JSON file in a second data format.
[0092] Furthermore, extracting comments corresponding to the parameters included in each interface includes:
[0093] Based on the parameter annotation adding format of the Proto file, the annotations corresponding to the parameters of each interface are extracted.
[0094] Furthermore, the second JSON file is stored in a pre-specified storage location, wherein the storage location is specified when the user uploads the Proto file.
[0095] Further, for at least one interface included in the Proto file, extracting comments corresponding to each interface;
[0096] The extracted comments and corresponding interfaces for each interface are filled into the second JSON file having the second data format.
[0097] Exemplary Devices
[0098] Figure 4 Schematic diagram of a structure of a device for processing Proto files provided by an exemplary embodiment of the present invention. Figure 4 As shown, the device includes an information extraction module 41, an annotation extraction module 42, a first storage module 43 and a second storage module 44.
[0099] Information extraction module 41: configured to extract interface information of each interface and parameters contained in each interface for at least one interface contained in the Proto file;
[0100] Annotation extraction module 42: configured to extract annotations corresponding to the parameters included in each interface;
[0101] The first storage module 43 is configured to store the interface information extracted from each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters in a first JSON file in a first data format;
[0102] The second storage module 44 is configured to fill the data associated and stored in the first JSON file into a second JSON file having a second data format.
[0103] Furthermore, the present invention provides a processing device for Proto files, the device comprising:
[0104] Information extraction module: configured to extract interface information of each interface and parameters contained in each interface for at least one interface contained in the Proto file;
[0105] Annotation extraction module: configured to extract annotations corresponding to the parameters included in each interface;
[0106] The second storage module is configured to store the interface information extracted for each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters in a second JSON file in a second data format.
[0107] Exemplary Electronic Devices
[0108] Figure 5 This is the structure of an electronic device 50 provided by an exemplary embodiment of the present invention. The electronic device may be any one or both of the first device and the second device, or a stand-alone device independent of them, and the stand-alone device may communicate with the first device and the second device to receive the collected input signals from them. Figure 5 FIG. 1 is a block diagram of an electronic device according to an embodiment of the present disclosure. Figure 5 As shown, the electronic device includes one or more processors 51 and a memory 52 .
[0109] The processor 51 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0110] The memory 52 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 51 may run the program instructions to implement the software program of each embodiment of the present disclosure described above for the processing method of the Proto file and / or other desired functions. In one example, the electronic device may also include: an input device 53 and an output device 54, which are interconnected by a bus system and / or other forms of connection mechanisms (not shown).
[0111] In addition, the input device 53 may also include, for example, a keyboard, a mouse, etc.
[0112] The output device 54 can output various information to the outside. The output device 54 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto.
[0113] Of course, to simplify, Figure 5 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device may further include any other appropriate components.
[0114] Exemplary computer program products and computer-readable storage media
[0115] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the processing method for Proto files according to various embodiments of the present disclosure described in the above-mentioned "Exemplary Method" section of this specification.
[0116] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, 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.
[0117] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, causes the processor to execute the steps of the method for processing Proto files according to various embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
[0118] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, 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.
[0119] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0120] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0121] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0122] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0123] It should also be noted that in the apparatus, equipment and method of the present disclosure, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present disclosure. The above description of the disclosed aspects is provided to enable any technician in the field to make or use the present disclosure. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown here, but to the widest scope consistent with the principles and novel features disclosed herein.
[0124] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A method for processing a Proto file, characterized in that: include: Generate the Proto file according to a preset template, parse the Proto file based on the template, and extract interface information of each interface and parameters contained in each interface for at least one interface contained in the Proto file; Based on the parameter annotation adding format of the Proto file, extract the annotations corresponding to the parameters contained in each interface, including extracting the interface with parameter annotations, the parameters with annotations corresponding to the interface, and the annotations of the parameters; The interface information extracted from each interface, the parameters included in each interface, the extracted parameters, and the comments corresponding to the extracted parameters are stored in a first JSON file in a first data format; as well as The data associated and stored in the first JSON file is filled into a second JSON file having a second data format.
2. The method according to claim 1, characterized in that The second data format includes: a data format supported by the Yapi system.
3. The method according to claim 1, characterized in that The second JSON file is stored in a pre-specified storage location, wherein the storage location is specified when the user uploads the Proto file.
4. The method according to claim 1, characterized in that For at least one interface included in the Proto file, extract comments corresponding to each interface; The extracted comments and the corresponding interfaces for each interface are also stored in a first JSON file in association with each other in the first data format; as well as The annotations extracted from the interfaces and the corresponding interfaces stored in association in the first JSON file are also filled into the second JSON file having the second data format.
5. A processing device for Proto files, characterized in that: The device comprises: An information extraction module: configured to generate the Proto file according to a preset template, parse the Proto file based on the template, and extract interface information of each interface and parameters contained in each interface for at least one interface contained in the Proto file; Annotation extraction module: configured to extract annotations corresponding to the parameters contained in each interface based on the parameter annotation adding format of the Proto file, including extracting interfaces with parameter annotations, parameters with annotations corresponding to the interface, and annotations of the parameters; A first storage module: configured to store the interface information extracted for each interface, the parameters included in each interface, the extracted parameters and the comments corresponding to the extracted parameters in a first JSON file in a first data format; The second storage module is configured to fill the data associated and stored in the first JSON file into a second JSON file having a second data format.
6. A computer-readable storage medium, wherein a plurality of instructions are stored in the storage medium; the plurality of instructions are used for a processor to load and execute the method as claimed in any one of claims 1 to 4.
7. An electronic device, characterized in that: The electronic device comprises: A processor, which is used to execute multiple instructions; A memory for storing a plurality of instructions; The plurality of instructions are used to be stored in the memory and loaded and executed by the processor according to any one of the methods of claims 1-4.
