Interface merging method and device, equipment and storage medium

By merging URIs in the API interface, using similarity calculations of path segments, query parameters, request bodies and response bodies, the problem of redundancy of API interface assets is solved, and the efficiency and accuracy of API interface assets are improved.

CN119311689APending Publication Date: 2025-01-14赵晓光
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411335929.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In the use of API interfaces, query parameters are directly spliced ​​into the URI, resulting in different URI uniqueness, resulting in an increase in redundant and duplicate API interface assets, making it difficult to effectively sort out.

Method used

By obtaining the URI from the received interface access data, the similarity of the path segment is determined, the similarity of the query parameters, request bodies and response bodies is calculated, and the comprehensive similarity is determined based on the preset weight value, and the URI is merged to avoid redundancy.

Benefits of technology

It effectively avoids redundant duplicate API interface assets caused by different URI query parameters, and improves the efficiency and accuracy of API interface assets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311689A_ABST
    Figure CN119311689A_ABST
Patent Text Reader

Abstract

The invention provides an interface merging method and device, equipment and a storage medium, target sets are determined from a plurality of obtained URIs, the target sets comprise URIs of which the similarity of path segments meets a set requirement, for each target set, the similarity of query parameters, corresponding request bodies and corresponding response bodies is determined, and the similarity of the query parameters, the corresponding request bodies and the corresponding response bodies is determined. According to the embodiment of the invention, a similarity calculation result is obtained, a comprehensive similarity is determined according to the similarity calculation result and a corresponding weight value, and under the condition that the comprehensive similarity is greater than a preset threshold value, each URI contained in a target set corresponds to the same interface, so that the problem that redundant and repeated API interface assets are generated due to different query parameters in the URI can be avoided, and the user experience is improved. The efficiency and accuracy of API asset carding can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to an interface merging method, device, equipment and storage medium. Background Art

[0002] As the demand for data exchange and integration between different systems grows, various application programming interfaces (APIs) have become a key link in business operations. Currently, in the process of combing API assets, all API calls can be identified from captured network traffic, the corresponding URIs can be recorded, and they can be used as part of the API assets.

[0003] However, in the use of API interfaces, especially some data collection and heartbeat maintenance type interfaces, query parameters are usually directly concatenated into the URI. When query parameters directly become part of the URI, if the API interface assets are determined only based on the uniqueness of the URI, due to different query parameters in the URI, even if the functions and main logic of the API interfaces corresponding to the URIs are the same, these API interfaces will still be regarded as different API interface assets, causing a sharp increase in the number of redundant and repeated API interface assets caused by query parameters, making it extremely difficult to sort out API interface assets. Summary of the invention

[0004] In view of this, the present application provides an interface merging method, device, equipment and storage medium to solve the deficiencies in the related art.

[0005] In a first aspect of the present application, a method for merging an interface is provided, the method comprising:

[0006] Obtaining a uniform resource identifier URI from the received interface access data;

[0007] Determine a target set from the obtained multiple URIs, wherein the target set includes URIs whose path segment similarities meet set requirements, wherein the path segments are obtained by segmenting the path portion of the obtained URI according to the path separator;

[0008] For each target set, respectively determine the similarity of query parameters in each URI contained in the target set, the similarity of request bodies in interface access data corresponding to each URI, and the similarity of response bodies in interface access data corresponding to each URI;

[0009] Determining a comprehensive similarity according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and preset weight values ​​of each similarity;

[0010] When the comprehensive similarity is greater than a first preset threshold, each URI included in the target set is matched with the same interface.

[0011] According to an embodiment of the present application, determining a target set from the acquired multiple URIs includes:

[0012] The path in the obtained URI is split according to the path separator to obtain the path segment;

[0013] According to the hierarchical relationship of each path segment in the corresponding path, the obtained path segments are constructed into a node tree, each node in the node tree contains a path segment;

[0014] For each level of the node tree, the similarity of the nodes in the level is calculated based on the node attribute characteristics, and when the similarity of the nodes is greater than a second preset threshold, the corresponding nodes are added to the same group under the level;

[0015] The target set is determined based on the groups corresponding to each level and the affiliation between nodes.

[0016] According to an embodiment of the present application, determining the similarity of the request bodies in the interface access data corresponding to each URI includes:

[0017] Determine the request body data type corresponding to the target set according to the data type of the request body in the interface access data corresponding to each URI;

[0018] When the request body data type is in JS key-value pair data JSON format, extract JSON frames from the request bodies of the interface access data corresponding to each URI, and calculate the similarity between the JSON frames;

[0019] When the request body data type is a MAP type, extracting sets containing all field names from the request bodies of the interface access data corresponding to each URI, and calculating similarities between the sets;

[0020] In the case that the request body data type is text data, text features are extracted from the request bodies of the interface access data corresponding to the respective URIs, and similarities between the text features are calculated.

[0021] According to an embodiment of the present application, determining the similarity of the response bodies in the interface access data corresponding to each URI includes:

[0022] Determine the response body data type corresponding to the target set according to the data type of the response body in the interface access data corresponding to each URI;

[0023] When the response body data type is in JSON format, extracting JSON frames from the response bodies of the interface access data corresponding to each URI, and calculating the similarity between the JSON frames;

[0024] In the case where the response body data type is an extensible markup language XML type, extracting XML frames from the response bodies of the interface access data corresponding to each URI, and calculating the similarity between the XML frames;

[0025] In the case that the response body data type is text data, text features are extracted from the response bodies of the interface access data corresponding to each URI, and the similarities between the text features are calculated.

[0026] According to an embodiment of the present application, the step of making each URI included in the target set correspond to the same interface includes:

[0027] Determine a replacement field according to an attribute feature of a target path segment, wherein the target path segment is a path segment whose similarity among the URIs included in the target set meets the set requirement;

[0028] Replacing the target path segment in each URI with the replacement field;

[0029] The replaced URIs are merged, and the merged URIs are made to correspond to the target interface, so that the URIs correspond to the same interface.

[0030] According to an embodiment of the present application, after merging the replaced URIs and making the merged URI correspond to the target interface, the method further includes:

[0031] In the case where the similarity between the acquired URI and the path segment in the merged URI meets the set requirement, the acquired URI is merged into the merged URI so that the acquired URI corresponds to the target interface.

[0032] In a second aspect of the present application, an interface merging device is provided, the device comprising:

[0033] An acquisition unit, used for acquiring a uniform resource identifier URI from the received interface access data;

[0034] A first determining unit is used to determine a target set from the obtained multiple URIs, wherein the target set includes URIs whose path segment similarities meet set requirements, and the path segments are obtained by dividing the path part in the obtained URI according to the path separator;

[0035] A second determination unit is used to determine, for each target set, respectively the similarity of query parameters in each URI contained in the target set, the similarity of request bodies in the interface access data corresponding to each URI, and the similarity of response bodies in the interface access data corresponding to each URI;

[0036] A third determining unit, configured to determine a comprehensive similarity according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and a preset weight value of each similarity;

[0037] The merging unit is used to correspond each URI included in the target set to the same interface when the comprehensive similarity is greater than a first preset threshold.

[0038] In a third aspect of the present application, an electronic device is provided, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor is used to execute the machine executable instructions to implement the steps of the method proposed in the above embodiment.

[0039] In a fourth aspect of the present application, a machine-readable storage medium is provided, wherein the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are executed by a processor, the steps of the method proposed in the above embodiment are implemented.

[0040] In a fifth aspect of the present application, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the method proposed in the above embodiment when executed by a processor.

[0041] It can be seen from the above technical scheme that by determining the target set from the multiple URIs obtained, the target set contains URIs whose path segment similarity meets the set requirements. For each target set, the similarity of the query parameters, the corresponding request body and the corresponding response body is determined respectively, and the comprehensive similarity is determined according to the similarity calculation result and the corresponding weight value. When the comprehensive similarity is greater than the preset threshold, each URI contained in the target set is corresponded to the same interface, thereby avoiding the problem of generating redundant and repeated API interface assets due to different query parameters in the URI, and improving the efficiency and accuracy of API interface asset combing.

[0042] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 It is a flowchart of an interface merging method provided in an embodiment of the present application;

[0044] Figure 2 is a schematic diagram of a node tree provided in an embodiment of the present application;

[0045] Figure 3 It is a flowchart of an interface merging method provided in an embodiment of the present application;

[0046] Figure 4 It is a structural schematic diagram of an interface merging device provided in an embodiment of the present application;

[0047] Figure 5 It is a schematic diagram of the hardware structure of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0048] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0049] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0050] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.

[0051] As the wave of digital transformation continues to advance, enterprises have an increasing demand for data exchange and integration between different systems, and various application programming interfaces (APIs). However, many companies have not fully realized the number of API interfaces they have and their importance during this transformation process. Therefore, combing API interface assets has become the first step in API interface management and control. At present, in order to comb API interface assets, API calls are usually identified by capturing and analyzing network traffic, recording the corresponding URI, and using it as part of the API interface assets.

[0052] However, in actual operations, especially some data collection and heartbeat maintenance type interfaces, query parameters and corresponding parameter values ​​are usually directly concatenated into the URI.

[0053] For example, suppose there is an API interface for obtaining user information, and its base URI is defined as " / api / users". This API interface has the ability to filter specific user information through query parameters, where the query parameters can be user ID (userId) or username (username), etc. When it is necessary to obtain the information of a specific user, the corresponding query parameters will be appended to the base URI, such as " / api / users?userId=123" and " / api / users?userId=456".

[0054] The API interfaces called by the above two URIs are identical in terms of function and logic, and are essentially used to obtain user information. Therefore, in practical applications, the API interfaces called by the two URIs should be considered as the same API interface asset. However, in the related art, API interface assets are determined only based on the uniqueness of the URI. Since the query parameters in the above two URIs are different, the API interfaces called by the two URIs in the related art will be considered as two different API interface assets, which leads to a sharp increase in the number of redundant and repeated API interface assets caused by query parameters, resulting in the expansion and confusion of API interface assets, thereby increasing the difficulty of sorting out API interface assets.

[0055] In view of this, an embodiment of the present application discloses an interface merging method to solve the deficiencies in the related art.

[0056] like Figure 1 As shown, Figure 1 1 is a flow chart of an interface merging method provided by an embodiment of the present application. The embodiment of the present application does not limit the execution subject of the process of the present method. Optionally, the execution subject can be any network device. For example, a gateway for interface merging, or a terminal that needs to perform interface merging, etc.

[0057] The interface merging method may include the following steps:

[0058] S101: Acquire a uniform resource identifier URI from received interface access data.

[0059] In an embodiment of the present application, the network device may receive interface access data and obtain a uniform resource identifier URI (Uniform Resource Identifier) ​​from the interface access data.

[0060] Interface access data refers to all data related to initiating a request (Request) and receiving a response (Response) during the process of exchanging data through an API. This includes the data of the request itself, such as the request method, URI, request header, request body, etc. in the HTTP request message, and the data returned by the response, such as the response status code, response header, response body, etc. in the HTTP response message. The HTTP request message in the received interface access data can be parsed to extract the URI from the request line of the HTTP request message.

[0061] S102: determining a target set from the obtained multiple URIs, wherein the target set includes URIs whose path segment similarities meet set requirements, and the path segments are obtained by dividing the path part in the obtained URI according to the path separator.

[0062] In an embodiment of the present application, the path part in the URI obtained in S101 can be segmented according to the path separator to obtain path segments, and for the multiple URIs obtained, the URIs whose path segment similarities meet the set requirements are added to the target set.

[0063] In some embodiments, the path separator may be " / ". Specifically, for the URI " / api / resource / users / 123?info=orders&status=active", the path portion in the URI is " / api / resource / users / 123", and the path portion in the URI may be split according to the path separator " / " to obtain four path segments in sequence, namely, the first-level path segment "api", the second-level path segment "resource", the third-level path segment "users" and the fourth-level path segment "123".

[0064] Exemplarily, the above-mentioned setting requirement may be that the similarity is greater than a preset threshold, or the similarity is within a preset range.

[0065] In some embodiments, URIs among multiple URIs whose path segments at all levels have similarities that meet set requirements may be added to the target set.

[0066] For example, the requirement is set to be a similarity greater than 0.7, assuming URI1: / api / resource / books / novel1, URI2: / api / resource / books / novel2, URI3: / api / resource / orders / info. For URI1 and URI2, the preset algorithm can be used to calculate that the similarity of the first, second, and third level path segments of the two is 1, and the similarity of the fourth level path segment is 0.8. Since the similarity of the path segments of all levels in URI1 and URI2 is greater than 0.7, URI1 and URI2 can be added to the target set.

[0067] It should be noted that the embodiments of the present application do not specifically limit the method of adding URIs whose path segment similarity meets the set requirements to the target set. For example, URIs among multiple URIs whose overall path segment similarity meets the set requirements can also be added to the target set. Here, the overall similarity of the path segments can be the average, weighted average or other aggregation measurement of the similarities of the path segments at each level.

[0068] In some embodiments, the path portion in the obtained URI may be split according to the path separator to obtain the path segments;

[0069] According to the hierarchical relationship of each path segment in the corresponding path, the obtained path segments are constructed into a node tree, and each node in the node tree contains a path segment;

[0070] For each level of the node tree, the similarity of the nodes in the level is calculated based on the node attribute characteristics, and when the similarity of the nodes is greater than a second preset threshold, the corresponding nodes are added to the same group under the level;

[0071] The target set is determined based on the groups corresponding to each level and the relationship between nodes.

[0072] Specifically, it is assumed that the acquired URI may include:

[0073] URI1: / api / resource / books / novel1;

[0074] URI2: / api / resource / books / novel2;

[0075] URI4: / api / resource / users / 123 / phone / 13211112222;

[0076] URI5: / api / resource / users / 124 / phone / 13233334444.

[0077] According to the path separator " / ", the path parts in URI1, URI2, URI4 and URI5 are split into path segments, where the path segments from the first level to the fourth level of URI1 are api, resource, books and novel1 respectively; the path segments from the first level to the fourth level of URI2 are api, resource, books and novel2 respectively; the path segments from the first level to the sixth level of URI4 are api, resource, users, 123, phone and 13211112222 respectively; the path segments from the first level to the sixth level of URI5 are api, resource, users, 124, phone and 13233334444 respectively.

[0078] The obtained path segments can be constructed into a node tree according to the hierarchical relationship of each path segment in the corresponding path. Specifically, the path segments of the first level in the path can be used as the root node of the node tree (the first level of the node tree), and the path segments of the second level in the path can be used as the child nodes of the root node (the second level of the node tree), and so on, to construct the obtained path segments into a node tree. Figure 2 As shown, Figure 2 It is a schematic diagram of a node tree provided in an embodiment of the present application, and each node in the node tree includes a path segment.

[0079] For each level of the node tree, features can be extracted for each node in the level to obtain node attribute features of each node. The node attribute features here can include the name of the path segment, the type of the path segment (such as encoding, file resource, etc.), etc.

[0080] Based on the node attribute features of each node obtained, the similarity of the nodes in the hierarchy is calculated. It should be noted that the embodiments of the present application do not specifically limit the method for calculating the node similarity. For example, the similarity of the nodes can be calculated using methods such as edit distance, Jaccard similarity coefficient, or natural language processing (NLP) technology.

[0081] When the similarity of the nodes is greater than the second preset threshold, the corresponding nodes are added to the same group under the level. Figure 2In the fourth level of the node tree of , the types of the path segments of nodes "123" and "124" are both user IDs. The Levenshtein distance can be used to calculate the similarity S between the node attribute features of the two nodes. Since the obtained similarity S is greater than the second preset threshold, nodes "123" and "124" can be added to group A under the fourth level. By analogy, for Figure 2 In the node tree, the node "novel1" and the node "novel2" can be added to the group B at the fourth level, the node "phone" under the node "123" and the node "phone" under the node "124" can be added to the group C at the fifth level, and the node "13211112222" and the node "13233334444" can be added to the group D at the sixth level. It should be noted that since the names of the node "phone" under the node "123" and the node "phone" under the node "124" are the same, when adding the two nodes to the group C at the fifth level, unique identifiers can be added to them respectively to distinguish them. For example, the name of their parent node can be used as the unique identifier, such as the node "phone" under the node "123" is recorded as the node "123_phone", and the node "phone" under the node "124" is recorded as "124_phone".

[0082] The target set is determined based on the groups corresponding to each level and the affiliation between nodes.

[0083] Specifically, group D contains nodes "13211112222" and "13233334444". Since the node "13211112222" in group D belongs to the node "123_phone" in group C (i.e., the previous level of the node "13211112222" in group D is the node "123_phone" in group C), the node "123_phone" in group C belongs to the node "123" in group B, and the node "123" in group B belongs to the node "users". At the same time, since another node "13233334444" in group D belongs to another node "124_phone" in group C, and the node "124_phone" in group C belongs to another node "124" in group B, the node "124" in group B also belongs to the node "users".

[0084] Therefore, URI4: / api / resource / users / 123 / phone / 13211112222 and URI5: / api / resource / users / 124 / phone / 13233334444 can be added to the target collection.

[0085] Similarly, URI1: / api / resource / books / novel1 and URI2: / api / resource / books / novel2 are added to another target collection.

[0086] S103: For each target set, respectively determine the similarity of query parameters in each URI contained in the target set, the similarity of request bodies in interface access data corresponding to each URI, and the similarity of response bodies in interface access data corresponding to each URI.

[0087] For each target set, determine the similarity of query parameters in each URI contained in the target set, determine the similarity of request bodies in interface access data corresponding to each URI contained in the target set, and determine the similarity of response bodies in interface access data corresponding to each URI contained in the target set.

[0088] In some embodiments, the parameter names of the query parameters in each URI included in the target set may be extracted, and the similarities between the parameter names may be calculated.

[0089] In a URI, a query parameter is a series of key-value pairs following the "?" and separated by "&". Query parameters are used to pass additional information to the server.

[0090] For example, in URI6: / search?q=hello&page=2, "q=hello" and "page=2" are query parameters. In the query parameters, the part to the left of "=" is the parameter name of the query parameter, such as "q" and "page" in the above example.

[0091] It should be noted that the embodiments of the present application do not specifically limit the method for calculating the similarity of query parameters. For example, the similarity of query parameters may be calculated using methods such as edit distance, Jaccard similarity coefficient, or natural language processing technology.

[0092] In some embodiments, the request body data type corresponding to the target set may be determined based on the data type of the request body in the interface access data corresponding to each URI included in the target set.

[0093] Specifically, the number of times the data types of various request bodies appear in the target set may be counted, and the data type of the request body that appears most frequently is used as the request body data type corresponding to the target set.

[0094] When the request body data type corresponding to the target set is in JS key-value pair data JSON (JavaScript Object Notation) format, JSON frames are extracted from the request bodies of the interface access data corresponding to each URI contained in the target set, and the similarities between these JSON frames are calculated.

[0095] When the request body data type corresponding to the target set is of MAP type, sets containing all field names are extracted from the request bodies of the interface access data corresponding to each URI contained in the target set, and the similarities between these sets are calculated.

[0096] When the request body data type corresponding to the target set is text data, text features are extracted from the request body of the interface access data corresponding to each URI included in the target set, and the similarity between the text features is calculated.

[0097] In some embodiments, the response body data type corresponding to the target set may be determined according to the data type of the response body in the interface access data corresponding to each URI included in the target set.

[0098] Specifically, the number of times the data types of various response bodies appear in the target set may be counted, and the data type of the response body that appears the most times is used as the data type of the response body corresponding to the target set.

[0099] It should be noted that the embodiments of the present application do not specifically limit the method for determining the request body / response body data type corresponding to the target set based on the data type of the request body / response body in the interface access data corresponding to each URI contained in the target set. For example, the request body / response body data type corresponding to the target set can also be determined by cluster analysis, regular expression matching or neural network methods.

[0100] When the response body data type corresponding to the target set is in JSON format, JSON frames are extracted from the response bodies of the interface access data corresponding to each URI included in the target set, and the similarities between the JSON frames are calculated.

[0101] When the response body data type corresponding to the target set is an Extensible Markup Language (XML) type, XML frames are extracted from the response bodies of the interface access data corresponding to each URI included in the target set, and the similarities between the XML frames are calculated.

[0102] When the response body data type corresponding to the target set is text data, text features are extracted from the response body of the interface access data corresponding to each URI included in the target set, and the similarity between the text features is calculated.

[0103] S104: Determine a comprehensive similarity according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and preset weight values ​​of each similarity.

[0104] Weight values ​​W1, W2 and W3 may be set in advance for the similarity of query parameters, the similarity of request bodies and the similarity of response bodies, respectively.

[0105] The comprehensive similarity is determined according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and the preset weight values ​​corresponding to each similarity.

[0106] In some embodiments, the comprehensive similarity S total It can be calculated using the following formula:

[0107] S total =W1×S1+W2×S2+W3×S3

[0108] Among them, W1 is the preset weight value corresponding to the similarity of the query parameters, S1 is the similarity of the query parameters, W2 is the preset weight value corresponding to the similarity of the request body, S2 is the similarity of the request body, W3 is the preset weight value corresponding to the similarity of the response body, S3 is the similarity of the response body, and the sum of W1, W2 and W3 is 1.

[0109] S105: When the comprehensive similarity is greater than a first preset threshold, each URI included in the target set is matched with the same interface.

[0110] When the comprehensive similarity is greater than the first preset threshold, it is considered that the API interfaces called by the various URIs included in the target set are the same at the functional and logical levels, and the various URIs included in the target set correspond to the same interface and are regarded as the same API interface asset.

[0111] In some embodiments, the replacement field may be determined based on the attribute characteristics of the target path segment, where the target path segment is a path segment whose similarity among the URIs included in the target set meets the set requirements.

[0112] For example, suppose the target collection contains the following URIs:

[0113] URI4: / api / resource / users / 123 / phone / 13211112222;

[0114] URI5: / api / resource / users / 124 / phone / 13233334444.

[0115] Among them, the path segment "123" and the path segment "124" are a group of target path segments, the attribute characteristics of both are user IDs, and the replacement field can be "{user_id}".

[0116] The path segment "13211112222" and the path segment "13233334444" are another set of target path segments. The attribute characteristics of both are mobile phone numbers, and the replacement field can be "{phone_number}".

[0117] Replace the target path segment in each URI with the replacement field;

[0118] The replaced URIs are merged, and the merged URIs are made to correspond to the target interface, so that the URIs correspond to the same interface.

[0119] For example, for URI5 and URI6 included in the above target set, the merged URI may be “ / api / resource / users / {user_id} / phone / {phone_number}”.

[0120] In some embodiments, after merging the replaced URIs and making the merged URI correspond to the target interface, if the similarity between the acquired URI and the path segment in the merged URI meets the set requirements, the acquired URI is merged into the merged URI so that the acquired URI corresponds to the target interface.

[0121] In an embodiment of the present application, a target set is determined from multiple URIs obtained, the target set includes URIs whose path segment similarity meets the set requirements, and for each target set, the similarity of the query parameters, the corresponding request body, and the corresponding response body is determined respectively, and the comprehensive similarity is determined based on the similarity calculation result and the corresponding weight value. When the comprehensive similarity is greater than a preset threshold, each URI included in the target set is corresponded to the same interface, thereby avoiding the problem of generating redundant and repeated API interface assets due to different query parameters in the URI, and improving the efficiency and accuracy of API interface asset combing.

[0122] like Figure 3 As shown, Figure 3 It is a flowchart of an interface merging method provided in an embodiment of the present application.

[0123] S301: URI segmentation

[0124] Receive interface access data, obtain a URI from the interface access data, and divide the path part in the obtained URI according to the path separator to obtain path segments.

[0125] S302: Building a node tree

[0126] According to the hierarchical relationship of each path segment in the corresponding path, the obtained path segments are constructed into a node tree, and each node in the node tree contains a path segment.

[0127] S303: Node Similarity Evaluation

[0128] For each level of the node tree, the similarity of the nodes in the level is calculated based on the node attribute characteristics, and when the node similarity is greater than the preset threshold, the corresponding node is added to the same group under the level. The target set is determined based on the groups corresponding to each level and the relationship between the nodes.

[0129] S304: Calculate the similarity of query parameters, request body and response body respectively

[0130] For each target set, determine the similarity of query parameters in each URI contained in the target set, determine the similarity of request bodies in interface access data corresponding to each URI contained in the target set, and determine the similarity of response bodies in interface access data corresponding to each URI contained in the target set.

[0131] S305: Calculate comprehensive similarity

[0132] The comprehensive similarity is determined according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and the preset weight values ​​of each similarity.

[0133] S306: Interface Merge

[0134] When the comprehensive similarity is greater than a preset threshold, it is considered that the API interfaces called by the various URIs included in the target set are the same at the functional and logical levels, and the various URIs included in the target set correspond to the same interface and are regarded as the same API interface asset.

[0135] In an embodiment of the present application, a target set is determined from multiple URIs obtained, the target set includes URIs whose path segment similarity meets the set requirements, and for each target set, the similarity of the query parameters, the corresponding request body, and the corresponding response body is determined respectively, and the comprehensive similarity is determined based on the similarity calculation result and the corresponding weight value. When the comprehensive similarity is greater than a preset threshold, each URI included in the target set is corresponded to the same interface, thereby avoiding the problem of generating redundant and repeated API interface assets due to different query parameters in the URI, and improving the efficiency and accuracy of API interface asset combing.

[0136] The above content describes the method provided by the present application. The following describes the device provided by the present application:

[0137] See also Figure 4 , which is a structural diagram of an interface merging device provided in an embodiment of the present application.

[0138] like Figure 4 As shown, the device may include:

[0139] The acquisition unit 410 is used to acquire a uniform resource identifier URI from the received interface access data;

[0140] A first determining unit 420 is configured to determine a target set from the obtained multiple URIs, wherein the target set includes URIs whose path segment similarities meet a set requirement, wherein the path segments are obtained by segmenting the path portion in the obtained URI according to the path separator;

[0141] A second determining unit 430 is used to determine, for each target set, respectively the similarity of query parameters in each URI included in the target set, the similarity of request bodies in the interface access data corresponding to each URI, and the similarity of response bodies in the interface access data corresponding to each URI;

[0142] A third determining unit 440 is used to determine a comprehensive similarity according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and a preset weight value of each similarity;

[0143] The merging unit 450 is configured to correspond each URI included in the target set to the same interface when the comprehensive similarity is greater than a first preset threshold.

[0144] In some embodiments, the first determining unit 420 is specifically configured to:

[0145] The path part in the obtained URI is split according to the path separator to obtain the path segment;

[0146] According to the hierarchical relationship of each path segment in the corresponding path, the obtained path segments are constructed into a node tree, each node in the node tree contains a path segment;

[0147] For each level of the node tree, the similarity of the nodes in the level is calculated based on the node attribute characteristics, and when the similarity of the nodes is greater than a second preset threshold, the corresponding nodes are added to the same group under the level;

[0148] The target set is determined based on the groups corresponding to each level and the relationship between nodes.

[0149] In some embodiments, the second determining unit 430 is specifically configured to:

[0150] Determine the request body data type corresponding to the target set according to the data type of the request body in the interface access data corresponding to each URI;

[0151] When the request body data type is in JS key-value pair data JSON format, extract JSON frames from the request bodies of the interface access data corresponding to each URI, and calculate the similarity between the JSON frames;

[0152] When the request body data type is a MAP type, extracting sets containing all field names from the request bodies of the interface access data corresponding to each URI, and calculating similarities between the sets;

[0153] In the case that the request body data type is text data, text features are extracted from the request bodies of the interface access data corresponding to the respective URIs, and similarities between the text features are calculated.

[0154] In some embodiments, the second determining unit 430 is specifically configured to:

[0155] Determine the response body data type corresponding to the target set according to the data type of the response body in the interface access data corresponding to each URI;

[0156] When the response body data type is in JSON format, extracting JSON frames from the response bodies of the interface access data corresponding to each URI, and calculating the similarity between the JSON frames;

[0157] In the case where the response body data type is an extensible markup language XML type, extracting XML frames from the response bodies of the interface access data corresponding to each URI, and calculating the similarity between the XML frames;

[0158] In the case that the response body data type is text data, text features are extracted from the response bodies of the interface access data corresponding to each URI, and the similarities between the text features are calculated.

[0159] In some embodiments, the merging unit 450 is specifically configured to:

[0160] Determine a replacement field according to an attribute feature of a target path segment, wherein the target path segment is a path segment whose similarity among the URIs included in the target set meets the set requirement;

[0161] Replacing the target path segment in each URI with the replacement field;

[0162] The replaced URIs are merged, and the merged URIs are made to correspond to the target interface, so that the URIs correspond to the same interface.

[0163] In some embodiments, the merging unit 450 is further configured to:

[0164] In the case where the similarity between the acquired URI and the path segment in the merged URI meets the set requirement, the acquired URI is merged into the merged URI so that the acquired URI corresponds to the target interface.

[0165] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0166] The present application embodiment also provides a hardware structure. Figure 5 , Figure 5 FIG. 1 is a schematic diagram of the hardware structure of an electronic device shown in an exemplary embodiment of the present application. Figure 5 As shown, the hardware structure may include: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application.

[0167] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.

[0168] Exemplarily, the above-mentioned machine-readable storage medium can be any electronic, magnetic, optical or other physical storage device that can contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.

[0169] It should be noted that, in this article, relational terms such as target and target are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0170] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. An interface merging method, characterized in that: The method includes: Obtaining a uniform resource identifier URI from the received interface access data; Determine a target set from the obtained multiple URIs, wherein the target set includes URIs whose path segment similarities meet set requirements, wherein the path segments are obtained by segmenting the path portion of the obtained URI according to the path separator; For each target set, respectively determine the similarity of query parameters in each URI contained in the target set, the similarity of request bodies in interface access data corresponding to each URI, and the similarity of response bodies in interface access data corresponding to each URI; Determining a comprehensive similarity according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and preset weight values ​​of each similarity; When the comprehensive similarity is greater than a first preset threshold, each URI included in the target set is matched with the same interface.

2. The method according to claim 1, characterized in that The determining of the target set from the obtained multiple URIs includes: The path part in the obtained URI is split according to the path separator to obtain the path segment; According to the hierarchical relationship of each path segment in the corresponding path, the obtained path segments are constructed into a node tree, each node in the node tree contains a path segment; For each level of the node tree, the similarity of the nodes in the level is calculated based on the node attribute characteristics, and when the similarity of the nodes is greater than a second preset threshold, the corresponding nodes are added to the same group under the level; The target set is determined based on the groups corresponding to each level and the affiliation between nodes.

3. The method according to claim 1, characterized in that The determining the similarity of the request bodies in the interface access data corresponding to each URI includes: Determine the request body data type corresponding to the target set according to the data type of the request body in the interface access data corresponding to each URI; When the request body data type is in JS key-value pair data JSON format, extract JSON frames from the request bodies of the interface access data corresponding to each URI, and calculate the similarity between the JSON frames; When the request body data type is a MAP type, extracting sets containing all field names from the request bodies of the interface access data corresponding to each URI, and calculating similarities between the sets; In the case that the request body data type is text data, text features are extracted from the request bodies of the interface access data corresponding to the respective URIs, and similarities between the text features are calculated.

4. The method according to claim 1, characterized in that: The determining the similarity of the response bodies in the interface access data corresponding to the respective URIs includes: Determine the response body data type corresponding to the target set according to the data type of the response body in the interface access data corresponding to each URI; When the response body data type is in JSON format, extracting JSON frames from the response bodies of the interface access data corresponding to each URI, and calculating the similarity between the JSON frames; In the case where the response body data type is an extensible markup language XML type, extracting XML frames from the response bodies of the interface access data corresponding to each URI, and calculating the similarity between the XML frames; In the case that the response body data type is text data, text features are extracted from the response bodies of the interface access data corresponding to each URI, and the similarities between the text features are calculated.

5. The method according to claim 1, characterized in that The step of making each URI included in the target set correspond to the same interface includes: Determine a replacement field according to an attribute feature of a target path segment, wherein the target path segment is a path segment whose similarity among the URIs included in the target set meets the set requirement; Replacing the target path segment in each URI with the replacement field; The replaced URIs are merged, and the merged URIs are made to correspond to the target interface, so that the URIs correspond to the same interface.

6. The method according to claim 5, characterized in that After merging the replaced URIs and making the merged URI correspond to the target interface, the method further includes: In the case where the similarity between the acquired URI and the path segment in the merged URI meets the set requirement, the acquired URI is merged into the merged URI so that the acquired URI corresponds to the target interface.

7. An interface merging device, characterized in that: The device includes: An acquisition unit, used for acquiring a uniform resource identifier URI from the received interface access data; A first determining unit is used to determine a target set from the obtained multiple URIs, wherein the target set includes URIs whose path segment similarities meet set requirements, and the path segments are obtained by dividing the path part in the obtained URI according to the path separator; A second determination unit is used to determine, for each target set, respectively the similarity of query parameters in each URI contained in the target set, the similarity of request bodies in the interface access data corresponding to each URI, and the similarity of response bodies in the interface access data corresponding to each URI; A third determining unit, configured to determine a comprehensive similarity according to the similarity of the query parameters, the similarity of the request body, the similarity of the response body, and a preset weight value of each similarity; The merging unit is used to correspond each URI included in the target set to the same interface when the comprehensive similarity is greater than a first preset threshold.

8. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor is used to execute the machine executable instructions to implement the method according to any one of claims 1 to 6.

9. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.