Giter Site home page Giter Site logo

anweber / httpbook Goto Github PK

View Code? Open in Web Editor NEW
59.0 59.0 5.0 2 MB

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code

Home Page: https://httpyac.github.io/

License: MIT License

Shell 0.12% TypeScript 91.73% JavaScript 4.42% CSS 3.73%
graphql grpc http mqtt notebook postman rest websocket

httpbook's Introduction

Hi there, I'm Andreas

const AnWeber = {
    work: "Software Architect/ Engineer",
    home: "Oberbatzi",
    code: ["Typescript", "Javascript", "Java", "C#", "CSS", "html"],
    askMeAbout: ["kids", "programming topics", "find a solution"],
    technologies: {
        backEnd: ["Spring Boot", "NodeJS", ".Net"],
        frontEnd: ["vue", "preact", "angular", "winforms", "wpf"],
        build: ["esbuild", "webpack", "gradle", "Github Actions", "Argo Workflows", "jenkins", "msbuild"],
        devOps: ["kubernetes", "elk stack", "argo-cd", "helm", "docker", "keycloak"],
        databases: ["oracle", "mssql", "mongo"],
        misc: ["VSCode Extensions", "bpmn"]
    },
    architecture: ["Microservices", "Serverless Architecture"],
    currentFocus: "Uniting software from two decades",
    hobbies: ["Hiking", "Gaming", "Lego"],
    funFact: "There are only 10 kinds of people in the world: the people who understand binary numbers and the people who don't."
};
console.info(AnWeber);

Current projects

Stats

AnWeber's GitHub stats

Top Langs

httpbook's People

Contributors

anweber avatar dependabot[bot] avatar donjayamanne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

httpbook's Issues

Global Before/After request hooks are not working

Imagine following code:

{{+request
   request.headers = { "enforced-header": "foo"};   
}}
{{+response
    console.info(response.body);
}}

# @name request1
GET /v1/foo

# @name request2
GET /v1/foo2

Running this in std. vs-plugin or cli works fine for both requests, but in httpbook it doesn't. Looks like the global hooks are not evaluated

No request body requests break the following blocks

As a follow on to #74 I noticed that if you have a request with no body i.e
image

You end up with the following written to the file system:

/*
## Test
*/
/*
#### Test 1
*/
GET https://example.com/api/auth/logout HTTP/1.1
X-Apitoken: {{api_token}}
/*
#### Test 2
*/
###
{{@response
    global.api_token = JSON.parse(response.body).token;
}}
POST https://example.com/api/auth/login HTTP/1.1
Content-Type: application/json
{
    "email": "{{httpbook_email}}",
    "pwd": "{{httpbook_password}}"
}

Which after re-opening results in:
image

Publishing as Webapp

Hi there!

First, fantastic work on httpyac and the surrounding ecosystem. I come from an IJ background and have for a long time enjoyed using their rest client; so when I switched to VSCode I was very glad to stumble on your extension. I'm starting to realize, however, that I can use your http file format for a lot more than just running sample code in my IDE. The extensive testing support and Notebook integration really has me thinking this could be a replacement for something like swagger and or my usual api doc publishing.

At the moment, unless I'm mistaken, the httpbook support is limited to being used from within VSCode. Have you explored publishing httpbook's as web apps.

I'm imagining a markdown or asciidoc file that sits within my code's repo which not only drives out tests using the httpyac cli but is also auto-published to something like github pages as an interactive notebook.

1 readable / diffable document serving multiple purposes, absolutely amazing if possible.

Appreciate your time.

Add possibility to view the sent request

I would like to view the request that was sent out, e.g. for manual review of variable replacements.

Is there a way to view the request Body / URL / Headers in the form they are sent out (= with replaced placeholders)?

how to wait for response.parsedBody promise to be resolved?

Dear AnWeber,

when starting to implement tests in httpYac using httpbook which require
a little bit more response time from the server it looks to me that
the response.parsedBody promise is not resolved in time before my chai test.
See error message below:

AssertionError: schema: expected undefined to be truthy
at Proxy. (node_modules/chai-json-schema/index.js:132:16)
at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)
at Object. (test.http:14:42)
at i2 (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.2/dist/extension.js:128:90931)
at Th (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.2/dist/extension.js:129:30436)
at Object.action (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.2/dist/extension.js:129:29800)
at $B. (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.2/dist/extension.js:1:4702)
at Generator.next ()
at s (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.2/dist/extension.js:1:3164)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)

When doing the same request and test with the command line the chai test passes as expected.

package.json:

{
  "dependencies": {
    "chai": "^4.3.6",
    "chai-json-schema": "^1.5.1"
  }
}

let me know if you need more information ✌️

Httpbook formatting broken by saving in VScode 1.76.1

Hi,

After upgrading to VScode 1.76 (code_1.76.1-1678294265_amd64.deb) on Ubuntu 22.04 LTS my httpyac files in httpbook format gets broken when loaded into VScode. The requests get truncated in httpbook whereas disabling the httpbook extension and using only httpyac in VScode works normally.

httpyac looks like this:

GET http://{my_url}}/my/api/v1
/config

in httpbook this is truncated to:
my_url}}/my/api/v1
/config

Maybe some control code change in VScode with undesired side effects ?

Hide codelens for code cells

image

For text documents, codelens is a good place to render "env/send all" actions but in notebook editor, but it looks weird in notebook editor code cells. We may want to hide it.

A few rough ideas of where to put the env: or send all actions

  • Cell status bar once the API is stabilized
  • Cell toolbar

Non-empty .http files sometimes open without a cell

Hello,
If I open them normally, I see a single empty cell, whereas if I open them as a text file I see the non-empty content:
2021-10-21_10-02-11

Some .http files open correctly. It seems to me that they are always the same ones that open well or that open badly.
How to isolate the problem and correct it.

Version: 1.61.2 (user setup)
Commit: 6cba118ac49a1b88332f312a8f67186f7f3c1643
Date: 2021-10-19T14:57:20.575Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

Is there a problem with @ref and @forceRef ?

Hello Andreas,

I think so.

I have a cell "# @name login" that is used by an accessToken cell in the same httpbook, "# @name accessToken"; itself used by a cell in another httpbook.
Whether the references are cascaded by @forceRef or by @ref - after the first two cells are executed, my token is still the one from before and becomes invalid over time.
I have to close VSCode and reopen it so that the token being used is the correct one.
I tried to clear the cache but it doesn't change anything.

Thank you again for this great work which helps me a lot.

httpbook.saveWithOutputs does not work

... or does not work as expected?

When set to false, the contents of the file containing the http requests are changed, also after a window reload/restart of vscode.
The unsaved file indicator pops up although nothing has been change about the actual requests.

Is there maybe a way to completely redirect the response to the console?

vscode version win64 1.60.1 (system)

View size of request

!Feature

It would be great to be able to limit the height size of the request view.
Cause when request has long body, then the window is very height, and the reponse is very far (need to scroll a lot)

image

Suggested presentation
image

Thanks

Code Formatting and Assist

Hi,

Is it possible to apply formatting to the Httpbook? I have a lot of JSON in the book and I have to copy them out to reformat, then paste them back. It would be great if it is available directly.

Also, is it possible to enable code assist in the script blocks?

Thanks
Matt

RequestError: unable to verify the first certificate

Just installed httpBook.
VSCode settings adapted:

"httpyac.requestGotOptions": {
    "request": {
        "https": {
            "rejectUnauthorized": false
        }
    }
} 

With a GET request

GET http://localhost:5000/api/v2/users

I got this error: RequestError: unable to verify the first certificate.

What's wrong?
It's a good idea to make a notebook around HTTP ;-)

Variables do not carry over between cells

When working with variables like this

{{
  exports.foo = 'bar';
}}
GET https://google.de/?q={{foo}}
###
GET https://google.de/?q={{foo}}

The second request will fail with

ReferenceError: foo is not defined

For unknown reasons I had it randomly work but most of the time it does not work. In httpyac it works fine.

cannot use external javascript packages when testing while using vscode remotely

Dear AnWeber,

first of all thank you for that amazing vscode extension!

Unfortunately, I found a really weird bug happening when testing with e,g, "assert" or "chai" an endpoint while using vscode remotely.
See error message below:

TypeError: Cannot assign to read only property '_fsPath' of object '[object Object]'
at v.get fsPath [as fsPath] (/home/ivo/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/out/vs/server/remoteExtensionHostProcess.js:73:14942)
at Object.ni.io.fileProvider.fsPath (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.0/dist/extension.js:274:7580)
at E2 (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.0/dist/extension.js:126:90247)
at Uh (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.0/dist/extension.js:127:29305)
at Object.action (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.0/dist/extension.js:127:28669)
at l5. (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.0/dist/extension.js:1:4676)
at Generator.next ()
at s (/home/ivo/.vscode-server/extensions/anweber.vscode-httpyac-4.10.0/dist/extension.js:1:3138)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)

How to reproduce:
In VS Code, select Remote-SSH: Connect to Host.

GET http://localhost:8080/api/test
{{
  const { equal } = require('assert');
  test('status code 200', () => {
    equal(response.statusCode, 200);
});

What I figured out so far:

  • same happens when I use chai
  • it does not matter if I use a GET or POST
  • error does not occur when running httpyac from the command line

If it helps to know:
OS: Manjaro Linux x86_64
vscode: aur/visual-studio-code-bin 1.63.2-1

Let me know if you need some extra information from me.
Keep up the good work ✌️

Ivo

Do not output the result of @ref or @forceRef request

Hello
When you use @ref or @forceRef to get for example a token with a login, it's a shame to have the output of this intermediate request. It makes it more difficult to read the result of the request we are really interested in.

I believe that this was not always the case.

Provide a way to suppress the output of a cell

When making a request to an endpoint that returns a large json dictionary the entire editor is filled with the response body, provide a way to suppress the output of a cell, such that only the first lines is displayed, either through a VSCode setting or as a snippet in the cell body.

How can I make use of httpyac-plugin-jq in Notebook?

I have the Plugin "httpyac-plugin-jq" installed in the repository.
When I execute the request with the extension httpyac-vscode, the plugin is executed.
When I execute the request with httpbook, the plugin is not executed.

How can I execute the notebook and get the result from the plugin?

How to configure response output

Is there a way to configure the response output similar as in CLI or the std-plugin? For me the full request/response cycle is show, whereas I'd like to see only the response body (at first).

Code Generation and Imported Files

Hi,

If I have variables defined in an external file, code generation is unable to find them even though the requests works. In the screenshot below, eshost is a variable that is imported.

image

Thanks
Matt

ReferenceError - login is not defined

If I run this cell:

# @name login
POST {{apiUrlAuth}}/accounts/login
Content-Type: application/json
cache-control: no-cache
{
	email: "{{email}}",
	password: "{{password}}"
}

I got a result.

But if I add this next cell

@accessToken = {{login.tokens.accessToken}}

I got the error even if I ran only the first one: "ReferenceError - login is not defined"

Tested in VSCode
Version: 1.57.1 (user setup)
Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
Date: 2021-06-17T13:28:07.755Z
Electron: 12.0.7
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19043

and in insiders
Version: 1.58.0-insider (user setup)
Commit: bfac07cd0e374c433c2c06d6999dabf9cf9d5d29
Date: 2021-06-28T05:14:44.463Z
Electron: 12.0.12
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19043

Mask Input Passwords in Active Session

hi @AnWeber

thanks for httpbook. it's an amazing extension for VSCode.
There's one issue, that I am not sure if it's related to this repo or related to another one.

If I use Input Variables as Password, like:

@query = {{$password input app? $value: foo}}
GET https://httpbin.org/json?q={{query}}

This works fine. Once a request is sent, then the password is cached as active session in the whole .http file. The problem is that if I want to take a look in the active session, then the password is displayed as plain text.

Is there a possibility to mask the cached inputs that are marked as passwords?

Thanks Rafael

Changing environment does not work after first call

I'm using dotenv with multiple env files.
Changing env in the text editor version of .http file works correctly.

In httpbook when I pick an env from the status bar, then send a request, then pick another env, the env will change based on the status bar text, but actually stays the previous one.
If I just open VSCode, don't pick an env and send a request it fails with an error, because some variables only exists in env specific files and they're missing, then pick an env, send again and it still fails.
I need to open the text editor version and change env from there to solve the issue.
Based on this looks like it saved on first request sent and not after first picking an env.

When using "Run all", is the order of execution of cells guaranteed?

I'm using httpbook to automate API testing, and I saw in one instance that my tests are flaky when run with the "Run All" toolbar button.

Running them one cell after another works perfectly.

I cleared my history and reopened the request file to debug the order of calls, but now it works again.

My question: is the order of calls guaranteed when using Run All? is the runner waiting for the response of one cell before running the next one?

Support for polyglot notebooks

Would it be possible to integrate HttpBook with the polyglot notebooks in VSCode?

This would enable advanced use cases, e.g. fetching secrets from Azure KeyVaults, etc. using C# or PowerShell.

Has anybody looked into what would be required?

websocket response inaccurate rendered as a cell

steps:

  1. create a notebook has follow content
WS wss://demo.piesocket.com/v3/channel_1?api_key=oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm&notify_self
  1. send request

them, response has been render as a cell

image

impossible execution of a cell

Hi
With the last update of yesterday the execution arrow is no longer displayed.
I reinstalled the previous version from .vsix, and the arrow is there.
2022-03-07_16-07-13

Regards

The cells are modified after execution

For some time now, the results of the queries are inserted in the cell, like this:
POST ------- HTTP/1.1
Content-Type: application/json
Authorization: Bearer {{accessToken}}
connection: close
date: Tue, 10 May 2022 11:51:54 GMT
content-type: application/json; charset=utf-8
server: Kestrel
content-length: 5832

Is it when saving the file, closing it or closing VSCode, I don't know exactly when this change is made?

Version: 1.67.1 (user setup)
Commit: da15b6fd3ef856477bf6f4fb29ba1b7af717770d
Date: 2022-05-06T12:37:03.389Z
Electron: 17.4.1
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Windows_NT x64 10.0.19044
httpBook v 3.1.0

Executing cells in VS Code always fails with "Unavailable (FileSystemError) No file system provider found for resource ..."

This extension looks really awesome. Unfortunately, I haven't been able to get it working at all. Every time I click "Execute cell" or "Run all", the extension always fails to run the HTTP requests and VS Code shows a notification that says.

Unavailable (FileSystemError): No file system provider found for resource 'vscode-notebook-cell:/Users/nate/Downloads/test1#ch0000002'

If I uninstall the HttpBook extension and use anweber.vscode-httpyac instead, I have no problem getting HTTP requests to work.

Versions

VS Code: 1.68.1
HttpBook extensions: v3.1.1
Httpyac - rest client extension: v5.5.1

More logs

I enabled trace level logging and it produces this

TRACE: load core
TRACE: load dotenv
TRACE: load eventSource
TRACE: load graphql
TRACE: load grpc
TRACE: load http
TRACE: load intellij
TRACE: load injection
TRACE: load javascript
TRACE: load mqtt
TRACE: load oauth2
TRACE: load rabbitMQ
TRACE: load websocket
ERROR: Unavailable (FileSystemError) - No file system provider found for resource 'vscode-notebook-cell:/Users/nate/Downloads/test1#ch0000001'
Unavailable (FileSystemError): No file system provider found for resource 'vscode-notebook-cell:/Users/nate/Downloads/test1#ch0000001'
	at Function._handleError (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:121521)
	at Object.stat (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:120091)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)

Mimetype text/html is not

When I use another notebook (in my case .NET interactive), I have to change the mimetype of the output to the built-in and repeat this over and over:
image

With the active mimetype I get this output:
image

and with built-in I get a more readable output:
image

It is really boring.

Compiling under Linux --> incompatible

Hi @AnWeber ,

Just for your information ;)
I tried to compile this under ubuntu 20.04. This leads to an error, that fsevents is incompatible with linux ;)

image


npm i -f

is a workaround for this, but it changes the lockfileversion from 2 to 1.

image

Greets,
Benni :)

Feat: Keep response tab last position

It would be interesting to persist the position of the answer tab in the last location

When we use the client as in the image example, the position of the tab is always reset when a request is made

PS: I know about workbench.editor.openSideBySideDirection but it's not ideal as it changes the whole behavior of the editor

210875566-9f8e93dd-f10d-45f9-9d70-5b296f6a3ce0

Block order gets lost

It looks like the order of blocks in the notebook can get lost, for example on creation the blocks are ordered like so:
initial-order

Which results in the following being saved to the filesystem:


/*
## Test
*/


/*
#### Test 1
*/

{{@response
    global.api_token = JSON.parse(response.body).token;
}}
POST https://example.com/api/auth/mfa HTTP/1.1
Content-Type: application/json
{
    "email": "{{httpbook_email}}",
    "pwd": "{{httpbook_password}}",
    "code": "123456"
}

/*
#### Test 2
*/


###

{{@response
    global.api_token = JSON.parse(response.body).token;
}}
POST https://example.com/api/auth/login HTTP/1.1
Content-Type: application/json
{
    "email": "{{httpbook_email}}",
    "pwd": "{{httpbook_password}}"
}

However after closing then re-opening it looks like this:
second-open-order

Here's the VSCode details:

Version: 1.71.2 (user setup)
Commit: 74b1f979648cc44d385a2286793c226e611f59e7
Date: 2022-09-14T21:03:37.738Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19043
Sandboxed: No

Also I have httpbook.saveWithOutputs off but the issue happens with it on as well.

Markdown rendered as plain text

Most of the time markdown is not applied to the .http file's comments.

Steps to reproduce:

  1. Create a new .http file, open it with VSCode with httpbook plugin.
  2. Add there some markdown section, save.
  3. Close the file and open it again.

Result: The markdown section is not formatted, i.e. rendered as plain text.
Expected result: Markdown should be converted to formatted text.

It's curios that if I enter the edit mode, change something in the section and "apply" changes for the section, it would render proper formatting. Sometimes formatting would also appear when I add a new section before the one in question.

VSCode: 1.67.1
httpbook: 3.1.0

support multiple requests in same code cell

Another great plugin from you! I am really impressed. However I faced a little problem. Here is my use case:

  1. run two requests in the same code cell
  2. render only response from the second request

FYI, the first request triggers a CI build and second request checks its results; it could be a common use case.

However it didn't work so well as is. I've tried:

  1. use httpbook with the VSCode built-in renderer, it displays response from both requests
  2. use httpbook with the httpBook - Monaco Editor Renderer, it displays response from first request and doesn't refresh after second request completes
  3. use @no-log on first request, now it breaks the variable reference doe.user and failes, however if I run it a second time, it seems able to resolve the variable somehow, from cached value maybe.

Below is a minimal example. It was really fun to use these plugins you've developed. I am not proficient in TS or VSCode plugin development; but let me see if I can get a grasp of them and contribute back.

###
@user = doe
@password = 12345678
# @name doe
GET https://httpbin.org/basic-auth/{{user}}/{{password}}
Authorization: Basic {{user}} {{password}}

###
# @ref doe
GET https://httpbin.org/basic-auth/{{doe.user}}worked/{{password}}
Authorization: Basic {{doe.user}}worked {{password}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.