Orange-OpenSource / Orange-OpenSource/hurl

Support templating more complex captures into JSON request bodies

Open
#2,152 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
19.2k
Forks
745
Avg merge
5h 3m
Merged PRs (30d)
60

Description

Problem to solve

While we can easily capture complex variables via jsonpath, the ability to use them is limited at the moment:

GET http://localhost:3000/car/1

HTTP 200
[Captures]
features: jsonpath "$.car.features" # Array of strings


PUT http://localhost:3000/car/2
{
    "features": {{features}}
}

HTTP 200

Output:

error: Unrenderable variable
  --> array-var.hurl:10:19
   |
10 |     "features": {{features}}
   |                   ^^^^^^^^ variable <features> with value [wheels engine doors] can not be rendered
Proposal

I have done some initial digging through the code to see what it might take to support this, and noted that it's likely not a trivial modification. The current templating code, as we can see in the error message above, outputs strings without any surrounding quotes, and modifying that would be a breaking change for that component's public API.

I'd love to support getting this into place, but wanted to make sure any changes are in line with existing project guidelines and direction. Some guidance on how this might fit into the project as it is today would be very welcome.

Tasks to complete
  1. Update Templating Body docs to accurately reflect that templating primitives does currently work for JSON bodies! Happy to submit a separate, initial PR for this.
  2. Modify existing (or add new?) JSON templating code to support complex types - mainly arrays and objects.
  3. Lots of unit tests.
  4. Update docs to reflect new feature.

Let me know if this is something that will fit into the current roadmap! Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Templating Body documentation and the existing JSON templating code and unit tests. Review the current handling of captured arrays and objects, then update the implementation, tests, and documentation so complex captures can be used in JSON request bodies.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.