Method and system for automatically generating micro-service calling SDK (Software Development Kit) based on GitLab warehouse code

By automatically parsing interface metadata in the GitLab repository to generate an SDK, the problems of low SDK development efficiency and delayed version synchronization under the microservice architecture are solved, efficient automatic generation and consistency management are achieved, and development efficiency and security are improved.

CN120743391APending Publication Date: 2025-10-03CAIXUETANG EDUCATION CULTURE MEDIA CHENGDU CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510835738.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-10-03

AI Technical Summary

Technical Problem

Under the existing microservice architecture, SDK development efficiency is low and version synchronization lags behind, resulting in time-consuming and error-prone manual parsing of interface documents. Version inconsistencies when interfaces change can easily lead to production accidents.

Method used

By analyzing the GitLab repository code structure, automatically parsing the interface metadata, generating SDK files and integrating them into the CI/CD automation process, the SDK can be automatically generated and versioned.

Benefits of technology

Significantly improve SDK generation efficiency, reducing it from man-days to minutes, ensuring the consistency of SDK version with code version and avoiding production accidents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743391A_ABST
    Figure CN120743391A_ABST
Patent Text Reader

Abstract

The invention relates to the field of SDK development, and discloses a method and system for automatically generating a micro-service calling SDK based on a GitLab warehouse code, and the method comprises the steps: firstly, submitting a micro-service site code to a GitLab warehouse; after the micro-service site code is submitted to a GitLab warehouse, automatically triggering a script, analyzing the micro-service site code by the script, and generating an SDK (Software Development Kit); according to the code structure of the micro-service site code, finding a version directory defined by a storage interface; analyzing the PHP file through a script, finding out a defined API method, and extracting the name of the API method; generating contents of SDK related files according to the extracted interface metadata; the updated SDK site code is submitted to a GitLab warehouse, and generation and version management of the SDK are completed; the problems that an existing SDK development mode is low in efficiency, version synchronization lags behind, and automatic generation and version management of the SDK are achieved by analyzing a code structure in a GitLab warehouse, automatically analyzing interface metadata and generating an SDK file are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of SDK development, and in particular to a method and system for automatically generating a microservice calling SDK based on GitLab repository code. Background Art

[0002] In a microservices architecture, services typically communicate through APIs. To make it easier for developers to call microservices, SDKs (Software Development Kits) are often developed or used. However, existing SDK development methods have at least the following drawbacks: 1. Inefficient manual development: Traditional SDK development requires engineers to manually parse interface documents and write code, which is time-consuming and error-prone. 2. Version synchronization lag: When the interface changes, the SDK needs to be manually updated, which can easily lead to version inconsistencies and cause production accidents during application. Summary of the Invention

[0003] In order to solve the technical problems of low efficiency and delayed version synchronization in the above-mentioned existing SDK development methods, the present invention provides a method and system for automatically generating microservice call SDKs based on GitLab repository code. By analyzing the code structure in the GitLab repository, automatically parsing the interface metadata, and generating SDK files, the automatic generation and version management of SDKs are realized, which greatly improves development efficiency, ensures update accuracy, and improves application security.

[0004] In order to achieve the above object, the present invention provides the following method: The present invention provides a method for automatically generating a microservice call SDK based on GitLab repository code: S1: Submit the microservice site code to the GitLab repository; S2: When the microservice site code is submitted to the GitLab repository, a script is automatically triggered to parse the microservice site code and generate an SDK; S3: Find the version directory storing the interface definition based on the code structure of the microservice site code; S4: Analyze the PHP class file through the script to find the defined API method and extract the name of the API method; S5: Generate the content of SDK-related files based on the extracted interface metadata; S6: Submit the updated SDK site code to the GitLab repository to complete SDK generation and version management.

[0005] Preferably, the script first verifies the name of the microservice site code and the application name.

[0006] Preferably, before the step of finding the version directory storing the interface definition according to the code structure of the microservice site code, preparations need to be made for generating a new SDK file, which includes: cloning the SDK site code from the GitLab repository.

[0007] Preferably, after cloning the code of the SDK site from the GitLab repository, preparations need to be made for analyzing the interface information. The specific steps are: cloning the currently submitted microservice site code from the GitLab repository.

[0008] Preferably, after the step of finding the version directory storing the interface definition according to the code structure of the microservice site code, the method further includes: traversing the Inneruse directory under the version directory, where the Inneruse directory stores the specific implementation code of the interface.

[0009] Preferably, after the step of traversing the Inneruse directory under the version directory, wherein the Inneruse directory stores the specific implementation code of the interface, the method further includes: traversing the Control directory under the version directory, wherein the Control directory stores the PHP class file defined by the interface.

[0010] Preferably, after the step of generating the content of SDK-related files according to the extracted interface metadata, the method further includes: writing the generated SDK file content into the cloned SDK site code and placing it in a corresponding directory to obtain interface information.

[0011] Preferably, after writing the generated SDK file content into the cloned SDK site code and placing it in a corresponding directory, and obtaining the interface information, the method further includes: saving the interface information into a MySQL database.

[0012] Preferably, in the process of submitting the microservice site code based on Gitlab, the business code corresponding to each business process link is split into matching microservice projects based on Gitlab according to the business process links.

[0013] The present invention provides a system for automatically generating microservice call SDKs based on GitLab repository code: Code submission module: submits the microservice site code to the GitLab repository; SDK generation module: When the microservice site code is submitted to the GitLab repository, a script is automatically triggered to parse the microservice site code and generate the SDK; Script parsing module: Analyzes PHP class files, finds defined API methods, extracts the names of the API methods, and generates the contents of SDK-related files based on the extracted interface metadata; Directory traversal module: traverses the Inneruse directory under the version directory, the Inneruse directory stores the specific implementation code of the interface, and traverses the Control directory under the version directory, the Control directory stores the PHP class file defined by the interface The beneficial effects of the present invention are as follows: the present invention is based on the repository code structure of the warehouse management tool GitLab, and by analyzing the code structure in the GitLab repository, automatically identifies interface information, parses the code, and automatically generates an SDK file based on the extracted interface metadata, and integrates the SDK generation process into the CI / CD automated delivery application method flow. When the code is submitted, SDK generation is automatically triggered to ensure that the SDK version is consistent with the code version; CI / CD integration triggers the generation of the SDK program, and the submission of the code is automatically triggered. It is based on the GitLab repository code and does not require additional code writing; the time consumption for SDK generation is reduced from man-days to minutes, realizing the synchronization of interface changes and SDK releases. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly describes the drawings required for the specific embodiments or the description of the prior art. Similar elements or parts are generally identified by similar reference numerals throughout the drawings. Elements or parts in the drawings are not necessarily drawn to scale.

[0015] Figure 1 A flowchart of a method for automatically generating a microservice call SDK based on GitLab repository code provided by an embodiment of the present invention; Figure 2 A schematic diagram of a process for automatically generating a microservice call SDK based on GitLab repository code provided by an embodiment of the present invention; Figure 3 A schematic diagram of the system steps of a method for automatically generating a microservice call SDK based on GitLab repository code provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0016] In order to help those skilled in the art better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0017] The terms "first," "second," and so on, in the description and claims of the present invention and the accompanying drawings are used to distinguish between different items, not to describe a specific order. Furthermore, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or end comprising a series of steps or elements is not limited to the listed steps or elements but may optionally include steps or elements not listed therein, or may optionally include other steps or elements inherent to such process, method, product, or end.

[0018] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0019] In a microservices architecture, services typically communicate through APIs. To facilitate developers' access to microservices, SDKs (Software Development Kits) are often developed. However, existing SDK development methods have the following drawbacks: Manual development is inefficient: Traditional SDK development requires engineers to manually parse interface documentation and write code, which is time-consuming and error-prone; and version synchronization lags: When an interface changes, the SDK must be manually updated, which can lead to version inconsistencies and production accidents.

[0020] The present invention aims to provide a method and system for automatically generating microservice call SDKs based on GitLab repository code, solving the problems of inefficient existing SDK development methods and delayed version synchronization. By analyzing the code structure in the GitLab repository, automatically parsing interface metadata, and generating SDK files, the method and system achieve automated SDK generation and version management.

[0021] like Figure 1 As shown, a specific embodiment of the present invention provides a method for automatically generating a microservice call SDK based on GitLab repository code, including the following steps: S1: Submit the microservice site code to the GitLab repository.

[0022] S2: When the microservice site code is submitted to the GitLab repository, a script is automatically triggered to parse the microservice site code and generate an SDK.

[0023] In an embodiment of the present invention, the script first verifies the name of the microservice site code and the application name.

[0024] S3: Find the version directory where the interface definition is stored based on the code structure of the microservice site code.

[0025] In an embodiment of the present invention, before finding the version directory where the interface definition is stored according to the code structure of the microservice site code, preparations need to be made for generating a new SDK file. The steps are: cloning the SDK site code from the GitLab repository; cloning the currently submitted microservice site code from the GitLab repository; traversing the Inneruse directory under the version directory, where the specific implementation code of the interface is stored; and traversing the Control directory under the version directory, where the PHP class file of the interface definition is stored.

[0026] S4: Analyze the PHP class file through the script, find out the defined API methods, and extract the names of the API methods.

[0027] S5: Generate the content of SDK-related files based on the extracted interface metadata.

[0028] In an embodiment of the present invention, after the step of generating the content of SDK-related files based on the extracted interface metadata, it also includes: writing the generated SDK file content into the cloned SDK site code and placing it in the corresponding directory to obtain interface information; saving the interface information to the MySQL database.

[0029] S6: Submit the updated SDK site code to the GitLab repository to complete SDK generation and version management.

[0030] In an embodiment of the present invention, in the process of submitting the microservice site code based on Gitlab, the business code corresponding to each business process link is split into matching microservice projects based on Gitlab according to the business process links.

[0031] like Figure 2 and Figure 3 The specific embodiment of the present invention provides a method for automatically generating a microservice call SDK based on GitLab repository code, including the following steps: Code submission module: submits the microservice site code to the GitLab repository; SDK generation module: When the microservice site code is submitted to the GitLab repository, a script is automatically triggered to parse the microservice site code and generate the SDK; Script parsing module: Analyzes PHP class files, finds defined API methods, extracts API method names, and generates SDK-related file contents based on the extracted interface metadata; Directory traversal module: traverse the Inneruse directory under the version directory, the Inneruse directory stores the specific implementation code of the interface, and traverse the Control directory under the version directory, the Control directory stores the PHP class file defined by the interface.

[0032] This invention is based on the GitLab repository code structure. By analyzing the code structure in the GitLab repository, the invention automatically identifies interface information and performs code parsing. Based on the extracted interface metadata, the invention automatically generates SDK files, integrates the SDK generation process into the CI / CD process, and automatically triggers SDK generation when the code is submitted, ensuring that the SDK version is consistent with the code version and improving the accuracy rate. The CI / CD integration triggers the generation of the SDK program, and the submission of the code is automatically triggered. Based on the GitLab repository code, there is no need to write additional code. The time consumption of SDK generation is reduced from man-days (for example, 2 people 15 days) to minutes, realizing the synchronization of interface changes and SDK releases, which greatly improves efficiency.

[0033] The above description is merely an embodiment of the present invention. Common knowledge such as the specific technical solutions or features of the solutions is not described in detail here. It should be noted that those skilled in the art may make several modifications and improvements without departing from the solution of the present invention, and these modifications and improvements should also be considered as the scope of protection of the present invention. These modifications and improvements will not affect the effects of the present invention and the practicality of the patent. The scope of protection claimed in this application shall be based on the content of the claims, and the specific embodiments and other descriptions in the specification may be used to interpret the content of the claims.

Claims

1. A method for automatically generating a microservice call SDK based on GitLab repository code, characterized in that: The method comprises: S1: Submit the microservice site code to the GitLab repository; S2: When the microservice site code is submitted to the GitLab repository, a script is automatically triggered to parse the microservice site code and generate an SDK; S3: Find the version directory storing the interface definition based on the code structure of the microservice site code; S4: Analyze the PHP class file through the script to find the defined API method and extract the name of the API method; S5: Generate the content of SDK-related files based on the extracted interface metadata; S6: Submit the updated SDK site code to the GitLab repository to complete SDK generation and version management.

2. A method for automatically generating a microservice call SDK based on GitLab repository code according to claim 1, characterized in that: The script first verifies the name of the microservice site code and the application name.

3. The method of automatically generating a microservice call SDK based on GitLab repository code according to claim 1, characterized in that: Before finding the version directory storing the interface definition based on the code structure of the microservice site code, you need to prepare for generating a new SDK file. The steps are as follows: Clone the SDK site code from the GitLab repository.

4. A method for automatically generating a microservice call SDK based on GitLab repository code according to claim 3, characterized in that: After cloning the SDK site code from the GitLab repository, you need to prepare for analyzing the interface information. The specific steps are as follows: Clone the currently committed microservice site code from the GitLab repository.

5. The method of automatically generating a microservice call SDK based on GitLab repository code according to claim 1, characterized in that: After finding the version directory storing the interface definition according to the code structure of the microservice site code, the following steps are also included: Traverse the Inneruse directory under the version directory, where the Inneruse directory stores the specific implementation code of the interface.

6. A method for automatically generating a microservice call SDK based on GitLab repository code according to claim 5, characterized in that: After the step of traversing the Inneruse directory under the version directory, where the Inneruse directory stores the specific implementation code of the interface, the method further includes: traversing the Control directory under the version directory, where the Control directory stores the PHP class file defined by the interface.

7. The method of automatically generating a microservice call SDK based on GitLab repository code according to claim 4, characterized in that: After generating the content of SDK-related files based on the extracted interface metadata, the following steps are also included: The generated SDK file content is written into the cloned SDK site code and placed in the corresponding directory to obtain the interface information.

8. The method of automatically generating a microservice call SDK based on GitLab repository code according to claim 7, characterized in that: After writing the generated SDK file content into the cloned SDK site code and placing it in a corresponding directory, and obtaining the interface information, the method further includes: saving the interface information into a MySQL database.

9. A method for automatically generating a microservice call SDK based on GitLab repository code according to any one of claims 1 to 8, characterized in that: In the process of submitting the microservice site code based on Gitlab, the business code corresponding to each business process link is split into matching microservice projects based on Gitlab according to the business process links.

10. A system for automatically generating microservice call SDKs based on GitLab repository code, characterized in that: The system comprises: Code submission module: submits the microservice site code to the GitLab repository; SDK generation module: When the microservice site code is submitted to the GitLab repository, a script is automatically triggered to parse the microservice site code and generate the SDK; Script parsing module: Analyzes PHP class files, finds defined API methods, extracts the names of the API methods, and generates the contents of SDK-related files based on the extracted interface metadata; Directory traversal module: traverses the Inneruse directory under the version directory, where the Inneruse directory stores the specific implementation code of the interface, and traverses the Control directory under the version directory, where the Control directory stores the PHP class file defined by the interface.