Skip to content

Add support for loops #5034

@aphilas

Description

@aphilas

Problem to solve

Some requests need to loop over a collection.

For example, fetching a list of resources and then deleting each resource individually, which is a common pattern in some tests.

Proposal

Support loops in some form.

No concrete design proposal atm. More like a request for comments.

Sample (probably bad) design I came up with in a few seconds:

# Get pets
GET {{host}}/pets
HTTP 200
[Captures]
pets: jsonpath "$"
[Asserts]
jsonpath "$" isCollection
jsonpath "$[*].id" count > 0

# Delete all pets
DELETE {{host}}/pets/{{id}}
[Options]
loop: id in jsonpath pets "$[*].id"
HTTP 204

Non-goals:

  • Handle filtering of the collection

Related issues:

Additional context and resources

Prior art:

Intellij HTTP client:

< {%
    request.variables.set("id", [1,2,3,4,5])
%}
GET http://localhost:8080/books/{{id}}

HttpYac:

{{
  exports.data = [1, 2, 3];
}}
###
# @loop for item of data
GET https://httpbin.org/anything?item={{item}}

Tasks to complete

  • ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions