HTTP interface implementation state detection method and system
By parsing the API list and constructing placeholder requests, combined with reverse state mapping and double-layer 404 checks, the problem of existing tools relying on real data is solved, achieving efficient and accurate interface state detection, suitable for HTTP interfaces that do not require real data detection.
Patent Information
- Application Number
- CN202611377558.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-27
AI Technical Summary
Existing HTTP interface testing tools rely on real data, which makes testing difficult in the early development stages, leads to misjudgments of interface status, authentication interference and inefficiency, and makes it impossible to accurately distinguish 404 status code types.
By parsing the API list from the source code, constructing placeholder requests that are valid in format but do not exist in the business logic, and using reverse state mapping rules and two-layer 404 checks, we can achieve interface state detection without real data.
It improves the efficiency and accuracy of interface detection, enabling automated detection of interface status in the early development stage, distinguishing between routing-level and business-level 404 errors, avoiding authentication interference, and reducing manual configuration and data preparation time.
Smart Images

Figure CN123178271A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of HTTP interface detection technology, specifically relating to an HTTP interface implementation status detection method and system. Background Technology
[0002] In software development and testing, HTTP interface status checks are a crucial step in ensuring service quality and stability. Existing interface testing tools, such as Postman and APIfox, typically require pre-configuration of a real authentication token, a real business ID, and a request body that conforms to business logic. They then determine whether the interface is functioning correctly based on whether the response status code is 2XX. Documentation tools like Swagger focus on verifying whether request parameters conform to data format specifications, usually assuming that the service is running normally and can complete business operations.
[0003] However, the above-mentioned existing technology has the following problems when used: 1. Reliance on real data: The detection process requires logging in and generating test data. In the early development stage or when there is no stable testing environment, it often cannot run smoothly, which limits the applicability of the detection.
[0004] 2. Misjudging the target: Existing tools often confuse "business failure" with "interface not working". For example, if a non-existent ID is passed, the interface returns a 4XX error, which is actually a business data error, but is mistakenly judged as the interface itself being unable to work.
[0005] 3. Authentication interference: For interfaces that require authentication, if no token is provided, the interface returns a 401 error, making it impossible to distinguish whether the problem is with the interface itself or with the authentication configuration, leading to misjudgment.
[0006] 4. Inefficiency: Testing requires generating a large amount of real or semi-real data, which is time-consuming and labor-intensive, and the data preparation process is cumbersome.
[0007] 5. Inaccurate differentiation of 404 status codes: The routing-level 404 (interface not found) and the service-level 404 (data not found) status codes are the same, and existing tools rarely distinguish between them, resulting in inaccurate judgment results. Summary of the Invention
[0008] To address the problems mentioned in the background section, this invention provides an HTTP interface implementation status detection method and system, which features no need for real data, accurate differentiation between interface implementation and business logic, resistance to authentication interference, high efficiency, and intelligent differentiation of 404 types.
[0009] To achieve the above objectives, the present invention provides the following technical solution: a method for implementing state detection in an HTTP interface, comprising the following steps: S1: Parse the list of APIs to be detected from the source code of the target project. Each API must contain at least an HTTP method and a route path. S2: Set the detection intent to no login, no collection of real business data, and no authentication, and set the detection intent parameter to implement the detection mode; S3: Based on the parsed API information, construct a placeholder request with a valid format but not applicable to the business logic, including: generating placeholder values for path parameters and query parameters according to parameter name semantics, attaching a valid placeholder request body to methods that require a request body, and not carrying a valid authentication credential. S4: Send the placeholder request to the target HTTP / HTTPS service and record the response status code and response body text; S5: According to the preset reverse implementation state mapping rules, the response status code and response body text are mapped to the interface implementation status, which includes "implemented", "partially implemented", "not implemented" or "failed". S6: Summarize the status of all detected APIs and calculate the implementation rate and pass rate.
[0010] Furthermore, in step S1, when parsing the list of APIs to be detected, the routing definitions in the source code of the target project are traversed, and the combination of HTTP method and full path is used as the deduplication key to ignore preset irrelevant directories and test files.
[0011] Furthermore, the construction of the placeholder request in step S3 includes: For dynamic parameters in the path (such as :id), replace them with valid placeholder values according to the parameter name characteristics. The placeholder values are not guaranteed to exist in the database. For query parameters, placeholder values are generated based on the semantics of the parameter names; For the POST, PUT, and PATCH methods, the system determines whether to include a placeholder request body based on whether the route handling function contains a request body decorator, and marks whether a valid request body has been included.
[0012] Furthermore, in step S5, the reverse implementation of the state mapping rules is judged sequentially according to priority: If the response status code is 501, or if it is determined to be a routing-level 404, then it is mapped to "not implemented"; If the response status code is 2XX, it is mapped to "implemented"; If the response status code is 401 or 403, it is mapped to "implemented"; If the error is determined to be a business-level 404, it is mapped to "implemented". If the response status code is 400, 422, or 409, it is mapped to "implemented". If the response status code is 5XX, and the HTTP method is POST / PUT / PATCH and a valid request body is included, then it is mapped to "partial implementation"; If the response status code is 5XX but the previous condition is not met, it is mapped to "failure"; The remaining 4XX status codes are mapped to "partial implementation"; Other cases are mapped as "failure".
[0013] Furthermore, for the case of a response status code of 404, a two-layer decision is performed: First level: If the response body indicates that the requested HTTP method and path do not exist in the server's routing table, it is determined as a route-level 404, mapped to "not implemented"; Second layer: If the response body indicates that the routing process has been executed but the business entity does not exist, it is determined to be a business-level 404, mapped to "implemented"; If it cannot be categorized into the two layers mentioned above, it is mapped as "partial implementation".
[0014] Furthermore, in step S2, under the detection mode, automatic login is not performed, no real business data is collected, and no valid token that can be used to pass authentication is added to the request.
[0015] Furthermore, the rules for generating placeholder values in step S3 are as follows: for parameter names containing "email", a valid test email address is generated; for those containing "password", a placeholder password that meets common verification rules is generated; for those ending with "id" or containing "id", a placeholder value in numeric ID or ObjectId format is generated; for those containing "slug", a placeholder slug is generated; for those containing "file" or "filename", a placeholder filename is generated; and for other parameters, a default numeric placeholder ID is generated.
[0016] Furthermore, in step S4, when sending a request, it is configured to accept any HTTP status code and not interrupt the request due to 4XX or 5XX status codes; the timeout for a single request is preset to 120 seconds, and the timeout for service reachability pre-check is preset to 30 seconds; the target address without a protocol header is automatically filled with http: / / .
[0017] An HTTP interface implementation status detection system, comprising: The interface enumeration module is used to parse the list of APIs to be tested from the source code of the target project; The request construction module is used to construct a placeholder request for each API that is in a valid format but does not exist in the business logic, without carrying a valid authentication credential, in the probe mode. The request execution module is used to send the placeholder request to the target service and collect the response status code and response body; The state mapping module is used to map the response result to "implemented", "partially implemented", "not implemented" or "failed" according to the preset reverse implementation state mapping rules. The 404 status determination module is used to perform two-layer determination for the case of a response status code of 404, distinguishing between routing-level 404 and service-level 404; The results output module is used to summarize the status of each API and calculate the implementation rate and pass rate.
[0018] Furthermore, the mapping rules adopted by the state mapping module are as follows: authentication rejection (401 / 403) is treated as "implemented", and server internal errors (5XX) are mapped as "partially implemented" or "failed" depending on whether they carry a valid request body, and the requirement to return 2XX is not taken as a condition for passing.
[0019] Compared with the prior art, the beneficial effects of the present invention are: 1. This invention generates valid placeholder data in a specific format through a request construction module. It does not require login to obtain a valid token or pre-preparation of real business data in the database. Interface detection can be completed in the early stages of project development, thus improving interface detection efficiency.
[0020] 2. This invention sets up a 404 discrimination submodule to perform two-layer judgment on 404 responses, distinguishing between routing-level 404 and service-level 404, solving the problem of confusion in the meaning of the same 404 status code, and improving the accuracy of interface implementation status judgment.
[0021] 3. This invention uses reverse pass-through logic. If the authentication interception returns 401 or 403, it does not determine that the interface is not implemented. This can distinguish between two scenarios: authentication interception and the interface itself not being fully developed.
[0022] 4. This invention determines internal errors in the 5XX service of the write interface carrying a valid request body as partial implementation, identifies that routing and parameter validation have been completed, and the fault occurs in the business layer interface, thus avoiding the misjudgment that the interface is not fully implemented.
[0023] 5. This invention automatically parses the API list from the source code, eliminating the need for manual configuration and improving detection efficiency and automation. Attached Figure Description
[0024] Figure 1 This is a schematic diagram of the system structure of the present invention; Figure 2 This is a flowchart of the method of the present invention; Figure 3 This is a schematic diagram of the upper half of the reverse implementation state mapping decision flowchart of the present invention; Figure 4This is a schematic diagram of the lower half of the reverse implementation state mapping decision flowchart of the present invention; Figure 5 This is a schematic diagram illustrating the determination of the double-layer 404 structure according to the present invention; Figure 6 This is a schematic diagram illustrating the construction of the present invention without real data requests. Detailed Implementation
[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] Example 1: Overall Method Flow Please see Figure 1-6 This invention provides a method for implementing state detection in an HTTP interface, comprising the following steps: S1: Parse the list of APIs to be tested from the target project's source code. Specifically, it iterates through the project's source code, identifies route definitions for different frameworks (such as Nest.js, Express, Fastify, Spring, etc.), extracts HTTP methods (GET, POST, PUT, PATCH, DELETE, etc.) and route paths (such as / api / users / :id), and removes duplicates using "method:path" as the unique key. By default, directories such as node_modules, dist, build, .git, and coverage, as well as test files such as *.test.*, *.spec.*, and __tests__, are ignored. Additionally, paths defined in the OpenAPI / Swagger documentation can be merged to supplement interfaces not directly declared in the source code.
[0027] S2: Set the detection intent to "implementation" (probeIntent='implementation'). In this mode, automatic login is not performed, no real business data is collected, and no valid authentication token is carried.
[0028] S3: Construct a placeholder request for each API. The specific construction method is as follows: For dynamic parameters (such as :id) in the path and query parameters, generate placeholder values with valid formats but not guaranteed to exist in the database based on the semantics of the parameter names (e.g., id→1234567890, email→probe.user@example.com).
[0029] For POST, PUT, and PATCH methods, determine whether a request body is required (by parsing the @Body decorator in the source code, etc.). If required, generate a valid placeholder JSON object (for known public form routes, a predefined minimum required template can be used); otherwise, no request body is attached. Simultaneously, mark whether a valid request body (V) has been included.
[0030] The request header does not include the Authorization field, or it is filled with an obviously invalid placeholder token.
[0031] S4: Sends a request to the target service, recording the response status code (S) and response body text (B). The request is configured to accept any HTTP status code (without throwing exceptions for 4xx / 5xx), and the timeout is preset to 120 seconds. Addresses without protocol headers are automatically completed to http: / / .
[0032] S5: According to the reverse implementation state mapping rule (see Example 2), map (M, S, B, V) to "passed", "partial", "not_implemented", or "failed". In particular, for S=404, perform a two-layer decision (see Example 3).
[0033] S6: Summarize the states of all APIs, count the number of each type of state, and calculate: Implementation rate = (Number of implemented APIs + Number of partially implemented APIs + Number of failed APIs) / Total number of discovered APIs × 100%; Pass rate = number of implemented / (number of tested - number of unimplemented) × 100%, where the number of tested does not include the "untested / skipped" status.
[0034] Example 2: Reverse implementation of state mapping rules Please see Figure 3 Let the request method be M, the status code be S, the response body text be B, and whether it carries a valid request body be V. The following priority rules apply: Example 3: Double-layer 404 determination When S=404, the following decision is made: (1) First layer - Routing level 404 (not implemented): If the response body clearly indicates that the requested HTTP method and path do not exist in the server routing table (for example, it contains words such as "CannotGET / api / xxx" or "CannotPOST...", or clearly indicates "notfound" and cannot match the business entity), it is determined to be a routing level 404 and mapped to "not implemented".
[0035] (2) Second layer - business level 404 (implemented): If the response body indicates that the routing process has been executed, but the business entity does not exist (e.g., it contains "not found", "NotFoundException", "notfound" and excludes routing level semantics), it is determined to be a business level 404 and mapped to "implemented".
[0036] (3) Other 404: If it cannot be classified into the above two categories, it is judged as "partial implementation" and it is recommended to manually confirm it later.
[0037] Example 4: Rules for Generating Valid Format Placeholder Parameters This example details the strategy for generating placeholder values. Please refer to [link / reference]. Figure 5 For different parameter name features, generate corresponding placeholder patterns: Example: Path / api / users / :id→ / api / users / 1234567890; Request body {"productId":"1234567890","quantity":1}.
[0038] Example 5: Authentication failure is not considered as not being implemented. Request: GET / api / admin / list, no valid token provided. Response: 401. According to R3, this is determined to be "implemented," indicating that the interface itself has been registered and can be called, but authentication has failed.
[0039] Example 6: Server error detection is partially implemented Request: POST / api / orders, with a valid placeholder request body {"productId":"1234567890","quantity":1}, but the database connection failed. Response: 500. Since M is POST and V=true, it satisfies R6, and is judged as "partially implemented," indicating that the interface routing and parameter validation passed, but the downstream dependency is abnormal.
[0040] Example 7: Comprehensive Deduction Example 8: System Composition Please see Figure 1 The system of the present invention includes:
[0041] The modules work together to achieve fully automated, data-independent interface status detection.
[0042] Example 9: Technical Solution Code Step (1): Check the list of APIs to be checked in the source code. / **Deduplication = HTTP method + full path* / functiondiscoverApis(projectPath:string):DiscoveredApi[]{ constapis:DiscoveredApi[]=[]; constseen = new Set <string>(); for (const file of findSourceFiles(projectPath, { ignore: ['node_modules', 'dist', 'build', '.git', 'coverage'], })) { const content = readFile(file); / / Nest: @Controller + @Get / @Post / ...; Express / Fastify / Spring are parsed in the same way for (const api of ...parseNest(content, file), ...parseExpress(content, file), ...parseFastify(content, file), ...parseSpring(content, file), ) { const key = `${api.method}:${api.fullPath}`; / / e.g., GET: / users / :id if (!seen.has(key)) { seen.add(key); apis.push({ ...api, id: key, line: api.line}); } } } / / Merge paths from candidate documents such as openapi.json / swagger.yaml for (const api of parseOpenApiDocs(projectPath)) { const key = `${api.method}:${api.fullPath}`; if (!seen.has(key)) { seen.add(key); apis.push(api); } } returnapis; } Step (2): Set the detection intent to be no login, no collection of real business data, and no authentication. typeProbeIntent='implementation'|'functional'; constconfig={ probeIntent: 'implementation' as ProbeIntent, / / Default implementation of probe timeoutMs:120_000, }; functionprepareContext(intent:ProbeIntent,ctx:{authToken?:string;seeds:Record<string,string>}){ if(intent==='functional'){ ctx.authToken = autoLogin() || ctx.authToken; / / Check: Login is possible harvestSeeds(ctx); / / Reference: Real IDs can be collected }else{ / / ★Detection Implementation: No login required, no collection of real business ID, and no subsequent use of a valid token. ctx.authToken=undefined; ctx.seeds={}; } } Step (3): Construct a placeholder request / ** Generates a valid format based on parameter name semantics, without requiring a value to exist in the library. * / functionformatParamValue(paramName:string):string{ constlower=paramName.toLowerCase(); if(lower.includes('email'))returnFORMAT_FIXTURES.email; if(lower.includes('password'))returnFORMAT_FIXTURES.password; if(lower.includes('file')||lower.includes('filename'))returnFORMAT_FIXTURES.fileName; if(lower.includes('slug'))returnFORMAT_FIXTURES.slug; if(lower.endsWith('id')||lower==='id'){ returnlower.includes('industry')||lower.includes('product') ?FORMAT_FIXTURES.objectId :FORMAT_FIXTURES.numericId; } returnFORMAT_FIXTURES.numericId; } / **Controller parsing window: handler line -25 ~ +35, extract @Query / @Param / @Body / authentication* / functionparseControllerHints(fileContent:string,handlerLine:number){ constlines=fileContent.split('\n'); constblock=lines.slice(Math.max(0,handlerLine-25),Math.min(lines.length,handlerLine+35)).join('\n'); constrequiresAuth= ! / @Public\s*\( / .test(block)&& ( / JwtAuthGuard / .test(block)|| / @ApiBearerAuth / .test(block)); / / ...parse queryParams, paramNames, hasBody return{requiresAuth,queryParams:[]asstring[],hasBody: / @Body\s*\( / .test(block)}; } / **: id → placeholder; use a minimum required field template for public forms; implement detection without merging real seeds * / functionbuildProbePlan(method:string,routePath:string,hints:ReturnType <typeofparsecontrollerhints>){ const pathParams: Record<string, string> = {}; for (const token of routePath.match( / :([a-zA-Z_][a-zA-Z0-9_]*) / g) || []) { pathParams[token.slice(1)] = formatParamValue(token.slice(1)); } let body: unknown; if (['POST', 'PUT', 'PATCH'].includes(method)) { if (routePath.includes(' / contact / submit')) { body = { name: 'XELC Probe User', phone: '13800138000', email: FORMAT_FIXTURES.email, company: 'XELC Probe Co', message: 'xelc implementation probe message', }; } else { body = hints.hasBody ? {} : undefined; } } return { pathParams, body, requiresAuth: hints.requiresAuth}; } / ** URL = baseUrl + prefix + path after replacement; * → placeholder * / function buildRequestUrl(baseUrl: string, routePath: string, prefix?: string, pathParams?: Record<string, string>) { letroute=routePath.replace( / :([a-zA-Z_][a-zA-Z0-9_]*) / g,(_,n)=> encodeURIComponent(pathParams?.[n]??formatParamValue(n)), ).replace( / \* / g,'placeholder'); if(prefix&&!route.startsWith(prefix))route=`${prefix}${route}`; return`${baseUrl.replace( / \ / $ / ,'')}${route}`; } Step (4): Send an HTTP / HTTPS request and record the status code and response body. constSUPPORTED_LIVE=newSet(['http','https']); functionnormalizeBaseUrl(baseUrl:string):string{ return baseUrl.includes(': / / ')?baseUrl:`http: / / ${baseUrl}`; / / Defaults to http if no scheme is specified } asyncfunctionrunHttpProbe(api:DiscoveredApi,plan:ReturnType <typeofbuildprobeplan>, cfg: typeof config) { const url = buildRequestUrl(cfg.baseUrl, api.fullPath, cfg.apiPrefix, plan.pathParams); const headers: Record<string, string> = { Accept: 'application / json'}; / / ★Probe implementation: No valid Token is attached (it is also optional to set headers.Authorization='Bearer ' + FORMAT_FIXTURES.probeBearer) const body = plan.body; const hasValidBody = body != null && !(typeof body === 'object' && Object.keys(body as object).length === 0); const response = await httpRequest({ url, method: api.method, headers, data: body, timeout: cfg.timeoutMs, / / 120000 acceptAnyStatus: true, / / 4xx / 5xx errors are still collected without throwing an exception }); const bodyText = typeof response.data === 'string' ? response.data : JSON.stringify(response.data ?? ''); return { method: api.method, / / M httpStatus: response.status, / / S bodyText, / / B hasValidBody, / / V responseTimeMs: response.elapsed, }; } Step (5): Map the state according to the detection decision table (including double-layer 404). typeImplStatus='passed'|'partial'|'not_implemented'|'failed'; / / Implemented / Partially implemented / Not implemented / Failed functionisRouteNotFound(status:number,body:string):boolean{ return( status===404&& ( / cannot\s+(get|post|put|patch|delete) / i.test(body)|| ( / Cannot / i.test(body)&& / notfound / i.test(body))) ); } functionisBusinessNotFound(status:number,body:string):boolean{ If (status !== 404) return false; return / not found|notfound|NotFoundException|not found / i.test(body)&&!isRouteNotFound(status,body); } / **Priority: R1→R10, corresponding to Example 2* / functionevaluateImplementationProbe( M:string, S: number, B: string, V:boolean, ):ImplStatus{ if(S===501||isRouteNotFound(S,B))return'not_implemented'; / / R1 if(S>=200&&S<300)return'passed'; / / R2 if(S===401||S===403)return'passed'; / / R3 reverse authentication passed if(isBusinessNotFound(S,B))return'passed'; / / R4 if(S===400||S===422||S===409)return'passed'; / / R5 if(S>=500){ if(['POST','PUT','PATCH'].includes(M)&&V)return'partial'; / / R6 return'failed'; / / R7 } if(S===404)return'partial'; / / R8 if(S>=400)return'partial'; / / R9 return'failed'; / / R10 } Step (6): Aggregate interface status functionbuildSummary(totalApis:number,results:{status:ImplStatus|'untested'|'skipped'}[]){ constpassed=results.filter((r)=>r.status==='passed').length; constfailed=results.filter((r)=>r.status==='failed').length; constpartial=results.filter((r)=>r.status==='partial').length; constnotImplemented=results.filter((r)=>r.status==='not_implemented').length; consttestedCount=results.filter((r)=>!['untested','skipped'].includes(r.status)).length; / / Implementation rate: Route reachability (including implemented, partially implemented, and failed) / Total number of discoveries constimplementedCount=passed+partial+failed; constimplementationRate= totalApis>0?Number(((implementedCount / totalApis)*100).toFixed(1)):0; / / Pass rate: Implemented / (Tested - Not Implemented) constcountableForPass=testedCount-notImplemented; constpassRate= countableForPass>0?Number(((passed / countableForPass)*100).toFixed(1)):0; return{passed,failed,partial,notImplemented,implementationRate,passRate}; } The code above is only a schematic of the core logic; the actual implementation can be adjusted according to the specific framework.
[0043] The HTTP request library, file traversal, route parsing, etc. involved in this invention are all existing mature technologies and can be implemented using axios, fs, glob, etc. The specific model and version do not affect the core protection scope of this invention.
[0044] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.< / typeofbuildprobeplan> < / typeofparsecontrollerhints> < / string>
Claims
1. A method for implementing state detection in an HTTP interface, characterized in that, Includes the following steps: S1: Parse the list of APIs to be detected from the source code of the target project. Each API must contain at least an HTTP method and a route path. S2: Set the detection intent to no login, no collection of real business data, and no authentication, and set the detection intent parameter to implement the detection mode; S3: Based on the parsed API information, construct a placeholder request with a valid format but not applicable to the business logic, including: generating placeholder values for path parameters and query parameters according to parameter name semantics, attaching a valid placeholder request body to methods that require a request body, and not carrying a valid authentication credential. S4: Send the placeholder request to the target HTTP / HTTPS service and record the response status code and response body text; S5: According to the preset reverse implementation state mapping rules, the response status code and response body text are mapped to the interface implementation status, which includes "implemented", "partially implemented", "not implemented" or "failed". S6: Summarize the status of all detected APIs and calculate the implementation rate and pass rate.
2. The HTTP interface implementation status detection method according to claim 1, characterized in that, In step S1, when parsing the list of APIs to be tested, the routing definitions in the source code of the target project are traversed, and the combination of HTTP method and full path is used as the deduplication key, ignoring the preset irrelevant directories and test files.
3. The method according to claim 1, characterized in that, The construction of the placeholder request in step S3 includes: For dynamic parameters in the path (such as :id), replace them with valid placeholder values according to the parameter name characteristics. The placeholder values are not guaranteed to exist in the database. For query parameters, placeholder values are generated based on the semantics of the parameter names; For the POST, PUT, and PATCH methods, the system determines whether to include a placeholder request body based on whether the route handling function contains a request body decorator, and marks whether a valid request body has been included.
4. The HTTP interface implementation status detection method according to claim 1, characterized in that, The reverse implementation of the state mapping rules in step S5 is judged in order of priority: If the response status code is 501, or if it is determined to be a routing-level 404, then it is mapped to "not implemented"; If the response status code is 2XX, it is mapped to "implemented"; If the response status code is 401 or 403, it is mapped to "implemented"; If the error is determined to be a business-level 404, it is mapped to "implemented". If the response status code is 400, 422, or 409, it is mapped to "implemented". If the response status code is 5XX, and the HTTP method is POST / PUT / PATCH and a valid request body is included, then it is mapped to "partial implementation"; If the response status code is 5XX but the previous condition is not met, it is mapped to "failure"; The remaining 4XX status codes are mapped to "partial implementation"; Other cases are mapped as "failure".
5. The HTTP interface implementation status detection method according to claim 4, characterized in that, For cases with a 404 response status code, perform a two-layer decision: First level: If the response body indicates that the requested HTTP method and path do not exist in the server's routing table, it is determined as a route-level 404, mapped to "not implemented"; Second layer: If the response body indicates that the routing process has been executed but the business entity does not exist, it is determined to be a business-level 404 and mapped to "implemented"; If it cannot be categorized into the two layers mentioned above, it is mapped as "partial implementation".
6. The HTTP interface implementation status detection method according to claim 1, characterized in that, In the detection mode described in step S2, automatic login is not performed, no real business data is collected, and no valid token that can be used to pass authentication is added to the request.
7. The HTTP interface implementation status detection method according to claim 1, characterized in that, The rules for generating placeholder values in step S3 are as follows: For parameter names containing "email", a valid test email address is generated; for those containing "password", a placeholder password that meets common verification rules is generated; for those ending with "id" or containing "id", a placeholder value in numeric ID or ObjectId format is generated; for those containing "slug", a placeholder slug is generated; for those containing "file" or "filename", a placeholder filename is generated; and for other parameters, a default numeric placeholder ID is generated.
8. The HTTP interface implementation status detection method according to claim 1, characterized in that, When sending a request in step S4, it is configured to accept any HTTP status code and not interrupt the request due to 4XX or 5XX status codes; the timeout for a single request is preset to 120 seconds, and the timeout for service reachability pre-check is preset to 30 seconds; the target address without a protocol header is automatically filled with http: / / .
9. A system for implementing a state detection method for an HTTP interface according to any one of claims 1-8, characterized in that, include: The interface enumeration module is used to parse the list of APIs to be tested from the source code of the target project; The request construction module is used to construct a placeholder request for each API that is in a valid format but does not exist in the business logic, without carrying a valid authentication credential, in the probe mode. The request execution module is used to send the placeholder request to the target service and collect the response status code and response body; The state mapping module is used to map the response result to "implemented", "partially implemented", "not implemented" or "failed" according to the preset reverse implementation state mapping rules; The 404 status determination module is used to perform two-layer determination for the case of a response status code of 404, distinguishing between routing-level 404 and service-level 404; The results output module is used to summarize the status of each API and calculate the implementation rate and pass rate.
10. The HTTP interface implementation status detection system according to claim 9, characterized in that, The mapping rules adopted by the state mapping module are as follows: authentication rejection (401 / 403) is treated as "implemented", and server internal errors (5XX) are mapped as "partially implemented" or "failed" depending on whether they carry a valid request body, and the requirement to return 2XX is not a condition for passing.
