CN-121996214-A - API interface connection method and system
Abstract
The application relates to the technical field of software development, in particular to an API (application program interface) connection method and system, wherein the method comprises the steps of obtaining names of a plurality of API interfaces to be connected, wherein the plurality of API interfaces to be connected comprise an input module, an output module and an input interface and an output interface of a subsystem in a system model; based on the similarity between the name of the input module and the name of the input interface and a preset similarity threshold, the connection between the input module and the input interface of the corresponding subsystem is completed; the method can automatically complete the connection between the input module and the input interface of the corresponding subsystem and the connection between the output module and the output interface of the corresponding subsystem in the system model, does not need to manually identify the API interface, effectively reduces labor cost and has higher accuracy.
Inventors
- LI GANG
- ZHANG QIANG
- WANG JIN
- Niu Xianmeng
- WANG FUMIN
Assignees
- 重庆赛力斯凤凰智创科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260123
Claims (13)
- 1. An API interfacing method, the method comprising: The method comprises the steps of obtaining names of a plurality of API interfaces to be connected, wherein the plurality of API interfaces to be connected comprise an input module, an output module, an input interface and an output interface of a subsystem in a system model, the input module and the output module are all API interface modules which are positioned at the same level with the subsystem, and the API interface modules are used for defining attributes of transmission data; Based on the similarity between the name of the input module and the name of the input interface and a preset similarity threshold, completing the connection between the input module and the input interface of the corresponding subsystem; And based on the similarity threshold value and the similarity between the name of the output module and the name of the output interface, completing the connection between the output module and the output interface of the corresponding subsystem.
- 2. The API interfacing method as recited in claim 1, wherein said obtaining a name of an API to be interfaced includes: the input module, the output module and the subsystem in the system model are acquired, wherein the acquired input module, the acquired output module and the acquired subsystem are at least one; and reading the name of the API to obtain the name of the input module, the name of the output module, the name of the input interface of the subsystem and the name of the output interface of the subsystem.
- 3. The API interfacing method as recited in claim 1, wherein said completing the connection between the input module and the input interface of the corresponding subsystem based on a similarity of the name of the input module and the name of the input interface and a preset similarity threshold value includes: under the condition that the names of the input modules and the names of the input interfaces are multiple, a first name set is established based on the names of the input modules, and a second name set is established based on the names of the input interfaces; obtaining the similarity of the first name set and the second name set to obtain a first target similarity; And if the first target similarity is greater than or equal to the similarity threshold, establishing connection between the current input module and the current input interface.
- 4. The API interfacing method as recited in claim 3, wherein said obtaining the similarity of the first name set and the second name set to obtain the first target similarity comprises: determining the name of any one of the input modules in the first name set as a first target name, and acquiring first similarity of the names of the input interfaces in the first target name set and the second name set, wherein a plurality of first similarities form a first similarity set; And determining the maximum value in the first similarity set as the first target similarity.
- 5. The API interfacing method of claim 4, wherein said obtaining a first similarity of said first target name and said names of said input interfaces in said second set of names comprises: Performing character string conversion on the first target name to obtain a first character string, and performing character string conversion on the name of the input interface to obtain a second character string; Acquiring public substrings of the first character string and the second character string, if a plurality of public substrings are provided, determining the public substring with the longest length in the public substrings as a first public substring, and obtaining a first public substring similarity based on the length of the first public substring, wherein the first public substring similarity and the length of the first public substring are in positive correlation; obtaining first intersection character string similarity based on the first intersection character quantity of the first character string and the second character string, wherein the first intersection character string similarity and the first intersection character quantity are in positive correlation; and obtaining the first similarity according to the first common substring similarity and the first intersection character string similarity.
- 6. The API interfacing method of claim 5, wherein said obtaining a first common substring similarity based on a length of said first common substring comprises: Determining 2 times the length of the first common substring as a first value; determining a sum of the length of the first character string and the length of the second character string as a second numerical value; determining a ratio between the first value and the second value as the first common substring similarity; the obtaining the first intersection character string similarity based on the first intersection character number of the first character string and the second character string includes: the method comprises the steps of determining a first intersection character quantity of the first character string and the second character string as a third value, determining a smaller value between the length of the first character string and the length of the second character string as a fourth value, and determining a ratio between the third value and the fourth value as the similarity of the first intersection character string.
- 7. The API interfacing method as recited in claim 5 or 6, wherein said obtaining said first similarity from said first common substring similarity and said first intersection string similarity comprises: Acquiring a first weight and a first data type matching weight, wherein the first weight and the first intersection character string similarity are in positive correlation, the first data type matching weight is 1 when the transmission data type of the input module is matched with the transmission data type of the input interface, and the difference between 0;1 and the first weight is a second weight when the transmission data type of the input module is not matched with the transmission data type of the input interface; The method includes determining a product of the first weight and the first intersection string similarity as a fifth value, determining a product of the first common substring similarity and the second weight as a sixth value, and determining a product of the first data type matching weight, the fifth value, the sixth value, and 100% as the first similarity.
- 8. The API interfacing method of claim 1, wherein said completing the connection between the output module and the output interface of the corresponding subsystem based on the similarity threshold and the similarity of the name of the output module and the name of the output interface comprises: Under the condition that the names of the output modules and the names of the output interfaces are multiple, a third name set is established based on the names of the multiple output modules, and a fourth name set is established based on the names of the multiple output interfaces; obtaining the similarity of the third name set and the fourth name set to obtain second target similarity; and if the second target similarity is greater than or equal to the similarity threshold, establishing connection between the current output module and the current output interface.
- 9. The API interfacing method of claim 8, wherein said obtaining the similarity of the third name set and the fourth name set to obtain the second target similarity comprises: determining the name of any one of the output modules in the third name set as a second target name, and acquiring second similarity of the second target name and the names of the output interfaces in the fourth name set, wherein a plurality of second similarity forms a second similarity set; And determining the maximum value in the second similarity set as the second target similarity.
- 10. The API interfacing method as recited in claim 9, wherein said obtaining a second similarity of said second target name to said output interface name in said fourth set of names comprises: performing character string conversion on the second target name to obtain a third character string, and performing character string conversion on the name of the output interface to obtain a fourth character string; Acquiring public substrings of the third character string and the fourth character string, if a plurality of public substrings are provided, determining the public substring with the longest length in the public substrings as a second public substring, and obtaining second public substring similarity based on the length of the second public substring, wherein the second public substring similarity and the length of the second public substring are in positive correlation; Obtaining second intersection character string similarity based on the second intersection character quantity of the third character string and the fourth character string, wherein the second intersection character string similarity and the second intersection character quantity are in positive correlation; And obtaining the second similarity according to the second common substring similarity and the second intersection character number.
- 11. The API interfacing method as recited in any one of claims 3-6, wherein establishing a connection between a current input module and a current input interface if the first target similarity is greater than or equal to the similarity threshold comprises: If the first target similarity is greater than or equal to the similarity threshold, a first handle of the current input module is obtained based on a first corresponding relation and the name of the current input module, wherein the first corresponding relation is used for indicating the relation between the first handle and the name of the corresponding input module; Obtaining a second handle of the current input interface according to a second corresponding relation and the name of the current input interface, wherein the second corresponding relation is used for indicating the relation between the second handle and the name of the corresponding input interface; And establishing connection between the current input module and the current input interface based on the first handle of the current input module and the second handle of the current input interface.
- 12. The API interfacing method of claim 8, wherein establishing a connection between a current output module and a current output interface if the second target similarity is greater than or equal to the similarity threshold comprises: If the second target similarity is greater than or equal to the similarity threshold, a third handle of the current output module is obtained based on a third corresponding relation and the name of the current output module, wherein the third corresponding relation is used for indicating the relation between the third handle and the name of the corresponding output module; Obtaining a fourth handle of the current output interface according to a fourth corresponding relation and the name of the current output interface, wherein the fourth corresponding relation is used for indicating the relation between the fourth handle and the name of the corresponding output interface; And establishing connection between the current output module and the current output interface based on the third handle of the current output module and the fourth handle of the current output interface.
- 13. An API interfacing system, said system comprising: The interface name acquisition module is used for acquiring names of a plurality of API interfaces to be connected, wherein the plurality of API interfaces to be connected comprise an input module, an output module, an input interface and an output interface of a subsystem in a system model, the input module and the output module are all API interface modules which are positioned at the same level with the subsystem, and the API interface modules are used for defining the attribute of transmission data; The first connection module is used for completing connection between the input module and the input interface of the corresponding subsystem based on the similarity between the name of the input module and the name of the input interface and a preset similarity threshold; And the second connection module is used for completing the connection between the output module and the output interface of the corresponding subsystem based on the similarity threshold value and the similarity between the name of the output module and the name of the output interface.
Description
API interface connection method and system Technical Field The present application relates to the field of software development technologies, and in particular, to an API interface connection method and system. Background With the continuous increase of complexity of electronic systems, such as control systems, a system model design manner based on Matlab/Simulink (an integrated, visual, dynamic system modeling and simulation platform based on a block diagram) has become a mainstream of industry. In Matlab/Simulink, the functional modules of the system typically exist in the form of subsystems. The normal operation of the subsystem relies on API (Application Programming Interface ) interface modules at the same level as it is, including Inport (input module) and Outport (output module). The subsystem realizes data interaction with the outside through the corresponding Inport module and Outport module. When the system model is designed and developed, a developer needs to complete function development in the subsystem, and needs to consider that an input interface and an output interface of the subsystem, and Inport modules and Outport modules corresponding to the subsystem are identified, so that connection between the input interface of the subsystem and the corresponding Inport module, and connection between the output interface of the subsystem and the corresponding Outport module are completed. However, this approach clearly increases labor costs and is prone to problems such as API interface connection errors. Disclosure of Invention The application provides an API interface connection method and system, which are used for solving the technical problems that the labor cost is high and the API interface connection error is easy to occur in the manner of manually identifying and connecting an API interface in the related technology. The application provides an API interface connection method, which comprises the following steps: The method comprises the steps of obtaining names of a plurality of API interfaces to be connected, wherein the plurality of API interfaces to be connected comprise an input module, an output module, an input interface and an output interface of a subsystem in a system model, the input module and the output module are all API interface modules which are positioned at the same level with the subsystem, and the API interface modules are used for defining attributes of transmission data; Based on the similarity between the name of the input module and the name of the input interface and a preset similarity threshold, completing the connection between the input module and the input interface of the corresponding subsystem; And based on the similarity threshold value and the similarity between the name of the output module and the name of the output interface, completing the connection between the output module and the output interface of the corresponding subsystem. In an embodiment of the present application, the obtaining the name of the API interface to be connected includes: the input module, the output module and the subsystem in the system model are acquired, wherein the acquired input module, the acquired output module and the acquired subsystem are at least one; and reading the name of the API to obtain the name of the input module, the name of the output module, the name of the input interface of the subsystem and the name of the output interface of the subsystem. In an embodiment of the present application, the completing the connection between the input module and the input interface of the corresponding subsystem based on the similarity between the name of the input module and the name of the input interface and a preset similarity threshold includes: under the condition that the names of the input modules and the names of the input interfaces are multiple, a first name set is established based on the names of the input modules, and a second name set is established based on the names of the input interfaces; obtaining the similarity of the first name set and the second name set to obtain a first target similarity; And if the first target similarity is greater than or equal to the similarity threshold, establishing connection between the current input module and the current input interface. In an embodiment of the present application, the obtaining the similarity between the first name set and the second name set to obtain the first target similarity includes: determining the name of any one of the input modules in the first name set as a first target name, and acquiring first similarity of the names of the input interfaces in the first target name set and the second name set, wherein a plurality of first similarities form a first similarity set; And determining the maximum value in the first similarity set as the first target similarity. In an embodiment of the present application, the obtaining the first similarity between the first target name and the names of the input