Interface code generation method, electronic equipment and computer program product

By automatically generating interface code and using the target data of the interface data structure, the problem of low efficiency and poor accuracy of manually writing Bean classes by front-end developers is solved, and efficient and accurate interface code generation is achieved.

CN120371272APending Publication Date: 2025-07-25KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510413094.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-02
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

During the software development process, front-end developers need to manually write Bean classes based on the interface documents provided by back-end developers, resulting in low efficiency in interface code generation and easy to miss fields, resulting in inaccurate interface code generated.

Method used

By obtaining the interface's data structure target data, extracting node description information, and adding preset data types and/or preset initial values, the node description information with the same parent node name is automatically written to generate interface code.

Benefits of technology

It improves the efficiency of interface code generation, ensures the integrity and accuracy of the code, avoids the problem of missing fields, and the generated code structure is clear and complies with design specifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371272A_ABST
    Figure CN120371272A_ABST
Patent Text Reader

Abstract

The invention provides an interface code generation method, electronic equipment and a computer program product. The interface code generation method comprises the steps that target data is obtained, the target data is data describing a data structure of an interface, and the data structure of the interface comprises a plurality of nodes; node description information of the multiple nodes is obtained from the target data, and the node description information at least comprises father node names; adding a preset data type and / or a preset initial value to the node description information of the plurality of nodes; and performing code writing on the increased node description information of the plurality of nodes with the same father node name to obtain a code of the interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical fields of computers and the like, and particularly to an interface code generation method, an electronic device, and a computer program product. Background Art

[0002] In the process of software development, front-end developers often need to manually write Bean classes according to the interface documents provided by back-end developers. Since there are a large number of fields in the interface documents, manually writing interface code requires front-end developers to invest a lot of time and effort, resulting in low efficiency of interface code generation. Summary of the Invention

[0003] The present disclosure provides an interface code generation method, an electronic device, a readable storage medium, and a computer program product.

[0004] According to one aspect of the present disclosure, there is provided an interface code generation method, including: Obtaining target data, where the target data is data describing the data structure of an interface, and the data structure of the interface includes multiple nodes; Obtaining node description information of the multiple nodes from the target data, where the node description information at least includes a parent node name; Adding a preset data type and / or a preset initial value to the node description information of the multiple nodes; and Respectively performing code writing on the added node description information of multiple nodes with the same parent node name to obtain the code of the interface.

[0005] According to the interface code generation method of at least one embodiment of the present disclosure, respectively performing code writing on the added node description information of multiple nodes with the same parent node name to obtain the code of the interface includes: Respectively performing code writing on the added node description information of multiple nodes with the same parent node name to generate codes corresponding to the multiple nodes with the same parent node name; Taking the codes corresponding to the multiple nodes with the same parent node name as the codes of a class with the parent node name as the class name; and Taking the codes of at least one class associated with the interface as the code of the interface.

[0006] According to the interface code generation method of at least one embodiment of the present disclosure, when the added node description information includes a node name, a node data type, a node comment, the parent node name, and the preset data type, respectively performing code writing on the added node description information of multiple nodes with the same parent node name to generate codes corresponding to the multiple nodes with the same parent node name includes: Generate the code corresponding to multiple nodes with the same parent node name, respectively using the node name as the name of the field, the combined data type of the node data type and the preset data type as the data type of the field, and the node comment as the comment of the field.

[0007] According to the interface code generation method of at least one embodiment of the present disclosure, when the added node description information includes the node name, node data type, node comment, the parent node name, and the preset initial value, code writing is performed on the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to multiple nodes with the same parent node name, including: Generate the code corresponding to multiple nodes with the same parent node name, respectively using the node name as the name of the field, the node data type as the data type of the field, the node comment as the comment of the field, and the preset initial value as the initial value of the field.

[0008] According to the interface code generation method of at least one embodiment of the present disclosure, when the added node description information includes the node name, node data type, node comment, the parent node name, the preset data type, and the preset initial value, code writing is performed on the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to multiple nodes with the same parent node name, including: Generate the code corresponding to multiple nodes with the same parent node name, respectively using the node name as the name of the field, the combined data type of the node data type and the preset data type as the data type of the field, the node comment as the comment of the field, and the preset initial value as the initial value of the field.

[0009] According to the interface code generation method of at least one embodiment of the present disclosure, code writing is performed on the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to multiple nodes with the same parent node name, including; Obtain a target node, where the target node is an unloaded node among multiple nodes whose parent node name is the root node name; Perform code writing on the added node description information of the target node to generate the code corresponding to the target node; and In response to the existence of child nodes of the target node, perform code writing on the added node description information of the child nodes of the target node to obtain the code corresponding to the child nodes of the target node, and after obtaining the code corresponding to the child nodes of the target node, go to the step of obtaining the target node to perform code generation in multiple loops until the code corresponding to multiple nodes with the same parent node name is obtained and then stop.

[0010] The interface code generation method according to at least one embodiment of the present disclosure further includes: In response to the target node having no child nodes, after obtaining the code corresponding to the target node, proceed to the step of obtaining the target node to perform code generation in multiple loops until the codes corresponding to multiple nodes with the same parent node name are obtained and then stop.

[0011] The interface code generation method according to at least one embodiment of the present disclosure for obtaining target data includes: When receiving the uniform resource locator of the target data, generate a target data acquisition request based on the uniform resource locator; Send the target data acquisition request to the server; and Receive the target data sent by the server.

[0012] According to another aspect of the present disclosure, there is provided an electronic device, including: a memory storing execution instructions; and a processor that executes the execution instructions stored in the memory, such that the processor executes the interface code generation method of any embodiment of the present disclosure.

[0013] According to still another aspect of the present disclosure, there is provided a readable storage medium storing execution instructions, and when the execution instructions are executed by a processor, they are used to implement the interface code generation method of any embodiment of the present disclosure.

[0014] According to yet another aspect of the present disclosure, there is provided a computer program product including a computer program, and when the computer program is executed by a processor, it implements the interface code generation method of any embodiment of the present disclosure. Description of the Drawings

[0015] The drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, are used to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are included in this specification and form a part of this specification.

[0016] Figure 1 It is a flowchart of the interface code generation method according to an embodiment of the present disclosure.

[0017] Figure 2 It is a schematic diagram of the process of obtaining target data according to an embodiment of the present disclosure.

[0018] Figure 3 It is a schematic diagram of the process of generating interface code according to an embodiment of the present disclosure.

[0019] Figure 4It is a schematic process diagram of generating node code according to an embodiment of the present disclosure.

[0020] Figure 5 It is a schematic process diagram of generating node code according to another embodiment of the present disclosure.

[0021] Figure 6 It is a schematic flow diagram of an interface code generation method according to another embodiment of the present disclosure.

[0022] Figure 7 It is a schematic block diagram of the structure of an interface code generation device according to an embodiment of the present disclosure.

[0023] Figure 8 It is a schematic block diagram of the structure of an electronic device according to an embodiment of the present disclosure. Specific Embodiments

[0024] The present disclosure will be further described in detail below with reference to the accompanying drawings and examples. It can be understood that the specific examples described herein are only for explaining the relevant content, rather than limiting the present disclosure. Additionally, it should be noted that for the sake of description, only parts related to the present disclosure are shown in the drawings.

[0025] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The technical solutions of the present disclosure will be described in detail below with reference to the drawings and embodiments.

[0026] In the software development process, front-end developers often need to manually write Bean classes according to the interface documents provided by back-end developers. Since there are a large number of fields in the interface documents, manually writing interface code requires front-end developers to invest a lot of time and effort, resulting in low efficiency of interface code generation. Moreover, since the interface code is manually written, it is also prone to the problem of missing fields, resulting in inaccurate generated interface code.

[0027] Therefore, the present disclosure proposes an interface code generation method.

[0028] The interface code generation method of the present disclosure can be used for an electronic device to automatically generate the code of an interface after obtaining target data describing the data structure of the interface. In the present disclosure, the electronic device includes but is not limited to servers, mobile phones, tablet computers, laptop computers, personal computers, wearable devices, teller machines, etc.

[0029] Figure 1 Shows the overall flow schematic diagram of the interface code generation method M100 according to an embodiment of the present disclosure. As Figure 1 shown, the method includes steps S110 to S140. Among them, the method can be executed by an electronic device such as a server, a mobile phone, or a computer.

[0030] Specifically, Figure 1 the method shown includes: S110. Obtain target data, where the target data is data describing the data structure of an interface, and the data structure of the interface includes multiple nodes.

[0031] The target data is used to describe the data structure of the interface, and through the target data, the detailed information of each node of the interface can be accurately understood. Exemplarily, the target data is Json Schema data.

[0032] The target data can be directly input to the electronic device by the developer, or can be automatically downloaded by the electronic device from a specified server, which is not limited herein.

[0033] S120. Obtain the node description information of multiple nodes from the target data, where the node description information includes at least the parent node name.

[0034] The detailed information of each node in the target data is intricate and not convenient to directly use for generating code. Therefore, first extract the node description information of each node from the target data, so as to provide better data support for generating code.

[0035] Exemplarily, the node description information may include multiple of the parent node name, node name, node data type, and node comment. The target data may include multiple key-value pairs. Furthermore, based on the keywords in the target data corresponding to each sub-information in the node description information, the value corresponding to the keyword can be obtained from the target data, and this value is used as the content of each sub-information. For example, the node name of a node can be obtained through the value corresponding to the keyword "properties" in the target data, the node data type can be obtained through the value corresponding to the keyword "type" in the target data, the node data type includes but is not limited to integer type, string type, floating point type, etc., and the node comment can be obtained through the value corresponding to the keyword "description" in the target data. The parent node name of a node is the parent object of the keyword "properties" corresponding to this node in the target data.

[0036] S130. Add a preset data type and / or a preset initial value to the node description information of multiple nodes.

[0037] Adding a preset data type and / or a preset initial value to the node description information can improve the integrity of the node description information.

[0038] Exemplarily, only the preset data type can be added to the node description information of multiple nodes, or only the preset initial value can be added to the node description information of multiple nodes, or both the preset data type and the preset initial value can be added to the node description information of multiple nodes, which is not limited herein.

[0039] The preset data types added to the node description information of different nodes can be the same. For example, they are all of the null type.

[0040] The preset initial values added to the node description information of different nodes can be the same. For example, they are all null.

[0041] S140. Code is written for the node description information after addition of multiple nodes with the same parent node name respectively to obtain the code of the interface.

[0042] Exemplarily, based on the programming language features, code is written for the node description information after addition of multiple nodes with the same parent node name respectively, so as to obtain the code of the interface.

[0043] In the code generation method of the present disclosure embodiment, the node description information of multiple nodes is obtained from the target data, and the preset data type and / or the preset initial value is added to the node description information of multiple nodes, and then code is automatically written for the node description information after addition of multiple nodes with the same parent node name respectively to obtain the code of the interface. Since the code of the interface is automatically written, front-end developers do not need to invest a lot of time and effort, which can improve the efficiency of interface code generation and will not cause inaccurate generated interface code due to missing fields. Since the target data is data describing the data structure of the interface, the interface code generated based on the target data has a clear structure and can conform to the interface design specification. In addition, adding the preset data type and / or the preset initial value to the interface code ensures the data integrity of the generated interface code, can provide better management for data types and data values, and makes the generated interface code more controllable.

[0044] Regarding step S110, in some embodiments of the present disclosure, it may include steps S111 to S113 as Figure 2 shown.

[0045] S111. When receiving the uniform resource locator of the target data, generate a target data acquisition request based on the uniform resource locator.

[0046] Exemplarily, the uniform resource locator of the target data can be input by a developer into the electronic device and thus received by the electronic device.

[0047] S112. Send the target data acquisition request to the server.

[0048] Exemplarily, the target data acquisition request is used to trigger the server to return the target data. In some embodiments, the target data acquisition request further includes the identity information of the electronic device, which can trigger the server to verify the identity of the electronic device and return the target data when the verification is passed, thereby enhancing data security.

[0049] S113. Receive the target data sent by the server.

[0050] For the code generation method in the above embodiments, when receiving the uniform resource locator of the target data, a target data acquisition request is generated based on the uniform resource locator, the target data acquisition request is sent to the server, and the target data sent by the server is received. Thus, the automatic acquisition of the target data from a remote source is realized, the acquisition method of the target data is enriched, the applicable range of the code generation method is enhanced, and the practicability and expandability of the code generation method are improved.

[0051] Regarding step S140, in some embodiments of the present disclosure, it may include steps S141 to S143 as Figure 3 shown.

[0052] S141. Code the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to the multiple nodes with the same parent node name.

[0053] There may be multiple groups of added node description information with the same parent node name among the multiple added node description information. In the case where there is a group of added node description information whose parent node name is the name of the root node, the nodes in this group of added node description information are all child nodes of the root node. In the case where there is a group of added node description information whose parent node name is the node name in another group of added node description information, the nodes in this group of added node description information are all child nodes of a certain node in the other group. Coding in groups based on the parent node name can completely generate the code corresponding to the multiple nodes with the same parent node name.

[0054] S142. Use the code corresponding to the multiple nodes with the same parent node name as the code of a class with the parent node name as the class name.

[0055] Exemplarily, after generating the code corresponding to the multiple nodes with the same parent node name, a class is generated based on these codes, and the parent node name is used as the class name.

[0056] S143. Use the code of at least one class associated with the interface as the code of the interface.

[0057] Exemplarily, the code of all classes associated with the interface can be used as the code of the interface.

[0058] For the code generation method of the above embodiment, the code is written for the added node description information of multiple nodes with the same parent node name, and the codes corresponding to multiple nodes with the same parent node name are generated. Then, the codes corresponding to multiple nodes with the same parent node name are used as the codes of a class with the parent node name as the class name. Furthermore, the codes of at least one class associated with the interface are used as the codes of the interface. Thus, the modular management of the code is realized, which is convenient for subsequent maintenance and extension. At the same time, generating class codes with the parent node name as the class name can effectively improve the readability and reusability of the code and reduce the generation of redundant code.

[0059] Regarding step S141, in some embodiments of the present disclosure, when the added node description information includes the node name, node data type, node comment, parent node name, and preset data type, step S141 may specifically be: generating the codes corresponding to multiple nodes with the same parent node name, respectively, with the node name as the name of the field, the combined data type of the node data type and the preset data type as the data type of the field, and the node comment as the comment of the field.

[0060] When the added node description information includes the node name, node data type, node comment, parent node name, and preset data type, for each node among multiple nodes with the same parent node name, the code corresponding to the node is generated with the node name as the name of the field, the combined data type of the node data type and the preset data type as the data type of the field, and the node comment as the comment of the field.

[0061] In the code corresponding to the node, the node data type and the preset data type can be connected together through the union type operator. Furthermore, the field name and the combined data type of the field can be connected together through the type specifier. That is, the code corresponding to the node can be in the following format: field name: node data type | preset data type.

[0062] The comment of the field can be marked around the code corresponding to the node through a single-line comment symbol or a multi-line comment symbol. In some embodiments of the present disclosure, when there is no node comment in the node description information, the comment of the field may not be generated during the process of generating the code corresponding to the node.

[0063] In the code generation method of the above-described embodiment, when the added post-node description information includes the node name, node data type, node comment, parent node name, and preset data type, the node name, node data type, node comment, parent node name, and preset data type are fully utilized to generate the code corresponding to the node, ensuring the integrity of the field definition. At the same time, by setting the data type of the field to a union data type, the data type of the field is strictly defined, thereby making the type check for the interface code more strict and secure, and avoiding the problem of data type mismatch during the operation of the interface code. It can be understood that in the related art, if a field in the interface code is optional, for example, the code of a field in the interface code is file1?: string, then the data type of this field is either a predefined node data type (such as string) or undefined (i.e., undefined), and the undefined data type will cause a data type mismatch problem during the operation of the interface code.

[0064] Regarding step S141, in some embodiments of the present disclosure, when the added post-node description information includes the node name, node data type, node comment, parent node name, and preset initial value, step S141 may specifically be: generating the code corresponding to multiple nodes with the same parent node name, respectively using the node name as the name of the field, the node data type as the data type of the field, the node comment as the comment of the field, and the preset initial value as the initial value of the field.

[0065] When the added post-node description information includes the node name, node data type, node comment, parent node name, and preset initial value, for each node among multiple nodes with the same parent node name, generating the code corresponding to this node using this node name as the name of the field, this node data type as the data type of the field, this node comment as the comment of the field, and the preset initial value as the initial value of the field.

[0066] In the code corresponding to the node, the field name and the data type of the field can be connected together through a type specifier, and further, the initial value of the field can be connected to the data type of the field through an assignment operator, that is, the code corresponding to the node can be in the following format: field name: node data type = field initial value.

[0067] The comment of the field can be marked around the code corresponding to this node through a single-line comment symbol or a multi-line comment symbol. In some embodiments of the present disclosure, when there is no node comment in the node description information, the comment of the field may not be generated during the process of generating the code corresponding to the node.

[0068] For the code generation method of the above embodiments, when the added post-node description information includes the node name, node data type, node annotation, parent node name, and preset initial value, the node name, node data type, node annotation, parent node name, and preset initial value are fully utilized to generate the code corresponding to the node. Thus, it is ensured that when instantiating an object, the corresponding fields always have a known preset initial value, enhancing the functionality of the interface code, avoiding runtime errors caused by uninitialization, and improving the robustness of the code. It can be understood that if a field is optional, that is, it can have this field or not, rather than definitely existing and having a preset initial value, then when instantiating an object, this field may be undefined (i.e., undefined), which may require additional checks when using this field, thereby increasing the complexity of the code.

[0069] Regarding step S141, in some embodiments of the present disclosure, when the added post-node description information includes the node name, node data type, node annotation, parent node name, preset data type, and preset initial value, step S141 may specifically be: generating the code corresponding to multiple nodes with the same parent node name, respectively using the node name as the name of the field, the combined data type of the node data type and the preset data type as the combined data type of the field, the node annotation as the annotation of the field, and the preset initial value as the initial value of the field.

[0070] When the added post-node description information includes the node name, node data type, node annotation, parent node name, preset data type, and preset initial value, for each node among multiple nodes with the same parent node name, generating the code corresponding to this node by using this node name as the name of the field, the combined data type of this node data type and the preset data type as the combined data type of the field, this node annotation as the annotation of the field, and the preset initial value as the initial value of the field.

[0071] In the code corresponding to the node, the node data type and the preset data type can be connected together through the union type operator. Furthermore, the field name and the combined data type of the field can be connected together through the type annotation symbol, and the initial value of the field can be connected to the combined data type of the field through the assignment operator. That is, the code corresponding to the node can be in the following format: field name: node data type | preset data type = field initial value.

[0072] The annotation of the field can be marked around the code corresponding to this node through single-line comment symbols or multi-line comment symbols. In some embodiments of the present disclosure, when there is no node annotation in the node description information, the annotation of the field may not be generated during the process of generating the code corresponding to the node.

[0073] For the code generation method of the above embodiments, when the added node description information includes node name, node data type, node comment, parent node name, preset data type, and preset initial value, the node name, node data type, node comment, parent node name, preset data type, and preset initial value are fully utilized to generate code with more complete field definitions to meet the requirements in complex scenarios. Since the field includes both the preset data type and the preset initial value, the field will not be set as optional, and thus there is no need for more defensive programming for the field, avoiding increasing the complexity of the code for handling undefined values. At the same time, the type check for the interface code is more secure, avoiding the problem of data type mismatch during the operation of the interface code.

[0074] Regarding step S141, in some embodiments of the present disclosure, it may include steps S1411 to S1413 as Figure 4 shown.

[0075] S1411. Obtain a target node, where the target node is an unloaded node among multiple nodes whose parent node name is the root node name.

[0076] An unloaded node, that is, a node that has not been used as a target node among multiple nodes whose parent node name is the root node name.

[0077] An unloaded node among multiple nodes whose parent node name is the root node name can be sequentially used as the target node in alphabetical order or in the order of appearance in the target data; alternatively, an unloaded node among multiple nodes whose parent node name is the root node name can be randomly used as the target node, which is not limited herein.

[0078] S1412. Write code for the added node description information of the target node to generate the code corresponding to the target node.

[0079] The content related to the code writing of the target node can refer to the above description. For the sake of brevity, it will not be elaborated herein.

[0080] S1413. In response to the existence of child nodes of the target node, write code for the added node description information of the child nodes of the target node to obtain the code corresponding to the child nodes of the target node. After obtaining the code corresponding to the child nodes of the target node, go to the step of obtaining the target node to perform code generation in multiple loops until the code corresponding to multiple nodes with the same parent node name is obtained and then stop.

[0081] If it is detected that the name of the target node is the same as the parent node name of other nodes, it can be determined that the target node has child nodes.

[0082] The code writing of the child nodes of the target node can refer to the code writing of the target node. For the sake of brevity, it will not be elaborated here.

[0083] Exemplarily, after obtaining the codes corresponding to all the child nodes of the target node, go to the step of obtaining the target node to generate the codes in multiple loops until the codes corresponding to multiple nodes with the same parent node name are obtained and stop going to the step of obtaining the target node. If the code writing of the child nodes of the target node is not completed at this time, the code writing of the child nodes of the target node should continue.

[0084] For the code generation method of the above embodiment, starting from the child nodes of the root node, the codes corresponding to the child nodes of the root node are generated one by one. And when there are child nodes of the child nodes of the root node, after generating the codes corresponding to the child nodes of the child nodes of the root node, then generate the codes corresponding to the next child node of the root node. Thus, in the case of a nested data structure, the codes corresponding to each node can be accurately generated in sequence, avoiding omission, and improving the integrity and accuracy of the generated interface codes.

[0085] Regarding step S141, in some embodiments of the present disclosure, it may further include step S1414 as Figure 5 shown.

[0086] S1414. In response to the target node having no child nodes, after obtaining the code corresponding to the target node, go to the step of obtaining the target node to generate the codes in multiple loops until the codes corresponding to multiple nodes with the same parent node name are obtained and stop.

[0087] For the code generation method of the above embodiment, starting from the child nodes of the root node, the codes corresponding to the child nodes of the root node are generated one by one. And when the child nodes of the root node have no child nodes, instead generate the codes corresponding to the next child node of the root node. Thus, unnecessary calculations are avoided, the code generation efficiency is improved, omission is avoided, and the integrity and accuracy of the generated interface codes are improved.

[0088] Please combine Figure 6 , in an example, the interface code generation method may include the following steps S201 to step S210. The content related to steps S201 to S210 can refer to the description of the above embodiment. For the sake of brevity, it will not be elaborated here.

[0089] In step S201, obtain target data, where the target data is data describing the data structure of the interface, and the data structure of the interface includes multiple nodes.

[0090] In step S202, obtain the node description information of multiple nodes from the target data, where the node description information includes at least the parent node name.

[0091] In step S203, the preset data type and the preset initial value are added to the node description information of multiple nodes to obtain the increased node description information of the multiple nodes.

[0092] In step S204, a target node is obtained, where the target node is an unloaded node among multiple nodes whose parent node name is the root node name.

[0093] In step S205, code is written for the increased node description information of the target node to generate the code corresponding to the target node. Specifically, with the target node name as the name of the field, the combined data type of the target node data type and the preset data type as the combined data type of the field, the target node comment as the comment of the field, and the preset initial value as the initial value of the field, the target node data type and the preset data type are connected together through the union type operator, the field name and the combined data type of the field are connected together through the type annotation symbol, and the initial value of the field and the combined data type of the field are connected together through the assignment operator to generate the code corresponding to multiple nodes with the same parent node name. Among them, the comment of the target field can be marked around the code corresponding to the target node through a single-line comment symbol or a multi-line comment symbol.

[0094] In step S206, it is determined whether the target node has child nodes. If so, step S207 is executed; otherwise, step S208 is executed.

[0095] In step S207, code is written for the increased node description information of the child nodes of the target node to obtain the code corresponding to all the child nodes of the target node.

[0096] In step S208, it is determined whether all the multiple nodes whose parent node name is the root node name have been loaded. If so, step S209 is entered; otherwise, step S204 is entered.

[0097] In step S209, the code corresponding to multiple nodes with the same parent node name is used as the code of a class with the parent node name as the class name.

[0098] In step S210, the code of all the classes associated with the interface is used as the code of the interface.

[0099] Based on any of the above embodiments, the present disclosure further provides an interface code generation device.

[0100] Figure 7 It is a structural schematic block diagram of an interface code generation device according to an embodiment of the present disclosure.

[0101] As Figure 7 shown, the interface code generation device includes: The first acquisition module 110 is configured to acquire target data, where the target data is data describing the data structure of an interface, and the data structure of the interface includes multiple nodes; The second acquisition module 120 is configured to acquire node description information of multiple nodes from the target data, where the node description information at least includes the parent node name; The processing module 130 is configured to add a preset data type and / or a preset initial value to the node description information of the multiple nodes; The generation module 140 is configured to perform code writing on the added node description information of multiple nodes with the same parent node name respectively to obtain the code of the interface.

[0102] The above interface code generation device may be in the form of computer software, and each module of the above interface code generation device may be implemented by computer software modules.

[0103] In some embodiments of the present disclosure, the first acquisition module 110 is configured to: when receiving the uniform resource locator of the target data, generate a target data acquisition request based on the uniform resource locator; send the target data acquisition request to the server; and receive the target data sent by the server.

[0104] In some embodiments of the present disclosure, the generation module 140 is configured to: perform code writing on the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to the multiple nodes with the same parent node name; use the code corresponding to the multiple nodes with the same parent node name as the code of a class with the parent node name as the class name; and use the code of at least one class associated with the interface as the code of the interface.

[0105] In some embodiments of the present disclosure, when the added node description information includes the node name, node data type, node comment, parent node name, and preset data type, the generation module 140 is configured to: generate the code corresponding to the multiple nodes with the same parent node name respectively with the node name as the name of the field, the combined data type of the node data type and the preset data type as the data type of the field, and the node comment as the comment of the field.

[0106] In some embodiments of the present disclosure, when the added node description information includes the node name, node data type, node comment, parent node name, and preset initial value, the generation module 140 is configured to: generate the code corresponding to the multiple nodes with the same parent node name respectively with the node name as the name of the field, the data type of the node data type as the data type of the field, the node comment as the comment of the field, and the preset initial value as the initial value of the field.

[0107] In some embodiments of the present disclosure, when the added node description information includes a node name, a node data type, a node annotation, a parent node name, a preset data type, and a preset initial value, the generating module 140 is configured to: generate codes corresponding to multiple nodes with the same parent node name, respectively using the node name as the name of the field, the combined data type of the node data type and the preset data type as the data type of the field, the node annotation as the annotation of the field, and the preset initial value as the initial value of the field.

[0108] In some embodiments of the present disclosure, the generating module 140 is configured to: obtain a target node, where the target node is an unloaded node among multiple nodes whose parent node name is the root node name; write codes for the added node description information of the target node to generate codes corresponding to the target node; and in response to the existence of child nodes of the target node, write codes for the added node description information of the child nodes of the target node to obtain codes corresponding to the child nodes of the target node, and after obtaining the codes corresponding to the child nodes of the target node, go to the step of obtaining the target node to perform code generation in multiple loops until codes corresponding to multiple nodes with the same parent node name are obtained and then stop.

[0109] In some embodiments of the present disclosure, the generating module 140 is configured to: in response to the non-existence of child nodes of the target node, after obtaining the codes corresponding to the target node, go to the step of obtaining the target node to perform code generation in multiple loops until codes corresponding to multiple nodes with the same parent node name are obtained and then stop.

[0110] The implementation processes of the functions and roles of each module in the above device are specifically described in detail in the implementation processes of the corresponding steps in the above method, and will not be elaborated here.

[0111] The execution subject of the interface code generation method in the specific embodiments of the present disclosure can be an electronic device such as a server, a mobile phone, or a computer.

[0112] Therefore, based on any one of the above embodiments, the present disclosure further provides an electronic device that can execute the interface code generation method of any one of the above embodiments described in the present disclosure.

[0113] Figure 8 It is a structural schematic diagram of an electronic device 1000 according to an embodiment of the present disclosure.

[0114] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application of the hardware and the overall design constraints. The bus 1100 connects various circuits including one or more processors 1200, a memory 1300, and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.

[0115] The bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Component (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only one connection line is shown in this figure, but it does not mean that there is only one bus or one type of bus.

[0116] The present disclosure also provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the above-mentioned method. The "readable storage medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples of the readable storage medium include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0117] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, the processes or functions of the present disclosure are executed in whole or in part.

[0118] Computer programs or instructions can be stored in a readable storage medium or transmitted from one readable storage medium to another. For example, the computer programs or instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired or wireless manner. The readable storage medium can be any available medium that can be accessed or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; it can also be an optical medium, such as a digital video disc; or it can be a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or can include both volatile and non-volatile types of storage media.

[0119] Those skilled in the art should understand that the embodiments of the present disclosure can be provided as a method, system, or computer program product. Therefore, the present disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present disclosure can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0120] The present disclosure is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device generate means for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0121] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable apparatus to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one process Figure 1 one process or more processes and / or blocks Figure 1 steps of the functions specified in one block or more blocks.

[0123] In the description of this specification, the description with reference to the terms "one embodiment / way", "some embodiments / ways", "example", "specific example", or "some examples", etc. means that the specific features, structures, or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / way or example. Moreover, the specific features, structures, or characteristics described can be combined in a suitable manner in any one or more embodiments / ways or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments / ways or examples described in this specification and the features of different embodiments / ways or examples.

[0124] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically and clearly defined.

[0125] Those skilled in the art should understand that the above embodiments are only for clearly explaining the present disclosure and not for limiting the scope of the present disclosure. For those skilled in the art, other changes or modifications can be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

Claims

1. An interface code generation method, characterized in that, Including: Obtain target data, where the target data is data describing the data structure of an interface, and the data structure of the interface includes multiple nodes; Obtain the node description information of the multiple nodes from the target data, where the node description information at least includes the parent node name; Add a preset data type and / or a preset initial value to the node description information of the multiple nodes; and Code the added node description information of multiple nodes with the same parent node name respectively to obtain the code of the interface.

2. The interface code generation method according to claim 1, wherein Coding the added node description information of multiple nodes with the same parent node name respectively to obtain the code of the interface, including: Code the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to the multiple nodes with the same parent node name; Use the code corresponding to the multiple nodes with the same parent node name as the code of a class with the parent node name as the class name; and Use the code of at least one class associated with the interface as the code of the interface.

3. The interface code generation method according to claim 2, wherein When the added node description information includes the node name, node data type, node comment, the parent node name, and the preset data type, code the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to the multiple nodes with the same parent node name, including: Generate the code corresponding to the multiple nodes with the same parent node name respectively with the node name as the name of the field, the node data type and the preset data type as the combined data type of the field, and the node comment as the comment of the field.

4. The interface code generation method according to claim 2, wherein When the added node description information includes the node name, node data type, node comment, the parent node name, and the preset initial value, code the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to the multiple nodes with the same parent node name, including: Generate the code corresponding to the multiple nodes with the same parent node name respectively with the node name as the name of the field, the node data type as the data type of the field, the node comment as the comment of the field, and the preset initial value as the initial value of the field.

5. The interface code generation method according to claim 2, wherein When the added node description information includes the node name, node data type, node comment, the parent node name, the preset data type, and the preset initial value, code the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to the multiple nodes with the same parent node name, including: Generate the code corresponding to the multiple nodes with the same parent node name respectively with the node name as the name of the field, the node data type and the preset data type as the combined data type of the field, the node comment as the comment of the field, and the preset initial value as the initial value of the field.

6. The interface code generation method according to claim 2, wherein Coding the added node description information of multiple nodes with the same parent node name respectively to generate the code corresponding to the multiple nodes with the same parent node name, including; Obtain a target node, where the target node is an unloaded node among multiple nodes whose parent node name is the root node name; Write code for the increased node description information of the target node to generate the code corresponding to the target node; and In response to the existence of child nodes of the target node, write code for the increased node description information of the child nodes of the target node to obtain the code corresponding to the child nodes of the target node, and after obtaining the code corresponding to the child nodes of the target node, go to the step of obtaining the target node to perform code generation in multiple loops until the code corresponding to multiple nodes with the same parent node name is obtained and then stop.

7. The interface code generation method according to claim 6, wherein Further include: In response to the non-existence of child nodes of the target node, after obtaining the code corresponding to the target node, go to the step of obtaining the target node to perform code generation in multiple loops until the code corresponding to multiple nodes with the same parent node name is obtained and then stop.

8. The interface code generation method according to any one of claims 1 to 7, characterized in that Obtain target data, including: In the case of receiving the uniform resource locator of the target data, generate a target data acquisition request based on the uniform resource locator; Send the target data acquisition request to the server; and Receive the target data sent by the server.

9. An electronic device, characterized in that, Include: A memory that stores execution instructions; And A processor that executes the execution instructions stored in the memory, so that the processor executes the interface code generation method according to any one of claims 1 to 8.

10. A computer program product comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the interface code generation method according to any one of claims 1 to 8.