If you accept mocking with other packages than Postman, then I suggest using MockServer or WireMock, both having support for describing matching rules in Java and JSON.
For instance, with WireMock you can match HTTP Request by URL and query string as follows:
Regex matching on path and query
According to Postman docs:
If there is no exact match found, Postman will return the best
matching response based on its algorithm.
I have tested the mock server and it does work with query parameters, however the algorithm points to a default value when you do not mock the parameter. In my case:
?id=1 points to 200 with ok page
?id=2 points to 404 with ...
We have a good experience with json-server. We found it really flexible.
Get a full fake REST API with zero coding in less than 30 seconds
Created with <3 for front-end developers who need a quick back-end for
prototyping and mocking.
It can server from static json files, where each ID returns a ...