### Example Strest Test Run Output Source: https://github.com/eykrehbein/strest/blob/master/README.md Provides examples of the console output when running Strest tests, showing the number of files found, schema validation status, and the results (success/failure and duration) for each test or request. ```shell [ Strest ] Found 4 test file(s) [ Strest ] Schema validation: 4 of 4 file(s) passed Executing tests in ./ ✔ Testing login succeeded (0.463s) ✔ Testing verify_login succeeded (0.32s) ✔ Testing verify_login_chained succeeded (0.233s) Executing tests in: ./var/ ✔ Testing chaining_var1 succeeded (0.128s) ✔ Testing chaining_var2 succeeded (0.131s) [ Strest ] ✨ Done in 1.337s ``` ```shell [ Strest ] Found 1 test file(s) [ Strest ] Schema validation: 1 of 1 file(s) passed ✔ Testing requestOne succeeded (0.1s) ✔ Testing requestTwo succeeded (0.32s) ✔ Testing requestThree succeeded (0.11s) [ Strest ] ✨ Done in 0.62s ``` -------------------------------- ### Install Strest CLI via npm or Yarn Source: https://github.com/eykrehbein/strest/blob/master/README.md Provides commands to install the Strest command-line interface globally using either npm or Yarn package managers. ```bash npm i -g @strest/cli ``` ```bash # Via Yarn yarn global add @strest/cli ``` ```bash # Via npm npm i -g @strest/cli ``` -------------------------------- ### Define Bulk stREST Tests Configuration (YAML) Source: https://github.com/eykrehbein/strest/blob/master/README.md Example YAML file (`bulk.yml`) demonstrating how to specify a list of stREST test files or directories to be executed in bulk. ```yaml --- - tests/success/postman.strest.yml - tests/success/two.strest.yml - tests/success/chaining/ ``` -------------------------------- ### Run Strest Tests via Docker Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows how to run Strest tests using the official Docker image, including examples for running tests included in the image or mounting local test files and environment variables. ```bash # Via Docker # The image contains everything in the tests directory docker run -it eykrehbein/strest:latest strest tests/success/chaining/ # Bring your own test and environment docker run -it --env STREST_URL=https://jsonplaceholder.typicode.com -v ${PWD}:/app/data eykrehbein/strest:latest strest /data/tests/success/Env/ ``` -------------------------------- ### Defining Request Method in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This example illustrates how to specify the HTTP method for a request using the `method` property. While any string is accepted, it's recommended to use standard HTTP methods like POST, GET, PUT, DELETE, etc. ```yaml # Example somePostRequest: request: url: ... method: POST ``` -------------------------------- ### Example stREST Test Failure Output (Shell) Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows the typical console output when a stREST test fails due to a validation error, indicating the specific validation rule that was not met. ```shell [ Strest ] Found 1 test file(s) [ Strest ] Schema validation: 1 of 1 file(s) passed ✖ Testing test failed (0.2s) [ Validation ] The required item test wasn't found in the response data [ Strest ] ✨ Done in 0.245s ``` -------------------------------- ### Defining Request URL in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This snippet shows how to specify the target URL for a request using the `url` property. It includes examples for a basic static URL and a URL that incorporates a value dynamically retrieved from a previous request using `Value()`. URLs must start with `http` or `https`. ```yaml # Basic Example someRequestName: url: http://localhost:3000/api # Example with a connected value someConnectedRequest: url: http://localhost:3000/api/user/Value(getUser.id)/friends ``` -------------------------------- ### Run stREST Test with Date Variable (Bash) Source: https://github.com/eykrehbein/strest/blob/master/README.md Example bash command to run a stREST test file, setting an environment variable `STREST_GMT_DATE` which can be used within the test configuration. ```bash export STREST_GMT_DATE=$(TZ=GMT-0 date --date='15 seconds' --rfc-2822 | sed "s/+0000/GMT/g") strest tests/success/validate/maxRetries.strest.yml ``` -------------------------------- ### Configuring HTTP Headers in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md Demonstrates how to specify HTTP headers to be sent with a request using an array format. Includes examples showing both a simple list of name/value pairs and an inline array definition, along with corresponding validation checks. ```yaml # Basic Example version: 2 requests: requestHeaders: request: url: https://postman-echo.com/headers method: GET headers: - name: exampleHeader value: "Lorem ipsum dolor sit amet" validate: - jsonpath: content.headers.exampleheader expect: "Lorem ipsum dolor sit amet" requestHeaders2: request: url: https://postman-echo.com/headers method: GET headers: [{ "name": "h1", "value": "v1" }, { "name": "h2", "value": "v2" }] validate: - jsonpath: content.headers.h1 expect: "v1" - jsonpath: content.headers.h2 expect: "v2" ``` -------------------------------- ### Strest HAR Response Format Example - JSON Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates the structure of a Strest response stored in the HAR format, showing how status, headers, and content are organized. This format is used to make previous response data available for subsequent requests. ```json { "login": { "status": 200, "statusText": "OK", "headers": { "content-type": "application/json; charset=utf-8", "date": "Mon, 12 Nov 2018 19:04:52 GMT", "vary": "Accept-Encoding", "content-length": "22", "connection": "Close" }, "content": { "authenticated": true } } } ``` -------------------------------- ### Naming a Single Request in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This example demonstrates how to define a single request within the `requests` section of the Strest YAML schema. The key `someRequestName` serves as the unique identifier for this request. ```yaml # Example requests: someRequestName: # <- a Request .. ``` -------------------------------- ### Adding a Delay Before Request Execution in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This example demonstrates how to use the `delay` property to pause the execution of a specific request for a specified number of milliseconds before it is sent. ```yaml # Example someRequest: delay: 2000 # Wait 2 seconds before perfoming request request: url: ... method: ... ``` -------------------------------- ### Allowing Insecure Certificates in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This example shows how to use the `allowInsecure` boolean property to permit Strest to connect to endpoints using insecure, self-signed, or expired certificates. ```yaml # Example allowInsecure: true someRequest: request: url: ... method: ... ``` -------------------------------- ### Generating Random Data with Faker - YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates how to use the Faker() function within request parameters to generate random test data based on Faker.js templates. Examples show generating first names and full names for query string values. ```yaml version: 2 requests: fake: request: url: https://postman-echo.com/get method: GET queryString: - name: first value: <$ Faker("name.firstName") $> - name: first_last value: <$ Faker("name.firstName") $> <$ Faker("name.lastName") $> log: true ``` -------------------------------- ### Defining Raw Text Post Data in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This example demonstrates how to send raw text data in the request body using the `postData` property. It requires setting the `mimeType` to `text/plain` and providing the raw text under the `text` property. ```yaml # Raw Data Example version: 2 requests: postRequest: request: url: https://postman-echo.com/post method: POST postData: mimeType: text/plain # Set the mimeType text: "This is raw text" ``` -------------------------------- ### Validating Response with Regex in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates using the `regex` validation type in Strest to check if the value at a given JSONPath matches a specified regular expression pattern. Examples show validating HTTP status codes. ```yaml version: 2 requests: codeValidate: request: url: https://jsonplaceholder.typicode.com/todos method: GET validate: # Multiple ways to use regex to validate status code - jsonpath: status regex: 2\d+ - jsonpath: status regex: 2[0-9]{2} - jsonpath: status regex: 2.. - jsonpath: status regex: 2.* ``` -------------------------------- ### Validating Response Values with Regex in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md Shows how to use the `regex` validation method with `jsonpath`. This method validates the value at the specified path against a regular expression pattern. Multiple examples are provided for validating an HTTP status code. ```yaml version: 2 requests: codeValidate: request: url: https://jsonplaceholder.typicode.com/todos method: GET validate: # Multiple ways to use regex to validate status code - jsonpath: status regex: 2\d+ - jsonpath: status regex: 2[0-9]{2} - jsonpath: status regex: 2.. - jsonpath: status regex: 2.* ``` -------------------------------- ### Extracting Data with JsonPath for Chaining - YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows how to use the JsonPath() function to extract specific data points from a previous JSON response using JsonPath expressions. The example extracts a phone number from the 'set_JsonPath' response to use in a query string for the 'JsonPath' request. ```yaml version: 2 requests: set_JsonPath: request: url: https://jsonplaceholder.typicode.com/posts method: POST postData: mimeType: application/json text: firstName: John lastName: doe age: 26 address: streetAddress: 'naist street' city: Nara postalCode: 630-0192 phoneNumbers: - {type: iPhone, number: 0123-4567-8888} - {type: home, number: 0123-4567-8910} JsonPath: request: url: https://postman-echo.com/get method: GET queryString: - name: foo value: <$ JsonPath("set_JsonPath.content.phoneNumbers[?(@.type == \"home\")].number") $> validate: - jsonpath: content.args.foo expect: 0123-4567-8910 ``` -------------------------------- ### Validate Response with JSON Schema in stREST (YAML) Source: https://github.com/eykrehbein/strest/blob/master/README.md Demonstrates how to validate API responses against a JSON schema in stREST. The schema can be defined in variables or inline within the request validation section. Includes examples for validating nested objects and arrays. ```yaml version: 2 variables: schemaValidate: properties: fruits: type: array items: type: string vegetables: type: array items: "$ref": "#/definitions/veggie" definitions: veggie: type: object required: - veggieName - veggieLike properties: veggieName: type: string veggieLike: type: boolean requests: jsonschema1: request: url: https://postman-echo.com/post method: POST postData: mimeType: application/json text: fruits: - apple - orange - pear vegetables: - veggieName: potato veggieLike: true - veggieName: broccoli veggieLike: false validate: - jsonpath: content.data jsonschema: <$ schemaValidate | dump | safe $> jsonschema2: request: url: https://postman-echo.com/post method: POST postData: mimeType: application/json text: fruits: - apple - orange - pear vegetables: - veggieName: potato veggieLike: true - veggieName: broccoli veggieLike: false validate: - jsonpath: content.data jsonschema: properties: fruits: type: array items: type: string vegetables: type: array items: "$ref": "#/definitions/veggie" definitions: veggie: type: object required: - veggieName - veggieLike properties: veggieName: type: string veggieLike: type: boolean ``` -------------------------------- ### Run Strest Tests from CLI Source: https://github.com/eykrehbein/strest/blob/master/README.md Demonstrates how to execute Strest tests from the command line, either by specifying a single test file, a directory containing test files, or recursively searching the current directory. ```bash strest tests/success/postman.strest.yml ``` ```bash strest tests/success/chaining # or strest # this will recursively search for all .strest.yml files in the cwd and it's subdirectories ``` -------------------------------- ### Basic Strest YAML Test File Structure Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates the fundamental structure of a .strest.yml test file, defining the version and a single request with URL, method, and query parameters. ```yaml version: 2 # only version at the moment requests: # all test requests will be listed here testRequest: # name the request however you want request: url: https://postman-echo.com/get # required method: GET # required queryString: - name: foo1 value: bar1 - name: foo2 value: bar2 # log: true # uncomment this to log the response ``` -------------------------------- ### Run Manual Strest Tests (Bash) Source: https://github.com/eykrehbein/strest/blob/master/CONTRIBUTING.md Shows various bash commands for manually testing the strest tool. This includes setting environment variables, running specific test suites (success, failure, retries), running bulk tests, and executing chained tests with history management. ```bash export STREST_URL=https://jsonplaceholder.typicode.com node dist/main.js tests/success/ export STREST_GMT_DATE=$(TZ=GMT-0 date --date='10 seconds' --rfc-2822 | sed "s/+0000/GMT/g") node dist/main.js tests/success_validate_retries/ node dist/main.js tests/failure/ --no-exit node dist/main.js tests/success/bulk.yml -b # Manual chained executions node dist/main.js tests/success/chaining/login.strest.yml -s node dist/main.js tests/success/chaining/verify_login_chained.strest.yml -l -s node dist/main.js tests/success/chaining/login.strest.yml -s tests/strest_history.json node dist/main.js tests/success/chaining/verify_login_chained.strest.yml -l tests/strest_history.json -s tests/strest_history.json node dist/main.js tests/success/chaining/login.strest.yml -s /tmp/strest_history.json node dist/main.js tests/success/chaining/verify_login_chained.strest.yml -l /tmp/strest_history.json -s /tmp/strest_history.json ``` -------------------------------- ### Run stREST Tests in Bulk (Bash) Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows the command-line flag `-b` used with the `strest` command to execute tests defined in a bulk configuration file. ```bash `strest tests/success/bulk.yml -b` ``` -------------------------------- ### Sending Files and Form Data in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Explains how to send `multipart/form-data` requests in Strest using the `postData` property with `params`. Shows how to include a file using the `file()` function. ```yaml version: 2 requests: postwithfile: request: url: https://postman-echo.com/post method: POST postData: mimeType: multipart/form-data params: - name: userId value: "1" - name: avatar value: <$ file("tests/strest.png") $> ``` -------------------------------- ### Print Equivalent Curl Command for stREST Request (Bash) Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows the command-line flag `--output curl` used with the `strest` command to print the equivalent curl command for each executed request. ```bash strest ... --output curl ``` -------------------------------- ### Defining Multiple Requests in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows how to include multiple test requests within a single .strest.yml file by adding multiple entries under the requests key. ```yaml version: 2 requests: requestOne: ... requestTwo: ... requestThree: ... ``` -------------------------------- ### Chaining Requests with Previous Response Data - YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Demonstrates how to reference data from a previous request's response (e.g., 'login') within a subsequent request's parameters or headers using the <$ requestName.content.jsonKey $> syntax. Shows using the 'authenticated' value from the 'login' response. ```yaml requests: login: # will return { authenticated: true } ... authNeeded: request: ... headers: - name: Authorization value: Bearer <$ login.content.authenticated $> # It's possible to use the status code, headers, and status text from previous calls. ``` -------------------------------- ### Build Strest Project (Bash) Source: https://github.com/eykrehbein/strest/blob/master/CONTRIBUTING.md Provides the command to build the strest project using the npm build script defined in package.json. This command compiles the source code. ```bash npm run build ``` -------------------------------- ### Using Environment Variables in Requests - YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Demonstrates how to reference a predefined environment variable (STREST_URL) within a request URL using the <$ Env("VARIABLE_NAME") $> syntax. Requires the environment variable to be set externally. ```yaml version: 2 # ensure the ENV var is set: `export STREST_URL=https://jsonplaceholder.typicode.com` requests: environment: request: url: <$ Env("STREST_URL") $>/todos/1 method: GET ``` -------------------------------- ### Configuring Basic Authentication in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md Shows how to configure HTTP Basic Authentication for a request. This method automatically sets the `Authorization` header using the provided username and password. ```yaml # Example someRequest: request: ... auth: basic: username: myusername password: test123 ``` -------------------------------- ### Setting Environment Variable for Strest - Bash Source: https://github.com/eykrehbein/strest/blob/master/README.md Provides the Bash command to set an environment variable (STREST_URL) which can then be referenced within Strest configuration files. This is a prerequisite step for using environment variables. ```bash export STREST_URL=https://jsonplaceholder.typicode.com strest tests/success/Env/environ.strest.yml ``` -------------------------------- ### Configuring Strest Colors (YAML) Source: https://github.com/eykrehbein/strest/blob/master/README.md This YAML snippet demonstrates how to set custom color values for Strest's primary, secondary, and error colors. The configuration is stored in a `.strestConfig.yml` file located in the user's home directory. Colors are specified using hexadecimal color codes. ```yaml config: primaryColor: "#2ed573" # Hexadecimal Color Code (don't forget the quotation marks) secondaryColor: "#ff4757" # Hexadecimal Color Code errorColor: "#576574" # Hexadecimal Color Code ``` -------------------------------- ### Defining and Using Custom Variables - YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows how to define custom variables directly within the Strest YAML file under the variables section. These variables can then be referenced and used throughout the request definitions using the <$ variableName $> syntax. ```yaml version: 2 variables: # Define variables here testUrl: https://jsonplaceholder.typicode.com/todos/1 to_log: true requests: my_variable_request: request: url: <$ testUrl $> method: GET log: <$ to_log $> ``` -------------------------------- ### Formatting Dates with Nunjucks Filter in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows how to use the Nunjucks `date` filter (wrapping Moment.js) within Strest requests and validation sections to format dates dynamically. Requires the `nunjucks-date` package. ```yaml requests: moment-in-request: request: url: https://postman-echo.com/get method: GET queryString: - name: foo value: <$ now | date('YYYY') $> validate: - jsonpath: content.args.foo expect: "<$ '2019-10-10' | date('YYYY') $>" moment-in-validate: request: url: https://postman-echo.com/time/format?timestamp=2019-10-10&format=YYYY method: GET validate: - jsonpath: content.format expect: "<$ '2019-10-10' | date('YYYY') $>" ``` -------------------------------- ### Reuse Response Data Between stREST Requests (YAML) Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates how to capture and reuse data from a previous request's response in a subsequent request using Nunjucks templating, specifically the `dump` and `safe` filters. ```yaml version: 2 requests: objectSet: request: url: https://postman-echo.com/post method: POST postData: mimeType: application/json text: foo: bar baz: 1 log: true objectReset: request: url: https://postman-echo.com/post method: POST postData: mimeType: application/json text: new: <$ objectSet.content.data | dump | safe $> validate: - jsonpath: content.data expect: {"new":{"foo":"bar","baz":1}} log: true ``` -------------------------------- ### Configure Request Retries in stREST (YAML) Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows how to configure a request to retry until validation succeeds or a maximum number of retries is reached. Uses `delay` and `maxRetries` options. ```yaml requests: waiter: request: url: https://postman-echo.com/time/now method: GET delay: 900 maxRetries: 30 validate: - jsonpath: status expect: 200 - jsonpath: content expect: "Tue, 09 Oct 2018 03:07:20 GMT" ``` -------------------------------- ### Defining Multiple Requests in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This snippet illustrates the basic structure for defining multiple test requests within the `requests` array property in the Strest YAML schema. Each key under `requests` represents a distinct test request. ```yaml # Example requests: request1: .. request2: .. request1000: .. ``` -------------------------------- ### Using Filename() Function in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Demonstrates how to use the `Filename()` function within a Strest request URL to dynamically insert the current strest file name (without the suffix) as a parameter. ```yaml version: 2 requests: test-file-name: request: url: https://<$ Filename() $>.com/get method: GET validate: - jsonpath: status expect: 200 ``` -------------------------------- ### Validating Response with Exact Match (Expect) in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Demonstrates using the `expect` validation type in Strest to perform an exact string match against a specific field in the response body identified by a JSONPath expression. ```yaml requests: example: ... validate: - jsonpath: content expect: "the response has to match this string exactly" ``` -------------------------------- ### Allow Insecure Certificates in stREST (YAML) Source: https://github.com/eykrehbein/strest/blob/master/README.md Demonstrates how to configure a stREST test to ignore SSL certificate errors, allowing connections to endpoints with insecure, self-signed, or expired certificates. ```yaml allowInsecure: true requests: someRequest: ... ``` -------------------------------- ### Sending JSON Request Body from File in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates how to specify an external JSON file path using the `json` option in a Strest POST request. Strest automatically reads the file content and sets the `Content-Type` header. ```yaml version: 2 requests: jsonfile: request: url: https://postman-echo.com/post method: POST json: tests/success/jsonfile/data.json # You have to put the whole path relative to the current directory that you run strest log: true ``` -------------------------------- ### Conditionally Executing Requests - YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates how to use the if condition to control whether a request is executed based on a comparison. The condition checks a value from a previous response (if_Set.content.foo) against a specified value (equals: 1 or equals: 2). Requests are skipped if the condition is false. ```yaml version: 2 requests: if_Set: request: url: https://jsonplaceholder.typicode.com/posts method: POST postData: mimeType: application/json text: foo: 1 skipped: if: operand: <$ if_Set.content.foo $> equals: 2 request: url: https://jsonplaceholder.typicode.com/todos/2 method: GET executed: if: operand: <$ if_Set.content.foo $> equals: 1 request: url: https://jsonplaceholder.typicode.com/todos/2 method: GET ``` -------------------------------- ### Prevent Exiting on Failed stREST Request (Bash) Source: https://github.com/eykrehbein/strest/blob/master/README.md Illustrates using the `-n` or `--no-exit` flag with the `strest` command to continue executing subsequent requests even if a previous request fails validation. ```bash strest ... -n strest ... --no-exit ``` -------------------------------- ### Defining Query String Parameters in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This snippet shows how to add query string parameters to a request using the `queryString` property. It is defined as an array of objects, where each object has `name` and `value` properties. ```yaml version: 2 requests: responseHeaders: request: url: https://postman-echo.com/response-headers method: GET queryString: - name: foo1 value: bar1 - name: foo2 value: bar2 ``` -------------------------------- ### Defining Variables in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This snippet demonstrates how to define custom variables in the Strest YAML schema using the `variables` property. These variables can be reused across different requests and files. ```yaml # Example variables: example_url: https://jsonplaceholder.typicode.com/todos/1 example_id: 1 requests: test: request: url: <$ example_url $> ... ``` -------------------------------- ### Conditional Request Execution with 'if' in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This snippet shows how to use the `if` property to conditionally execute a request based on the result of a previous request. It compares a value extracted from a previous response (`if_Set.content.foo`) to a specified value. ```yaml version: 2 requests: if_Set: request: url: https://jsonplaceholder.typicode.com/posts method: POST postData: mimeType: application/json text: foo: 1 skipped: if: operand: <$ if_Set.content.foo $> equals: 2 request: url: https://jsonplaceholder.typicode.com/todos/2 method: GET executed: if: operand: <$ if_Set.content.foo $> equals: 1 request: url: https://jsonplaceholder.typicode.com/todos/2 method: GET ``` -------------------------------- ### Validating Response Content with Expect in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md Illustrates using the `expect` validation method with `jsonpath`. This method performs an exact string match against the value found at the specified jsonpath within the response content. ```yaml requests: example: ... validate: - jsonpath: content expect: "the response has to match this string exactly" ``` -------------------------------- ### Validating Response with Type Check in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/README.md Shows how to use the `type` validation type in Strest to check if the value at a given JSONPath matches one of the specified data types (e.g., `string`, `number`, `boolean`). ```yaml version: 2 requests: typeValidate: request: url: https://jsonplaceholder.typicode.com/todos method: GET validate: - jsonpath: headers["content-type"] type: [ string ] - jsonpath: status type: [ boolean, string, number ] - jsonpath: content.0.userId type: [ number ] ``` -------------------------------- ### Validating Response Data Types with Type in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md Demonstrates how to use the `type` validation method with `jsonpath`. This allows checking if the value at a specific path matches one of the listed data types (e.g., string, boolean, number). ```yaml version: 2 requests: typeValidate: request: url: https://jsonplaceholder.typicode.com/todos method: GET validate: - jsonpath: headers["content-type"] type: [ string ] - jsonpath: status type: [ boolean, string, number ] - jsonpath: content.0.userId type: [ number ] ``` -------------------------------- ### Defining JSON Post Data in Strest YAML Source: https://github.com/eykrehbein/strest/blob/master/SCHEMA.md This snippet shows how to include JSON data in the request body using the `postData` property. It requires setting the `mimeType` to `application/json` and providing the JSON structure under the `text` property. ```yaml # JSON Example version: 2 requests: postRequest: request: url: https://postman-echo.com/post method: POST postData: mimeType: application/json # Set the mimeType text: foo: bar: "baz" ``` -------------------------------- ### Validate JSONPath with Multiple Types (YAML) Source: https://github.com/eykrehbein/strest/blob/master/VALIDATION.md This YAML snippet shows how to configure a validation rule in Strest to check if the value at a specific JSON path (`content.id`) matches at least one of the multiple specified types (`string`, `string.hex`, `null`, `boolean`). This provides flexibility in validating data that could be one of several expected types. ```yaml validate: - jsonpath: content.id type: [ string, string.hex, "null", boolean] ``` -------------------------------- ### Validate JSONPath with Single Type (YAML) Source: https://github.com/eykrehbein/strest/blob/master/VALIDATION.md This YAML snippet demonstrates how to configure a validation rule in Strest to check if the value at a specific JSON path (`content.id`) matches exactly one specified type (`string`). This is used within the 'validate' section of a Strest request configuration. ```yaml validate: - jsonpath: content.id type: [ string ] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.