You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: content-type support for validateResponse/validateRequest (#1)
* feat(types): add optional contentType to ValidatorOptions
Narrow stored options type to { strict: boolean } since contentType
is resolved per-call, not at construction time.
* feat(schemas): add isBinaryContentType helper
* feat(schemas): add resolveMediaType helper for content-type lookup
* feat(schemas): content-type aware response schema extraction
Extend extractResponseSchema with an optional contentType parameter (defaulting
to application/json) that uses isBinaryContentType and resolveMediaType to
support exact, family-wildcard, and */* media-type matching; silently bypasses
unmatched binary types and emits MISSING_SCHEMA for unmatched non-binary types.
* feat(schemas): content-type aware request schema extraction
Extend extractRequestSchema with an optional contentType parameter (defaulting
to application/json), using resolveMediaType for wildcard matching and
isBinaryContentType for silent bypass of binary payloads.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(validator): forward contentType option through validateResponse
Plumbs options.contentType (defaulting to 'application/json') from
validateResponse into extractResponseSchema, enabling content-type-aware
schema lookup for binary and wildcard media types.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(validator): forward contentType option through validateRequest
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(validator): normalize schemas under all content-type entries
Update normalizeAllSchemas to iterate over every media-type object in
both response content and requestBody content, rather than only
handling application/json, so non-JSON schemas (multipart/form-data,
text/plain, etc.) are also converted to OpenAPI 3.1 shape during init.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(validator): use discriminating exclusiveMinimum transform
Replace nullable-based assertions (which Ajv silently accepts even
without normalization due to strict:false) with exclusiveMinimum
boolean-form tests that only pass when normalizeAllSchemas actually
rewrites 3.0 schemas under non-JSON content types.
* chore: bump version to 0.2.0 for content-type support
* docs: changelog entry for 0.2.0 content-type support
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,15 @@
1
1
# Changelog
2
2
3
+
## 0.2.0 (2026-04-20)
4
+
5
+
### Features
6
+
7
+
-**content-type:** Add optional `contentType` to `ValidatorOptions` for `validateResponse` and `validateRequest`. Defaults to `application/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-positive `MISSING_SCHEMA` warnings when a mock returns binary data like a QR code.
8
+
9
+
### Internal
10
+
11
+
-**normalize:**`normalizeAllSchemas` now rewrites OpenAPI 3.0 → 3.1 schemas under every media-type entry in `content`, not only `application/json`. Previously, schemas declared under e.g. `multipart/form-data` or `image/jpeg` missed the rewrite and could throw at validation time.
0 commit comments