github unkn0wn-root/resterm v0.53.1

3 hours ago

This release fixes several document and capture bugs, adds multiline directives and makes response refer only to the current request.

Breaking change

response is available only after the current request completes

Note: This change affects only files that use response before a request runs.

Before this release, using response during pre-request evaluation silently returned the previous response. This made it possible for a URL, header, body, condition, or pre-request script to use stale data without warning. response now always means the current response. It is available in @assert and @capture, which run after the request completes.

Use last when you intentionally need the previous response.

Before:

response.json("auth.token")

After:

last.json("auth.token")

For example:

Authorization: Bearer {{= last.json("auth.token") }}

This affects pre-request expressions in:

  • URLs, headers, and bodies
  • Request variables and authentication fields
  • @apply and @patch
  • @when and @skip-if
  • @for-each
  • @if, @elif, and @switch
  • RestermScript pre-request blocks

Accessing an unavailable response is a hard error, so try cannot catch it. Replacing pre-request uses of response with last is compatible with earlier Resterm versions. RestermScript pre-request blocks that read response previously received an empty response object. They now report an error instead. To migrate, search your files for response. Keep it in @assert and @capture; change pre-request uses to last.

New

Directives can span multiple lines

Resterm now continues a directive across comment lines while its expression, matcher value, or template marker is incomplete.

Long assertions no longer need to fit on one line:

# @assert (
#   response.statusCode == 200
#   and contains(response.text(), "args")
# ) => "the echo endpoint did not return the query arguments"

Multiline expressions are supported in:

  • @assert
  • @when and @skip-if
  • @capture
  • @apply and @patch
  • @for-each
  • @if and @elif
  • @switch and @case

@match also continues while a quoted or bracketed option value remains open:

# @match json-rules={
#   "user.id": "42",
#   "user.role": "admin"
# }

Continuation lines may use any supported comment marker and do not repeat the directive name.

Options after the closing delimiter remain part of the directive:

# @if (
#   vars.get("env") == "prod"
# ) run=deploy

A recognized directive, a blank or non-comment line, a ### separator, or the end of the file stops collection. If a delimiter is never closed, Resterm reports the error at the line where the directive started.

Errors on continuation lines retain their original line and column. Assertion names and skip reasons are folded onto one line in reports so they remain readable:

@when evaluated to false: ( 1 == 2 and 3 == 3 )

Single-line directives such as @name, @tag, and @step are unchanged.

Fixed

Generated documents retain directives

The document writer now preserves these directives when reconstructing a document:

  • @patch
  • @when and @skip-if
  • @for-each
  • @apply
  • @assert

This affects imports, generated files, and other features that use the document writer. Custom-header @auth forms are also preserved instead of being silently omitted:

# @auth X-Release-Auth {{release.token}}
GET https://api.example.com/releases

Normal editor saves already wrote the current buffer and were not affected by this bug.

Captures read their own response

A {{= ... }} expression inside @capture previously read the most recent response in the session. On a later run, that response could belong to another request. It now reads the response belonging to the request being captured:

### login
# @name login
# @capture file token = {{= response.json("auth.token") }}
POST https://api.example.com/login

Plain template captures were already correct and are unchanged:

# @capture file token {{response.json.auth.token}}

Capture expressions that use file helpers now also respect the configured base directory.

Directive separators are recognized only at the top level

Directive separators are no longer recognized inside strings, comments, or nested groups.

This applies to:

  • => in @assert
  • as and in in @for-each
  • Workflow options such as run= and fail=

This prevents parts of an expression from being mistaken for an assertion message, loop variable, or workflow option.

Capture errors are clearer

@capture now gives one consistent error when its name or expression is missing. Template text and RestermScript captures are also distinguished more reliably. If an RTS comment mentions a template marker such as {{token}}, quote the marker so the capture remains in RestermScript mode:

# @capture request status response.statusCode # mention "{{token}}"

Don't miss a new resterm release

NewReleases is sending notifications on new releases.