fix: forward mock Content-Type to contract validator#5
Merged
kevinccbsg merged 10 commits intomainfrom Apr 21, 2026
Merged
Conversation
…2, puppeteer 24.42.0) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Adds /products/{id}/thumbnail endpoint (image/*) to products-3.0.json
- Adds 4 mocks exercising the new Content-Type forwarding:
- image/png and image/jpeg against image/* spec → should validate cleanly
- application/xml against JSON-only /api/products → should warn (MISSING_SCHEMA)
- No responseHeaders against image-only endpoint → should warn (defaults to JSON, no match)
All four endpoints use contract mode 'warn' so CI does not fail on the
intentional negative cases.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI was failing with `npm ci` errors because the previous dep-bump commit's lockfile was missing top-level @emnapi/core and @emnapi/runtime entries that are required by transitive peers of @napi-rs/wasm-runtime. Regenerating via a fresh `npm install` restores them. All 177 tests pass and `npm ci` now succeeds locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TWD Contract Validation
23 passed · 41 failed · 3 warnings · 1 skipped Failed validations./contracts/users-3.0.json
./contracts/posts-3.1.json
./contracts/products-3.0.json
./contracts/events-3.1.json
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
readContentType(responseHeaders)helper insrc/contracts.jsthat readsContent-Typefrom each collected mock and forwards it as{ contentType }toopenapi-mock-validator'svalidateResponse. Defaults toapplication/jsonwhen noresponseHeadersis present.MISSING_SCHEMAwarnings for binary mocks (image/*,audio/*,video/*, etc.) — the validator now resolves the correct media-type entry in the spec instead of always looking upapplication/json.openapi-mock-validator@^0.2.0(contentType support),twd-js@^1.7.2(emitsresponseHeaderson collected mocks), andpuppeteer@^24.42.0.1.1.10and adds CHANGELOG entry.No public API surface changes for consumers of
twd-cli. Part 2 of 3 in the cross-repo rollout (openapi-mock-validator+twd-jsalready shipped).Test Plan
responseHeaders: { 'Content-Type': 'image/png' }against spec withimage/*→ noMISSING_SCHEMAwarning, no errorsContent-Type,content-type,CONTENT-TYPEall resolve correctlyresponseHeadersandresponseHeaderswithout a Content-Type entry both fall back toapplication/jsonrunTests()collector preservesresponseHeadersthrough the{ ...mock }spread insrc/index.js(drives the real__twdCollectMockcallback)test-example-app/with a mock setting a non-JSON Content-Type🤖 Generated with Claude Code