Repository navigation
fix(mirage-api-detector): read urlPathTemplate stubs and match literal stub paths to declared templates - #293
Merged
Conversation
…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
Owner
Author
|
🎉 This PR is included in version 4.8.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
urlPathTemplateas an OpenAPI-style templateurl/urlPathagainst 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})metadata.operationnames, as the emitter's stubs carryurl'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 pathdetectMirageApisnow collects the declared endpoints before scanning stubs, and passes them to the scannerValidation:
cd mirage-api-detector && ./gradlew check— 161 tests passCloses #292