Skip to content

fix(mirage-api-detector): read urlPathTemplate stubs and match literal stub paths to declared templates - #293

Merged
Arc-E-Tect merged 1 commit into
mainfrom
feat/mirage-api-detector-literal-stub-paths
Sep 28, 2026
Merged

Arc-E-Tect merged 1 commit into
mainfrom
feat/mirage-api-detector-literal-stub-paths

Conversation

@Arc-E-Tect

Copy link
Copy Markdown
Owner

Stub mapping files generated by the API-Only TranscriberJ's WireMock emitter were read wrongly by WireMockStubScanner: its fallbacks (urlPathTemplate) yielded no endpoint, and its exact stubs ("urlPath": "/v1/users/aaaa") were recorded as endpoints of their own instead of as /v1/users/{username}.

Changes:

  • read urlPathTemplate as an OpenAPI-style template
  • match a literal url/urlPath against the declared templates of the stub's own method first, segment by segment; at the first segment where two matching templates differ, a literal segment beats a placeholder, as routing does (/users/me → a declared /users/me, not /users/{id})
  • prefer the declared operation a stub's metadata.operation names, as the emitter's stubs carry
  • ignore a url's query string for this matching, and take the base path off the stub's path before comparing, keeping it on the result so it is stripped like every other stub path
  • the digits-only heuristic applies only where no declared template matches
  • detectMirageApis now collects the declared endpoints before scanning stubs, and passes them to the scanner
  • README section "Matching a stub's id segment…" and the report's stub-evidence preamble describe the new order

Validation:

  • cd mirage-api-detector && ./gradlew check — 161 tests pass

Closes #292

…al stub paths to declared templates

A stub mapping's urlPathTemplate is read as the template it is. A literal
url/urlPath is recorded as the declared template of the stub's method it is an
instance of, with a declared literal segment winning over a placeholder and a
stub's metadata.operation preferred; the digits-only heuristic applies only
where no declared template matches.

Closes #292
@Arc-E-Tect Arc-E-Tect changed the title feat(mirage-api-detector): read urlPathTemplate stubs and match literal stub paths to declared templates fix(mirage-api-detector): read urlPathTemplate stubs and match literal stub paths to declared templates Sep 28, 2026
@Arc-E-Tect
Arc-E-Tect merged commit 4129124 into main Sep 28, 2026
5 checks passed
@Arc-E-Tect
Arc-E-Tect deleted the feat/mirage-api-detector-literal-stub-paths branch September 28, 2026 06:32
Arc-E-Tect added a commit that referenced this pull request Sep 28, 2026
## [4.8.2](mirage-api-detector-v4.8.1...mirage-api-detector-v4.8.2) (2026-09-28)

### 🐛 Bug Fixes

* **mirage-api-detector:** read urlPathTemplate stubs and match literal stub paths to declared templates ([#293](#293)) ([4129124](4129124)), closes [#293](#293) [#292](#292)
@Arc-E-Tect

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 4.8.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mirage-api-detector: read urlPathTemplate stubs, and match literal stub paths to their contract templates

1 participant