Skip to content

v0.20.0

Choose a tag to compare

@github-actions github-actions released this 30 Oct 07:31
· 44 commits to main since this release

Two new operators for expect and until: regular expressions, and JSON Schema. No breaking change.

matches: a regular expression

On a body value, a header or a cookie. It searches the value, like JavaScript's RegExp.test; anchor it with ^...$ for the whole value, (?i) ignores case. Numbers and booleans are matched as their JSON text. Placeholders work: '^${prefix}-'.

expect:
  headers:
    Location: { matches: '^/api/orders/[0-9]+$' }
  cookies:
    sid: { matches: '^[0-9a-f]{32}$' }
  body:
    $.id: { matches: '^ORD-[0-9]{8}-[0-9]{4}$' }
    $.email: { matches: '(?i)@example\.com$' }

An invalid pattern is an error before any request, with the reason. A pattern that takes more than 1 s on a value fails the step instead of hanging the run.

schema: check a value against a JSON Schema

The whole body ($) or a part of it, against a JSON or YAML schema file, a schema inside your OpenAPI document (after #, a JSON Pointer), or a schema written in the step:

expect:
  body:
    $: { schema: ../openapi/openapi.yaml#/components/schemas/User }
    $.address: { schema: ../schemas/address.json }
    $.id: { schema: { type: integer, minimum: 1 } }
      ✗ $.nickname schema required  actual (missing)
      ✗ $.id schema type "string"  actual 1
  • JSON Schema drafts 4 to 2020-12 and the schemas of OpenAPI 3.0 and 3.1 (nullable, boolean exclusiveMinimum), $ref within a document and to other files, and the common formats (date-time, date, time, email, uuid, uri, ipv4, ipv6).
  • Schemas are read and checked when the workflow is loaded: a missing file, a pointer that leads nowhere, a misspelled keyword (requird) or an unsupported one is an error with its location, before any request.
  • One failed check per problem, at the path of the value, at most 20, then a count.

The guide for coding agents (tinyprobe guide) maps Postman's jsonSchema, tv4.validate and .to.be.a("string"), and Bruno's type checks, to schema, and tells agents that start from an OpenAPI document to point at components/schemas instead of copying them.

Also

  • docs/example uses both operators, so CI and the test server image exercise them.
  • Strings in the report keep characters such as + as they are, instead of +.
  • The binary is 165 KB larger (9.3 MB) and starts in the same 5 ms.

What's Changed

  • matches: regular expressions on body values, headers and cookies (spec 0015) by @kikutano in #33
  • schema: check a body value against a JSON Schema (spec 0016) by @kikutano in #34

Full Changelog: v0.19.0...v0.20.0