fix: yaml parsing

This commit is contained in:
Morten Olsen
2025-05-18 22:29:50 +02:00
parent e0707e74fb
commit ba56b66222
3 changed files with 13 additions and 6 deletions

View File

@@ -89,7 +89,7 @@ _(Note: Actual headers and some response fields might vary.)_
HTTP requests are defined in fenced code blocks annotated with `http`. The syntax is similar to the raw HTTP format:
```http disable
```
<METHOD> <URL>
<Header-Name>: <Header-Value>
...
@@ -132,10 +132,17 @@ You can assign a unique ID to an `http` request block. This allows you to:
1. Reference its specific response in a `::response` directive.
2. Access its request and response data in [Templating](https://www.google.com/search?q=%23templating-with-handlebars) via the `requests` and `responses` dictionaries.
To add an ID, include `id=yourUniqueId` in the `http` block's info string:
To add an ID, include `#yourUniqueId` or `id=yourUniqueId` in the `http` block's info string:
::raw-md[./examples/with-multiple-requests.md]
<details>
<summary>Output</summary>
::raw-md[./examples/with-multiple-requests.md]{render}
</details>
## Templating with Handlebars
`http.md` uses [Handlebars](https://handlebarsjs.com/) for templating, allowing you to create dynamic content within your markdown files. You can inject data from request responses, input variables, and other requests into your HTTP blocks or general markdown text.

View File

@@ -2,16 +2,16 @@
First, create a resource:
```http id=createUser
```http #createUser,format=yaml
POST https://httpbin.org/post
Content-Type: application/json
{"username": "alpha"}
username: alpha
```
Then, fetch a different resource:
```http id=getItem
```http #getItem
GET https://httpbin.org/get?item=123
```

View File

@@ -69,7 +69,7 @@ const httpHandler: ExecutionHandler = ({
}
}
node.value = content;
node.value = [head, parsedBody].filter(Boolean).join('\n\n');
node.meta = undefined;
context.addRequest({