Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use value from expression to match specific data #50

Open
bhoppeadoy opened this issue May 30, 2018 · 0 comments
Open

Use value from expression to match specific data #50

bhoppeadoy opened this issue May 30, 2018 · 0 comments

Comments

@bhoppeadoy
Copy link

Is it possible to capture a value from the expression and use that to return specific data? Like a regex capture?

For example, I have this simple mock that returns an array of data that's contained in a file
"expression": "api/solutions"
"response": {
"file": "data/solutions-list.json"
}

Each item in the array has a GUID associated with it. This GUID is used in other API calls, for example this returns an svg for that specific GUID:
api/solutions/([0-9A-Fa-f]{8}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{12})/svg

I'd like to be able to mock it so that the correct svg file is returned based on the GUID in the expression. For example, I could have the response for a file:
"expression": "api/solutions/([0-9A-Fa-f]{8}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{12})/svg"
"response":{
"file": "data/%GUID%.svg"
}

Where %GUID% is the captured GUID from the expression.

Is this possible or is there another way I missed that I can do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant