diff --git a/README.md b/README.md index 636d3901778..f6132f0750e 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,7 @@ HTTP 200 * [Templating a JSON Body](#templating-a-json-body) * [Templating a XML Body](#templating-a-xml-body) * [Using GraphQL Query](#using-graphql-query) + * [Using Dynamic Datas](#using-dynamic-datas) * [Testing Response](#testing-response) * [Testing Status Code](#testing-status-code) * [Testing Response Headers](#testing-response-headers) @@ -586,6 +587,32 @@ GraphQL queries can also use [Hurl templates]. [Doc](https://hurl.dev/docs/request.html#graphql-body) +### Using Dynamic Datas + +[Functions] like `newUuid` and `newDate` can be used in templates to create dynamic datas: + + +A file that creates a dynamic email (i.e `0531f78f-7f87-44be-a7f2-969a1c4e6d97@test.com`): + +```hurl +POST https://example.org/api/foo +{ + "name": "foo", + "email": "{{newUuid}}@test.com" +} +``` + +A file that creates a dynamic query parameter (i.e `2024-12-02T10:35:44.461731Z`): + +```hurl +GET https://example.org/api/foo +[QueryStringParams] +date: {{newDate}} +HTTP 200 +``` + +[Doc](https://hurl.dev/docs/templates.html#functions) + ## Testing Response Responses are optional, everything after `HTTP` is part of the response asserts. @@ -1524,9 +1551,9 @@ Please follow the [contrib on Windows section]. [GitHub]: https://github.com/Orange-OpenSource/hurl [libcurl]: https://curl.se/libcurl/ [star Hurl on GitHub]: https://github.com/Orange-OpenSource/hurl/stargazers -[HTML]: /docs/standalone/hurl-5.0.1.html -[PDF]: /docs/standalone/hurl-5.0.1.pdf -[Markdown]: /docs/standalone/hurl-5.0.1.md +[HTML]: /docs/standalone/hurl-6.0.0.html +[PDF]: /docs/standalone/hurl-6.0.0.pdf +[Markdown]: /docs/standalone/hurl-6.0.0.md [JSON body]: https://hurl.dev/docs/request.html#json-body [XML body]: https://hurl.dev/docs/request.html#xml-body [XML multiline string body]: https://hurl.dev/docs/request.html#multiline-string-body @@ -1548,6 +1575,7 @@ Please follow the [contrib on Windows section]. [`--json` option]: https://hurl.dev/docs/manual.html#json [`--resolve`]: https://hurl.dev/docs/manual.html#resolve [`--connect-to`]: https://hurl.dev/docs/manual.html#connect-to +[Functions]: https://hurl.dev/docs/templates.html#functions [GitHub]: https://github.com/Orange-OpenSource/hurl [Hurl latest GitHub release]: https://github.com/Orange-OpenSource/hurl/releases/latest [Visual C++ Redistributable Package]: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version diff --git a/bin/docs/build_readme.py b/bin/docs/build_readme.py index b48c32c7ebd..6a257bb27c4 100755 --- a/bin/docs/build_readme.py +++ b/bin/docs/build_readme.py @@ -138,20 +138,21 @@ def replace(text: str, dest: str) -> str: """, ), + # TODO: extract version from Cargo.toml ( - "[HTML]: /docs/standalone/hurl-5.0.1.html", - "[HTML]: /docs/standalone/hurl-5.0.1.html", - "[HTML]: https://hurl.dev/assets/docs/hurl-5.0.1.html.gz", + "[HTML]: /docs/standalone/hurl-6.0.0.html", + "[HTML]: /docs/standalone/hurl-6.0.0.html", + "[HTML]: https://hurl.dev/assets/docs/hurl-6.0.0.html.gz", ), ( - "[PDF]: /docs/standalone/hurl-5.0.1.pdf", - "[PDF]: /docs/standalone/hurl-5.0.1.pdf", - "[PDF]: https://hurl.dev/assets/docs/hurl-5.0.1.pdf.gz", + "[PDF]: /docs/standalone/hurl-6.0.0.pdf", + "[PDF]: /docs/standalone/hurl-6.0.0.pdf", + "[PDF]: https://hurl.dev/assets/docs/hurl-6.0.0.pdf.gz", ), ( - "[Markdown]: https://hurl.dev/docs/standalone/hurl-5.0.1.html", - "[Markdown]: /docs/standalone/hurl-5.0.1.md", - "[Markdown]: https://hurl.dev/assets/docs/hurl-5.0.1.md.gz", + "[Markdown]: https://hurl.dev/docs/standalone/hurl-6.0.0.html", + "[Markdown]: /docs/standalone/hurl-6.0.0.md", + "[Markdown]: https://hurl.dev/assets/docs/hurl-6.0.0.md.gz", ), ] for old, new_for_github, new_for_crates in snippets: diff --git a/docs/manual/hurl.1 b/docs/manual/hurl.1 index 1f477c1e5d0..962d282a8c7 100644 --- a/docs/manual/hurl.1 +++ b/docs/manual/hurl.1 @@ -1,4 +1,4 @@ -.TH hurl 1 "07 Nov 2024" "hurl 6.0.0-SNAPSHOT" " Hurl Manual" +.TH hurl 1 "03 Dec 2024" "hurl 6.0.0-SNAPSHOT" " Hurl Manual" .SH NAME hurl - run and test HTTP requests. diff --git a/docs/manual/hurlfmt.1 b/docs/manual/hurlfmt.1 index 6546c7888ca..53c1b5acff5 100644 --- a/docs/manual/hurlfmt.1 +++ b/docs/manual/hurlfmt.1 @@ -1,4 +1,4 @@ -.TH hurl 1 "07 Nov 2024" "hurl 6.0.0-SNAPSHOT" " Hurl Manual" +.TH hurl 1 "03 Dec 2024" "hurl 6.0.0-SNAPSHOT" " Hurl Manual" .SH NAME hurlfmt - format Hurl files diff --git a/packages/hurl/README.md b/packages/hurl/README.md index 9d7d16a65a9..2a091a9d0dd 100644 --- a/packages/hurl/README.md +++ b/packages/hurl/README.md @@ -191,6 +191,7 @@ HTTP 200 * [Templating a JSON Body](#templating-a-json-body) * [Templating a XML Body](#templating-a-xml-body) * [Using GraphQL Query](#using-graphql-query) + * [Using Dynamic Datas](#using-dynamic-datas) * [Testing Response](#testing-response) * [Testing Status Code](#testing-status-code) * [Testing Response Headers](#testing-response-headers) @@ -586,6 +587,32 @@ GraphQL queries can also use [Hurl templates]. [Doc](https://hurl.dev/docs/request.html#graphql-body) +### Using Dynamic Datas + +[Functions] like `newUuid` and `newDate` can be used in templates to create dynamic datas: + + +A file that creates a dynamic email (i.e `0531f78f-7f87-44be-a7f2-969a1c4e6d97@test.com`): + +```hurl +POST https://example.org/api/foo +{ + "name": "foo", + "email": "{{newUuid}}@test.com" +} +``` + +A file that creates a dynamic query parameter (i.e `2024-12-02T10:35:44.461731Z`): + +```hurl +GET https://example.org/api/foo +[QueryStringParams] +date: {{newDate}} +HTTP 200 +``` + +[Doc](https://hurl.dev/docs/templates.html#functions) + ## Testing Response Responses are optional, everything after `HTTP` is part of the response asserts. @@ -1524,9 +1551,9 @@ Please follow the [contrib on Windows section]. [GitHub]: https://github.com/Orange-OpenSource/hurl [libcurl]: https://curl.se/libcurl/ [star Hurl on GitHub]: https://github.com/Orange-OpenSource/hurl/stargazers -[HTML]: https://hurl.dev/assets/docs/hurl-5.0.1.html.gz -[PDF]: https://hurl.dev/assets/docs/hurl-5.0.1.pdf.gz -[Markdown]: https://hurl.dev/assets/docs/hurl-5.0.1.md.gz +[HTML]: https://hurl.dev/assets/docs/hurl-6.0.0.html.gz +[PDF]: https://hurl.dev/assets/docs/hurl-6.0.0.pdf.gz +[Markdown]: https://hurl.dev/assets/docs/hurl-6.0.0.md.gz [JSON body]: https://hurl.dev/docs/request.html#json-body [XML body]: https://hurl.dev/docs/request.html#xml-body [XML multiline string body]: https://hurl.dev/docs/request.html#multiline-string-body @@ -1548,6 +1575,7 @@ Please follow the [contrib on Windows section]. [`--json` option]: https://hurl.dev/docs/manual.html#json [`--resolve`]: https://hurl.dev/docs/manual.html#resolve [`--connect-to`]: https://hurl.dev/docs/manual.html#connect-to +[Functions]: https://hurl.dev/docs/templates.html#functions [GitHub]: https://github.com/Orange-OpenSource/hurl [Hurl latest GitHub release]: https://github.com/Orange-OpenSource/hurl/releases/latest [Visual C++ Redistributable Package]: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version