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
We already import OpenAPI 3.x specs (#25) and support # @test assertions (#6). Close the loop: let devs assert responses against a schema instead of hand-writing per-field assertions. Two entry points, one core:
Zero new heavy deps: use ajv (already common in the TS ecosystem, MIT-licensed, tiny footprint, we already validate everything with zod — ajv earns its keep because it is the JSON Schema validator).
Reuses the existing OpenAPI import path — no second parser.
Pitch
We already import OpenAPI 3.x specs (#25) and support
# @testassertions (#6). Close the loop: let devs assert responses against a schema instead of hand-writing per-field assertions. Two entry points, one core:# @schema { "type": "object", "required": ["id"] }# @schema openapi:./api.yaml#/paths/~1users~1{id}/get/responses/200Assertion runs after the response comes back; failures show up in the response panel with the exact JSON Pointer path and a plain-English reason.
Why this matters
.httpfiles into CI ([M6] Run-file mode + test assertions + CLI #6 CLI mode).ajv(already common in the TS ecosystem, MIT-licensed, tiny footprint, we already validate everything withzod—ajvearns its keep because it is the JSON Schema validator).User-visible behavior
# @schema <inline-json | openapi:<path>#/<pointer> | file:<path>>directive above a request.response.bodyagainst the resolved schema.reqit run) exits non-zero on schema-validation failure — same as@testfailures — so this is drop-in for CI gates.Acceptance criteria
src/core/schemaValidator.ts: resolves a schema ref (inline / file / openapi-pointer), validates a JSON body withajv, returns a normalized{ ok, violations[] }result. Unit-tested with vitest (inline pass/fail, ref resolution, invalid-pointer errors, non-JSON response guard).src/core/schemaRef.ts: JSON Pointer + OpenAPI$refresolver (walkscomponents.schemasandpaths.*.responses.*.content['application/json'].schema). Unit-tested.src/core/parser.ts) recognizes# @schemadirective; validated by zod; ignored on non-JSON responses with a warning.@schemawas set) with pass/fail + violations list.ajv+ajv-formats(only these; noajv-cli, nojson-schema-ref-parser).