[GH-ISSUE #5980] [feature]: Mock Server — Variable resolution and dynamic response body substitution #2351

Open
opened 2026-03-17 00:02:33 +03:00 by kerem · 0 comments
Owner

Originally created by @ajsead on GitHub (Mar 13, 2026).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/5980

Is there an existing issue for this?

  • I have searched the existing issues

Summary

Currently the Mock Server matches requests and returns static response bodies. There is no support for variable substitution in response bodies, and query parameters containing Hoppscotch variable syntax (<<variable>>) are never treated as wildcards during example matching — causing valid examples to fail to match incoming requests.

  • Using x-mock-response-name header to bypass scoring — works as a workaround but requires hardcoding example names in every request

Second, response bodies are always static — there is no variable substitution, so request values like path variables, query params, or body fields can never be reflected back in the response. This makes the mock server impractical for simulating realistic dynamic API behavior.

Why should this be worked on?

Two concrete problems today:

1. Query param matching breaks with variables

If an example endpoint is defined as:

<<base-url>>/search?query=<<query>>

The value <<query>> is compared literally against the actual request value (e.g. shoes), resulting in a partialMatches penalty and potentially a zero score. The example is never selected.

2. Response body is always static

formatExampleResponse returns responseBody as-is with no substitution. There is no way to reflect request values (path variables, query params, body fields) back in the response, making the mock server less useful for dynamic API simulation.

Originally created by @ajsead on GitHub (Mar 13, 2026). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/5980 ### Is there an existing issue for this? - [x] I have searched the existing issues ### Summary Currently the Mock Server matches requests and returns static response bodies. There is no support for variable substitution in response bodies, and query parameters containing Hoppscotch variable syntax (`<<variable>>`) are never treated as wildcards during example matching — causing valid examples to fail to match incoming requests. - **Using `x-mock-response-name` header** to bypass scoring — works as a workaround but requires hardcoding example names in every request Second, response bodies are always static — there is no variable substitution, so request values like path variables, query params, or body fields can never be reflected back in the response. This makes the mock server impractical for simulating realistic dynamic API behavior. ### Why should this be worked on? Two concrete problems today: **1. Query param matching breaks with variables** If an example endpoint is defined as: ``` <<base-url>>/search?query=<<query>> ``` The value `<<query>>` is compared literally against the actual request value (e.g. `shoes`), resulting in a `partialMatches` penalty and potentially a zero score. The example is never selected. **2. Response body is always static** `formatExampleResponse` returns `responseBody` as-is with no substitution. There is no way to reflect request values (path variables, query params, body fields) back in the response, making the mock server less useful for dynamic API simulation.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#2351
No description provided.