Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
13.02k stars 486 forks source link

Suggestion: add random data generation helpers #606

Open icepuma opened 2 years ago

icepuma commented 2 years ago

Hey folks, awesome tool you wrote here!

As I use the tool for setting up demo data for my projects, I would find it cool to have a small set of helpers to e.g. create a random email or a random alphanumeric user name.

Those helpers could be used like:

# Create a new doggy thing with JSON body:
POST https://example.org/api/dogs
{
    "id": 0,
    "name": "{{random_alphanumeric(12)}}",
    "picture": "images/scottish-terrier.jpeg",
    "age": {{random_int()}},
    "breed": "Scottish Terrier",
    "location": "Lisco, Alabama"
}

I know that I could use the --variables functionality to inject variables and generate the random data outside of hurl, but I think this could come in handy for having self-contained .hurl - files.

If you like this idea or have more input, I would be happy to contribute the code myself! I wanted to let you guys know first and discuss it before I go for it!

Best regards Stefan

jcamiel commented 2 years ago

Hi, yes we plan to update the templates with expressions to add dynamic behavior. We have not settled on a syntax now (we’re currently rewriting our parser to support future uses cases) and this is directly in our roadmap of things to add. We’ve an issue about date support for templates, that has some ideas for syntax => #312

You’re welcome to add your use case and syntax proposition in the comments of this issue, so we take these into account. We definitively need more inputs and discussion before starting implementation.