Orange-OpenSource / Orange-OpenSource/hurl
Support templating more complex captures into JSON request bodies
Nobody has claimed this yet.
- 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
- 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.
- Modify existing (or add new?) JSON templating code to support complex types - mainly arrays and objects.
- Lots of unit tests.
- Update docs to reflect new feature.
Let me know if this is something that will fit into the current roadmap! Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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