Releases: BRIKEV/openapi-mock-validator
Releases · BRIKEV/openapi-mock-validator
v0.3.0
Internal
- deps: Bump runtime and dev dependencies. Notably crosses
ajv-formatsv2 → v3. The only behavioral change in v3 is that thedate-timeandtimeformats now require a timezone per RFC3339 — strings like"2024-04-15T00:00:00"(noZ/ offset) will now fail validation. Use the newiso-time/iso-date-timeformats to opt back into the v2 behavior. - security: Bumping
ajvto ^8.20.0 closes the high-severityfast-uriadvisories (GHSA-q3j6-qgpj-74h6, GHSA-v39h-62p7-jpjc) pulled in transitively.
| package | from | to |
|---|---|---|
| ajv | ^8.18.0 | ^8.20.0 |
| ajv-formats | ^2.1.1 | ^3.0.1 |
| @apidevtools/json-schema-ref-parser | ^15.3.4 | ^15.3.5 |
| path-to-regexp | ^8.4.0 | ^8.4.2 |
| vitest | ^4.1.2 | ^4.1.5 |
| @vitest/coverage-v8 | ^4.1.2 | ^4.1.5 |
Full Changelog: v0.2.0...v0.3.0
v0.2.0
Features
- content-type: Add optional
contentTypetoValidatorOptionsforvalidateResponseandvalidateRequest. Defaults toapplication/json(backwards compatible). Media-type resolution order is exact match → family wildcard (image/*) →*/*. Unmatched binary content types (image/*,video/*,audio/*,application/octet-stream,application/pdf,application/zip) are silently bypassed — no more false-positiveMISSING_SCHEMAwarnings when a mock returns binary data like a QR code.
Internal
- normalize:
normalizeAllSchemasnow rewrites OpenAPI 3.0 → 3.1 schemas under every media-type entry incontent, not onlyapplication/json. Previously, schemas declared under e.g.multipart/form-dataorimage/jpegmissed the rewrite and could throw at validation time.
Full Changelog: v0.1.4...v0.2.0
v0.1.4
Bug Fixes
- error messages: Include property names in
requiredandadditionalPropertieserror messages. Instead ofunexpected property, unexpected propertyyou now getunexpected property "foo", unexpected property "bar"— making composition error summaries actually actionable.
Full Changelog: v0.1.3...v0.1.4
v0.1.3
Features
- Descriptive oneOf/anyOf error messages: Instead of the generic "does not match any allowed schema", errors now identify the best-matching branch and its specific sub-errors.
- Discriminator resolution: When the schema declares a
discriminator, errors pinpoint the matched branch:
oneOf matched branch "card" (via discriminator "type"), but: unexpected property - Best-match fallback: When no discriminator is present, picks the branch with the fewest errors:
anyOf best match (branch 1 of 2) failed: expected number, got string - Works with nested compositions (oneOf inside allOf), array items, and nullable schemas
- Discriminator resolution: When the schema declares a
Full Changelog: v0.1.2...v0.1.3
v0.1.2
Bug Fixes
- strict mode: Fix false positives when validating
oneOfschemas withallOfcomposition. Strict mode was applyingadditionalProperties: falseto eachallOfbranch independently, causing sibling properties to be rejected as unexpected. Now merges property keys acrossallOfbranches before applying strict constraints.
v0.1.1
Bug Fixes
- normalize: Handle
nullable: truewithouttypein OpenAPI 3.0 schemas. Schemas usingnullableonallOfcompositions or bare description objects were not being normalized, causing Ajv to throw"nullable" cannot be used without "type".
Maintenance
- Regenerate
package-lock.jsonfor cross-platform compatibility
Full Changelog: v0.1.0...v0.1.1
v0.1.0
Initial release
OpenAPI 3.0/3.1 mock validator — validates JSON payloads against OpenAPI specs to catch mock drift before it hits production.
Features
- Validate response and request payloads against OpenAPI 3.0 and 3.1 specs
- Automatic
$refdereferencing and 3.0 → 3.1 normalization (nullable, exclusiveMin/Max) - URL path matching with parameter support (
/users/{userId}) - Humanized error messages (
missing required property,must be one of: ..., collapsed oneOf errors) - Strict mode with
additionalProperties: falseinjection - Format validation via
ajv-formats(uuid, email, date-time, uri, ipv4, ipv6, etc.) - Reusable Ajv instance for fast bulk validation