subasraj / flashpost-support

Flashpost is a lightweight Rest API Client Extension for Visual Studio Code.
MIT License
10 stars 0 forks source link

More functionallity with "Set the variables from the response" and "Json Response" parameter #23

Closed twilkinson closed 7 months ago

twilkinson commented 8 months ago

I like your plugin but it would be more useful if the "value" for "Json Response" was more complete.

For example:

  1. if the parameter 'value' name references a response property that is 0 or "", the variable name is not set
  2. if the parameter 'value' is set using double quotes (e.g., "name") then the variable name is not set

Thanks,

subasraj commented 8 months ago

Can you please send me response sample for 2

twilkinson commented 8 months ago

URL: https://api.openweathermap.org/data/2.5/onecall?appid=9e0157329feb9f7fbf6fe386031870de&lat=43&lon=-83

REQUEST: image

RESPONSE: image

ENVIRONMENT: image

variable timezone_q is not set

subasraj commented 8 months ago

Why do you want to do “timezone” when timezone works. Is the a reason behind that.

twilkinson commented 8 months ago

It's just a test. I'm thinking of a case where the response Json has names with special characters in them, for example:

{ "first:last": "Joe Smith", "first.last": "Joe Smith" }

subasraj commented 7 months ago

@twilkinson I have fixed it now pls try like this below image

image

twilkinson commented 7 months ago

That's a lot better! I see you're now correctly setting values where the response property is 0 - great!

The only thing remaining is that it doesn't seem to save the value where the response property is either of

  1. zero-length string like "" OR
  2. the null value

For example it doesn't seem to save the following value, image OR image

from the RESPONSE image

Otherwise, it's looking great!

subasraj commented 7 months ago

@twilkinson i don't think we should save null or empty string parameters.

twilkinson commented 7 months ago

What's your reason for that? They are values after all :-)

subasraj commented 7 months ago

Ok 🙂 @twilkinson i will include them. Please give me a review when you get a chance.

twilkinson commented 7 months ago

Thanks for the quick responses.

I have come across a real-world example that I think can only be handled if you support quoted parameter values when setting variables.

I need to reference the url object marked with the magenta arrow in this response: image

I think it has to be referenced using quotes, like this. assets."https!!!devtest!driftscape!com!newsatlas!branding!drift!favicon.png".url

The current syntax (below, without the quotes) won't work because of the .png in the object name. assets.https!!!devtest!driftscape!com!newsatlas!branding!drift!favicon.png.url

You've done a great job with this VS Extension and I think with these changes it can become a workable alternative to Postman. Then I'll be happy give a good review.

subasraj commented 7 months ago

Please try now with version 1.1.74

image image

twilkinson commented 7 months ago

Please have a look at these tests: TEST image

RESPONSE image

TEST RESULTS image

I think the two that Failed should have Passed?

subasraj commented 7 months ago

Please have a look at these tests: TEST image

RESPONSE image

TEST RESULTS image

I think the two that Failed should have Passed?

@twilkinson Please try now

subasraj commented 7 months ago

Please try now with version 1.1.74

image image

@twilkinson Did you try this fix ?

twilkinson commented 7 months ago

@subasraj That fixed things - thanks again for your quick response.

subasraj commented 7 months ago

@twilkinson Thanks for the review :)