Replies: 13 comments
-
This is a great idea indeed! Do you have a specific scenario in mind that we could include in our thinking? |
Beta Was this translation helpful? Give feedback.
-
TBH no. It's an idea that I got when trying to make my kid to go to sleep 😝. But I will think more about it 😁 |
Beta Was this translation helpful? Give feedback.
-
sorry for the lack of response. I did a bit more thinking on this one and: 🔧 How the feature could workSo if we could modify a bit the
The fundamental change here is that we have a collection of possible
So in this case if my app would request a 🤔 What for? (scenario)Lets think of a scenario where I have an app with list of projects and I the test will rename two projects. First with let me know what do you think? 🙂 |
Beta Was this translation helpful? Give feedback.
-
Thank you for sharing the additional information. One challenge that I'm seeing is that if we allow specifying multiple conditions, shall we combine them with an How about if we did this? {
"responses": [
{
"url": "https://customapi/project/rename",
"method": "PATCH",
"headers": {
"sdk": "foo"
},
"body": {
"id": 1
},
"responseBody": {
"id": 1,
"name": "Project 1"
}
},
{
"url": "https://customapi/project/rename",
"method": "PATCH",
"body": {
"id": 2
},
"responseCode": 404
}
]
} Right now, we use the URL as the unique value to match responses. In this new format, we'd use a combination of URL, method, headers and body. For headers and body, we'd use partial matching: all keys and values listed under headers and body must be present in the request, but the request can contain additional keys that aren't listed in the mock. @gavinbarron @sebastienlevert @garrytrinder In the above structure, is it clear enough that {
"responses": [
{
"request": {
"url": "https://customapi/project/rename",
"method": "PATCH",
"headers": {
"sdk": "foo"
},
"body": {
"id": 1
}
},
"response": {
"body": {
"id": 1,
"name": "Project 1"
}
}
}
]
} |
Beta Was this translation helpful? Give feedback.
-
@waldekmastykarz thanks for considering my idea and improving it 🤩. your suggestion is really awesome and quite clear 👍. So giving an example we may have
or better
what do you think ? |
Beta Was this translation helpful? Give feedback.
-
I think that if we follow this reasoning it wouldn't be obvious on the outside and might lead to confusion. I think allowing to specify one condition is less ambiguous even if it comes at the cost of duplicating configuration. As for your second question, GET requests don't have a body. It we really wanted to break it down, we'd need to introduce another property named query and specify the different properties in there. I'm not sure what's the benefit of that and if it doesn't lead to unnecessary complexity. I'd suggest we strive for simplicity and re-evaluate if there are blocking scenarios. Ideally, configuration should be self-explanatory and doesn't require debugging to understand which mock is applied and why. |
Beta Was this translation helpful? Give feedback.
-
In this case for GET parameter I would go in specifying it directly in the
I am also ok with that 👍 making it possible to specify single property is fine and if needed we may always revisit this one and try to extend and then try to rethink should it be |
Beta Was this translation helpful? Give feedback.
-
I like the idea of matching on endpoint + body etc. I would make sure we have a Thoughts? |
Beta Was this translation helpful? Give feedback.
-
@sebastienlevert that might be true. |
Beta Was this translation helpful? Give feedback.
-
That's the beauty of plugins, that when something doesn't necessarily fit what we have in mind, if you have a specific use case that justifies some work, you can build your own plugin and share it with others :) |
Beta Was this translation helpful? Give feedback.
-
Ok. If this is put of scope for MSGraph dev proxy, let us make this a plugin 🙂. @waldekmastykarz are there already some docs or example for plugins in the repo? |
Beta Was this translation helpful? Give feedback.
-
Yes! For the upcoming release, we changed all existing functionality into plugins. Check out the plugins project for what we've got at the moment. Detailed docs are coming soon but if you're stuck at any point, please don't hesitate to reach out. |
Beta Was this translation helpful? Give feedback.
-
Ok great. I guess in that case we may close this one and as soon as find time I will start working on this one |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
💡 Idea
What if it was possible to add a condition to a mock that it should be used only when the request contains a specific value in a specific param (either GET or POST) 🤔?
Currently, I think it is almost possible for GET requests by specifying a full URL of the mock also with params like
https://test/some/reqeuest?param1=aaa
. That way it will only be used when we specify alsoparam1=aaa
in the request right?But for a POST request, this is impossible 🤔. So I was wondering if the
response.json
structure could have some additional property in which the developer could specify a condition when this mock will be used and the condition will be about values set in some specific param.What do you think? TBH I haven't tested the above yet but just wanted to share an idea that I just got for this tool 😅.
📝 Use Case
As for a use case, I was thinking that we may not always want every POST request to fail for the same request. Sometimes it may be required to mock a failed response only when we pass specific data together with the request 🤔.
Beta Was this translation helpful? Give feedback.
All reactions