Comments (13)
rest-client does this with IntelliSense for variables
rest-client does this, but you should have seen how many times I have got an breakpoint/ interrupt while debugging on my NodeJS PR (674). One keypress in the http file and +10 rechecking of the variables
I understand your concern. I have included exactly the command for troubleshooting. I run the request, and on errors I can look what variables are defined. You want to check the variables before sending and that makes sense for critical requests. I just don't quite like the way it works yet. I would rather implement the solution via DebugAdapater, but I don't have the time. Until then I'll implement my own command validateVariables
, which prepares the request, resolves all variables but doesn't send the actual request them.
from vscode-httpyac.
Here you can find an example how the use of a .httpyac.json would look like.
But unfortunately there is a bug. Currently the settings from the file are loaded but not used. I didn't notice it because I use .env files myself.
from vscode-httpyac.
Thanks, I appreciate the correction on the format of the file, and I'll wait for the bug fix to hit the released version.
Can you please clarify where I should be able to put the file? Is it the same locations as for .env?
from vscode-httpyac.
(As a side note, it would be nice if I could hover over variables in the .http file to see the resolved value, or an error if the variable can't be found. Currently, I have to submit the request and see the resulting error to suss out any problems.)
I've been thinking about this feature for a while, but I don't have an idea yet how to solve this without unreasonably high CPU and Memory consumption. The only way I can correctly determine all variables is to execute the request on every change in a http file.
- Variables defined in Javascript. Scripts loaded by require can also set variables.
- References to other responses, because here the return type is not known
- Environment variables loaded from e.g. Spring Config Cloud or Hashicorp Vault, which are different depending on selected environment (maybe cachable?).
I do not want to include this function only so half ready. vscode-restclient tries to implement this feature and has as a consequence the performance problems.
As a solution I have currently built in that you can display the current variables (command httpyac.showVariables
). I will wrap this soon in a TreeDataProvider. I am open for good ideas.
from vscode-httpyac.
Yes, I'm currently using rest-client but looking to switch because of all the goodies your extension offers. Intellisense evaluation of variables is one thing I do miss from rest-client; it lets me verify that I'm loading the correct values before I send the request. I understand that it's more complicated for your extension because of all the extra ways that variables can be set.
How about something like a CodeLens link to display the variable values for the current request?
from vscode-httpyac.
I will add a CodeLens link für the command httpyac.showVariables
. I would have thought of CompletionItemProvider (better IntelliSense) as well, but just haven't gotten around to it yet.
from vscode-httpyac.
Vielen Dank!
from vscode-httpyac.
Es war mir eine Freude:-)
I have provided the update. Can you please also test it and give feedback?
Can you please clarify where I should be able to put the file?
.httpyac.js
or .env
are searched the directory tree upwards (till root). First found location is used.
from vscode-httpyac.
Variable resolution with .httpyac.json seems to work as expected.
The 'show variables' link appears at the top of the file, and it doesn't take into account global variables in that file (or per-request variables). Is that the intent? I was picturing a link for each request, showing (as best as possible) everything in scope for that request.
'show variables' also opens an untitled document window, and then vscode prompts me to save when I close it.
from vscode-httpyac.
showVariables
just shows the current state of the variables. No code is executed during this process. You can simply execute the request and then view the variables.
An alternative would be to install httpyac on the command line and view the variables using {{debugger;}} (see docs).
I prevent the unexpected execution so explicitly, because I also create database entries in scripts, or combine writing services. However, in my cases I also have >80% of the variables in .env files and the remaining variables are generated in the same file, so it is easy for me to know the correct names. Do you dynamically create the variables in the NodeJs scripting part that it is difficult to know all the variable names present?
from vscode-httpyac.
I understand about the limitations -- variables could come from anywhere, and you don't want to run all of the associated scripts in order to generate those.
All of my variables are either in .httpyac.json or in the .http file itself. With the 'show variables' link at the top of the file, I would expect at least that variables from the global section of the file would be evaluated. Instead, it looks like only json/.env variables are evaluated.
I think it would also be more useful to have this link for each request, and then to include in evaluation the per-request variables.
My goal is to be able to determine, before running a request, the values assigned to variables. This helps in troubleshooting, because it lets me see if maybe I've screwed up the inheritance chain. rest-client does this with IntelliSense for variables; I understand that you don't want to do this because of the overhead.
from vscode-httpyac.
The command httpyac.validateVariables
was rolled out with the new version.
from vscode-httpyac.
Looks great, thanks!
from vscode-httpyac.
Related Issues (20)
- Runner-like function to run load tests in VS Code extension? HOT 5
- [BUG] Broken environment loading HOT 2
- httpRegion.httpFile.activeEnvironment does not exist HOT 1
- Syntax highlight missing for next line of a commentted query item line HOT 1
- How about adding some shortcut keys like jupyter notebook ? HOT 1
- [feature] import curl HOT 2
- OAuth2 / OpenID Connect - Error HOT 3
- setup response path/ clear up response files HOT 4
- Wrong request host HOT 3
- request timeout in vscode but works in cli HOT 3
- Escaping curly braces is not correctly interpreted HOT 3
- env from http-client.private.env.json overwritten with values from template-http-client.private.env.json HOT 1
- JSON key that has spaces un-referencable when using variable injection HOT 3
- Input unexpected behavior HOT 2
- Feature Request: Token Exchange Grant Support for a particular audience in the same realm HOT 2
- Nodejs parsing for query params HOT 5
- I have 6.11.0 version and response lens is missing too. HOT 2
- jpeg image response is not being previewed HOT 2
- GRPC reflection HOT 1
- sent GraphQL request without content type header and got error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-httpyac.