class EndpointOptimizer
- EndpointOptimizer
- Reference
- Object
Overview
Endpoint optimization module that handles endpoint deduplication, URL combination, and path parameter extraction
Direct Known Subclasses
Defined in:
optimizer/optimizer.crConstant Summary
-
ABSOLUTE_URL_RE =
/\A[a-zA-Z][a-zA-Z0-9+.\-]*:\/\// -
A URL that already carries its own scheme + authority (e.g.
https://host/path). The HAR / OAS detectors emit these, so the optimizer must not prepend a target, collapse the//after the scheme, or treat the leading segment as a path. -
COLLECTION_NOISE_HEADERS =
Set {"user-agent", "accept", "content-type", "host", "origin", "referer", "x-requested-with"} -
Generic request headers a browser/HTTP client always sends; they carry no endpoint-specific signal, so collection imports that surface them as params are treated as noise during dedup.
-
PROJECT_MANIFEST_FILES =
{"pom.xml", "build.gradle", "build.gradle.kts", "settings.gradle", "settings.gradle.kts", "shard.yml", "package.json", "go.mod", "Cargo.toml", "pyproject.toml", "mix.exs"}
Constructors
Instance Method Summary
-
#add_path_parameters(endpoints : Array(Endpoint)) : Array(Endpoint)
Add path parameters by parsing URL patterns
-
#apply_pvalue(param_type, param_name, param_value) : String
Apply parameter values based on configuration
-
#combine_url_and_endpoints(endpoints : Array(Endpoint)) : Array(Endpoint)
Combine target URL with endpoints
-
#normalize_url_shapes(endpoints : Array(Endpoint)) : Array(Endpoint)
Normalize cross-framework URL shapes the analyzers can't always resolve without language context.
-
#optimize(endpoints : Array(Endpoint)) : Array(Endpoint)
Main optimization workflow - calls all optimization steps
-
#optimize_endpoints(endpoints : Array(Endpoint)) : Array(Endpoint)
Remove duplicated endpoints and parameters, validate HTTP methods, clean URLs
Constructor Detail
Instance Method Detail
Add path parameters by parsing URL patterns
Apply parameter values based on configuration
Combine target URL with endpoints
Normalize cross-framework URL shapes the analyzers can't always
resolve without language context. Rewrites a small set of well-
known leaky forms into the canonical {name} placeholder so the
downstream #add_path_parameters pass picks them up as path
params instead of literal noise.
Covered shapes:
(?P<name>pattern)— Pythonre_path-style named groups. Bleeds through Django'sre_pathroute table; rewrite to{name}and drop the regex body.${name}/${obj.field}— JS/TS template literals that analyzers can't statically resolve (handler files reference captured variables, not literal paths). Rewrite to{name}(or{field}for${obj.field}) so the AI/output payload surfaces it as a path placeholder rather than as a literal${...}segment.- Python regex anchors
^(leading) and$/\Z(trailing) —re_pathpatterns commonly include these. - Python regex backslash-escaped dots
\.— rewrite to plain.for the visible URL. - Spring
{name:regex}— strip the inline regex constraint so the placeholder is{name}regardless of framework dialect. - Postman / Express-style
:namepath segments — rewrite to{name}so collections merge with framework analyzers that already emit the canonical placeholder shape.
Main optimization workflow - calls all optimization steps
Remove duplicated endpoints and parameters, validate HTTP methods, clean URLs