API-based metadata consistency comparison system and method
Through the API metadata consistency comparison system, using the Swagger SDK component and document comparison module, the consistency between API definition and document is compared in real time, and the high cost and inconsistency of interface document maintenance caused by frequent API updates is solved, and the problem of high interface document maintenance costs and inconsistencies is realized. Timely notification and version control reduce the risk of business interruption.
Patent Information
- Application Number
- CN202411242747.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-12-27
AI Technical Summary
The number of APIs in the digital transformation of enterprises has exploded, resulting in frequent API updates, high cost of maintaining interface documents, and inconsistent source code and interface documents, resulting in business interruption and failure risks.
Develop a API metadata consistency comparison system, including the development and integration of SDK modules, document comparison modules, real-time and periodic metadata comparison modules, alarm and notification modules, and version control and traceability modules, which are extracted through the Swagger SDK component and parse API definitions, compare the consistency of API definitions with documents in real time or regularly, and send alert messages and manage version differences.
Ensure the accuracy of the information of API definitions and documents, timely notification and update, ensure that each difference is traced to the source of information, reduce the risk of business interruption, and improve the maintenance efficiency of API interfaces.
Smart Images

Figure CN119201205A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data comparison, and specifically is a system and method based on API metadata consistency comparison. Background Art
[0002] With the rapid development of enterprise digital transformation, many enterprises have adopted the front-end and back-end separation and microservice architecture model to build business systems, resulting in an explosive growth in the number of APIs. The cost of API connection and maintenance within and between enterprises has become an urgent problem that needs to be solved. Due to the lack of transparency of API changes in upstream and downstream systems and the lack of timely and comprehensive change information, the risk of failure is extremely high, which may lead to business interruption and directly damage the profitability and reputation of the enterprise. Based on this situation, it is necessary to detect and register the metadata of the API interface, and promptly detect the API metadata information after the system is released. If changes are found, the upstream and downstream systems should be notified in time.
[0003] Currently, to maintain the consistency between the interface documentation and the system API source code, developers need to contact the interface documentation maintainer to update the interface documentation every time they change the source code. The source code modifiers need to review the documentation to ensure that the source code and the interface documentation remain consistent. When consumers use the document to develop program docking, if any inconsistencies are found or the access does not meet expectations, they need to contact the interface documentation maintainer to update the interface documentation to ensure that the documentation is consistent with the actual program interface definition.
[0004] In the current digital transformation of enterprises, the number of APIs has exploded, APIs are updated frequently, and the maintenance cost of interface documents is high. When team members update the source code or when team members change, they forget to update the interface documents, resulting in maintenance errors. The API source code and interface documents may have different versions, and the interface documents are not updated and maintained in a timely manner, resulting in inconsistencies. Summary of the invention
[0005] In view of the above problems, the present invention is proposed to provide an API metadata consistency comparison system and method that overcomes the above problems or at least partially solves the above problems.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A system for comparing consistency of API metadata, the system comprising:
[0008] Develop and integrate SDK modules for developing Swagger SDK components, which automatically extract and parse Swagger API definitions;
[0009] Document comparison module, used to register, manage and compare API metadata;
[0010] Real-time and periodic metadata comparison modules, used to implement metadata comparison mechanisms and detect inconsistencies between API definitions and documents;
[0011] Alarm and notification module, used to send alarm information to inform that API and parameters have changed;
[0012] Version control and traceability module for tracking all changes to documents and source code.
[0013] Optionally, the development and integration SDK module extracts API details by reading a Swagger JSON or YAML file.
[0014] Optionally, the API detailed information includes path, HTTP scheme, parameter type, request body, and response model.
[0015] Optionally, the document comparison module includes:
[0016] The registration service unit is used to register service information, including the Chinese name of the service, the service abbreviation and the Swagger address;
[0017] The information comparison unit is used to store the Swagger information of the periodic or real-time crawled address and parse the API definition, and then generate an interface document, which includes input parameters, output parameters and response code information.
[0018] Optionally, the real-time and periodic metadata comparison module compares the latest captured API metadata with the stored document version, identifies the differences and records the timestamps and change details of the changes.
[0019] Optionally, the alarm information includes a version difference management report, and the version difference management report includes inconsistent APIs, inconsistent parameters and a specific time when the change occurs.
[0020] Optionally, the version control and traceability module labels each change and records the modifier and date.
[0021] The present invention also provides a method for comparing consistency based on API metadata, using the above-mentioned system for comparing consistency based on API metadata, the method comprising the following steps:
[0022] S1. Develop and integrate Swagger SDK components, extract Swagger API definitions and expose interfaces;
[0023] S2. Register the Swagger address of the application service in the document comparison center;
[0024] S3, the document comparison center synchronizes Swagger information, stores API definitions and forms initial documents;
[0025] S4. Edit and supplement the generated interface documents;
[0026] S5. The document comparison center regularly captures Swagger information in real time and compares it with registered documents to perform version difference control management;
[0027] S6. When the comparison results are inconsistent, send an alarm message and notify the application manager;
[0028] S7. After receiving the alarm, check the interface definition and update the inconsistent items in time. After the update is completed, trigger step S5 to compare again to ensure that the API definition information is consistent.
[0029] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0030] 1. The present invention develops an integrated Swagger SDK, integrates the API definition of the service, exposes the interface definition, and extracts the API interface definition from each application service through a document comparison module. The consistency between the API definition and the document is compared in real time or regularly to ensure that the information is accurate.
[0031] 2. After receiving the alarm information, the user checks the interface definition and can improve it in time to ensure that the API definition information is consistent. The document comparison module performs version control on the interface definition to ensure that each difference can be traced back to the source of the information. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A schematic diagram of an API metadata consistency comparison system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0034] Embodiment 1:
[0035] See also Figure 1 This embodiment provides a system for comparing consistency based on API metadata, the system comprising:
[0036] Develop and integrate SDK modules for developing Swagger SDK components, which automatically extract and parse Swagger API definitions. This component can be integrated with various services to expose API definition metadata.
[0037] The development and integration SDK module extracts API details by reading the Swagger JSON or YAML file of the reader. The API details include path, HTTP scheme, parameter type, request body and response model.
[0038] Document comparison module, used to register, manage and compare API metadata.
[0039] The document comparison module includes:
[0040] The registration service unit is used to register service information, which includes the Chinese name of the service, the abbreviation of the service and the Swagger address.
[0041] The information comparison unit is used to store the Swagger information of the periodic or real-time crawled address and parse the API definition, and then generate an interface document, which includes input parameters, output parameters and response code information.
[0042] Real-time and periodic metadata comparison modules are used to implement metadata comparison mechanisms and detect inconsistencies between API definitions and documents.
[0043] The real-time and periodic metadata comparison module uses an algorithm to compare the latest captured API metadata with the stored document version, identifies the differences and records the timestamps and change details of the changes.
[0044] Alarm and notification module, used to send alarm information to inform that API and parameters have changed;
[0045] The warning information includes a version difference management report, and the version difference management report includes inconsistent APIs, inconsistent parameters and a specific time when the change occurs.
[0046] Version control and traceability module for tracking all changes to documents and source code.
[0047] The version control and traceability module labels each change and records the modifier and date, ensuring that the source of each inconsistency can be traced during comparison.
[0048] This embodiment develops and integrates the Swagger SDK, integrates the API definition of the service, exposes the interface definition, and extracts the API interface definition from each application service through the document comparison module. The consistency between the API definition and the document is compared in real time or regularly to ensure that the information is accurate. After receiving the alarm information, the user checks the interface definition and can improve it in time to ensure that the API definition information is consistent. The document comparison module performs version control on the interface definition to ensure that each difference can be traced back to the source of the information.
[0049] Embodiment 2:
[0050] Embodiment 2 provides a method for comparing consistency based on API metadata, using a system for comparing consistency based on API metadata provided in Embodiment 1, the method includes the following steps:
[0051] S1. Develop and integrate Swagger SDK components, extract Swagger API definitions and expose interfaces.
[0052] S2. Register the Swagger address of the application service in the document comparison center.
[0053] S3, the document comparison center synchronizes Swagger information, stores API definitions and forms initial documents;
[0054] S4. Edit and supplement the generated interface documents.
[0055] S5. The document comparison center regularly captures Swagger information in real time, compares it with registered documents, and performs version difference control management.
[0056] S6. When the comparison results are inconsistent, an alarm message is sent and the application manager is notified.
[0057] S7. After receiving the alarm, check the interface definition and update the inconsistent items in time. After the update is completed, trigger step S5 to compare again to ensure that the API definition information is consistent.
[0058] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. A system based on API metadata consistency comparison, characterized in that: The system comprises: Develop and integrate SDK modules for developing Swagger SDK components, which automatically extract and parse Swagger API definitions; Document comparison module, used to register, manage and compare API metadata; Real-time and periodic metadata comparison modules, used to implement metadata comparison mechanisms and detect inconsistencies between API definitions and documents; Alarm and notification module, used to send alarm information to inform that API and parameters have changed; Version control and traceability module for tracking all changes to documents and source code.
2. The API metadata consistency comparison system according to claim 1, characterized in that: The development and integration SDK modules extract API details by reading the Swagger JSON or YAML file.
3. The API metadata consistency comparison system according to claim 2, characterized in that: The API details include path, HTTP scheme, parameter types, request body, and response model.
4. The API metadata consistency comparison system according to claim 1, characterized in that: The document comparison module includes: The registration service unit is used to register service information, including the Chinese name of the service, the service abbreviation and the Swagger address; The information comparison unit is used to store the Swagger information of the periodic or real-time crawled address and parse the API definition, and then generate an interface document, which includes input parameters, output parameters and response code information.
5. The API metadata consistency comparison system according to claim 1, characterized in that: The real-time and periodic metadata comparison module compares the latest captured API metadata with the stored document version, identifies the differences and records the timestamps and change details of the changes.
6. The API metadata consistency comparison system according to claim 1, characterized in that: The warning information includes a version difference management report, and the version difference management report includes inconsistent APIs, inconsistent parameters and a specific time when the change occurs.
7. The API metadata consistency comparison system according to claim 1, characterized in that: The version control and traceability module labels each change and records the modifier and date.
8. A method for comparing consistency of API metadata, characterized in that: Using the API metadata consistency comparison system according to any one of claims 1 to 7, the method comprises the following steps: S1. Develop and integrate Swagger SDK components, extract Swagger API definitions and expose interfaces; S2. Register the Swagger address of the application service in the document comparison center; S3, the document comparison center synchronizes Swagger information, stores API definitions and forms initial documents; S4. Edit and supplement the generated interface documents; S5. The document comparison center regularly captures Swagger information in real time and compares it with registered documents to perform version difference control management; S6. When the comparison results are inconsistent, send an alarm message and notify the application manager; S7. After receiving the alarm, check the interface definition and update the inconsistent items in time. After the update is completed, trigger step S5 to compare again to ensure that the API definition information is consistent.