Skip to content

contracteer 3.1.0

Choose a tag to compare

@camory camory released this 07 Jun 14:35
· 5 commits to main since this release

OpenAPI 3.1 support

Contracteer 3.1.0 adds contract testing for OpenAPI 3.1 / JSON Schema 2020-12 specifications. Contracteer detects the specification version and parses accordingly; OpenAPI 3.0 behavior is unchanged except as noted below.

New in OpenAPI 3.1

  • type: "null" and type: [T, "null"] for nullable values
  • const for single-value schemas
  • propertyNames to constrain property names
  • contentEncoding: base64 and contentMediaType for binary string bodies (the 3.1 replacements for format: byte and format: binary)
  • $ref with sibling keywords (implicit allOf merge) and $ref by JSON Pointer into nested schema locations
  • Path-level parameters and operation parameter $ref resolution
  • New string formats: uri, uri-reference, hostname

A documented subset, enforced at load

Contracteer implements a documented subset of JSON Schema 2020-12 and rejects unsupported keywords at load with an explanatory message instead of silently ignoring them, so a green run means the whole specification was exercised. Not supported (rejected at load): prefixItems, if/then/else, patternProperties, contains, dependentRequired/dependentSchemas, unevaluatedItems/unevaluatedProperties, not, multi-type unions, and $defs-referenced schemas.

See the OpenAPI coverage matrix for the full list of supported and rejected constructs.

Changes for existing OpenAPI 3.0 users

Two correctness fixes apply to all specification versions and reject at load what was previously mishandled. A specification that loaded before may need a change:

  • not is now rejected at load instead of being silently ignored.
  • Flat-style parameters (simple, form, label, matrix) carrying arrays of objects or arrays of arrays are now rejected; their serialization is undefined in the specification.

Changelog

🚀 Features

core

  • 1f193f7 introduce NullDataType for OAS 3.1
  • 9eeebac widen codec/serde dispatch to composed schemas
  • c7e0019 merge OAS 3.1 $ref with sibling keywords
  • bc31a55 hard-error unsupported OAS 3.1 keywords
  • e7ed051 support uri, uri-reference, hostname string formats
  • 0f52cfa support OAS 3.1 path-level parameters
  • 3decd02 support OAS 3.1 propertyNames keyword
  • fa52a24 support OAS 3.1 contentEncoding and contentMediaType
  • 7a92189 support OAS 3.1 const keyword
  • ab51e91 support OAS 3.1 via type-based schema dispatch
  • 5536b4d version detection and spec-version-aware parsing

🐛 Fixes

core

  • 7d6ef72 reject 'not' keyword instead of silently ignoring it
  • 5aa634d honor additionalProperties on exploded object params
  • 2ddb9fb reject array-of-non-primitive items in flat-style params
  • 941a28d resolve $ref via JSON Pointer to any Schema location
  • 2e62869 resolve OAS 3.1 operation-level parameter $refs
  • cd4ff73 allow OAS 3.1 array schemas without items

verifier

  • 40cd03b skip type-mismatch for permissive exploded objects

🔄️ Changes

core

  • 89dbd86 group unsupported-keyword checks in convertSchema

🧪 Tests

core

  • 74d2590 move datatype fixtures to 3.0 subfolder

📝 Documentation

  • 8480764 document OpenAPI 3.0 and 3.1 coverage across the site

Contributors

We'd like to thank the following people for their contributions:
Tophe