{"_id":"@antimatter-studios/gavel","name":"@antimatter-studios/gavel","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@antimatter-studios/gavel","version":"1.0.0","description":"Validates HTTP messages against expectations, the validation engine dredd reports with","main":"lib/index.js","typings":"typings.d.ts","engines":{"node":">=20.19"},"bin":{"gavel":"bin/gavel"},"dependencies":{"ajv":"8.20.0","ajv-draft-04":"^1.0.0","ajv-formats":"^3.0.1","commander":"8.1.0","content-type":"1.0.4","curl-trace-parser":"0.0.10","deep-equal":"2.0.5","http-string-parser":"0.0.6","media-typer":"1.1.0"},"repository":{"type":"git","url":"git+https://github.com/antimatter-studios/dredd.git","directory":"packages/gavel"},"keywords":["http","validation","diff","request","response","gavel"],"author":{"name":"Apiary Czech Republic, s.r.o.","email":"support@apiary.io"},"license":"MIT","types":"typings.d.ts","devDependencies":{"chai":"^4.5.0","mocha":"^11.8.0"},"bugs":{"url":"https://github.com/antimatter-studios/dredd/issues"},"homepage":"https://github.com/antimatter-studios/dredd/tree/master/packages/gavel","scripts":{"test":"mocha \"test/**/*.test.js\"","test:features":"node scripts/cucumber.js"},"_id":"@antimatter-studios/gavel@1.0.0","_integrity":"sha512-NKkU4P7uk6L+nkBeOzhpXQs1q5yGa3xiu7u7eX5ZF6E1aQzRkIPClpebdQTxMKgvmVWLFFRB4m94Rqp3UOcS6g==","_resolved":"/private/var/folders/0k/nf8vt_350d16l72c1syfqww80000gn/T/5e1e61fe89b71c24448190f3a0281fff/antimatter-studios-gavel-1.0.0.tgz","_from":"file:antimatter-studios-gavel-1.0.0.tgz","_nodeVersion":"26.5.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-NKkU4P7uk6L+nkBeOzhpXQs1q5yGa3xiu7u7eX5ZF6E1aQzRkIPClpebdQTxMKgvmVWLFFRB4m94Rqp3UOcS6g==","shasum":"32f312e2742f435a84188a535dcd56598f2a5842","tarball":"https://registry.npmjs.org/@antimatter-studios/gavel/-/gavel-1.0.0.tgz","fileCount":31,"unpackedSize":51895,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDzRcjzwucqLhzPV7uRw1EUXAe2KWtomdPqsao6VtMQIAIhANbUVd7WGU5jTIxWVANMqvXloaYACl/YJjFS+N6d3j9O"}]},"_npmUser":{"name":"christhomas","email":"chris.thomas@antimatter-studios.com"},"directories":{},"maintainers":[{"name":"christhomas","email":"chris.thomas@antimatter-studios.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/gavel_1.0.0_1786874011234_0.24816694549968354"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-16T09:53:31.050Z","1.0.0":"2026-08-16T09:53:31.393Z","modified":"2026-08-16T09:53:31.655Z"},"maintainers":[{"name":"christhomas","email":"chris.thomas@antimatter-studios.com"}],"description":"Validates HTTP messages against expectations, the validation engine dredd reports with","homepage":"https://github.com/antimatter-studios/dredd/tree/master/packages/gavel","keywords":["http","validation","diff","request","response","gavel"],"repository":{"type":"git","url":"git+https://github.com/antimatter-studios/dredd.git","directory":"packages/gavel"},"author":{"name":"Apiary Czech Republic, s.r.o.","email":"support@apiary.io"},"bugs":{"url":"https://github.com/antimatter-studios/dredd/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <a href=\"https://badge.fury.io/js/gavel\" target=\"_blank\">\n    <img src=\"https://badge.fury.io/js/gavel.svg\" alt=\"npm version\" />\n  </a>\n  <a href=\"https://snyk.io/test/npm/gavel\" target=\"_blank\">\n    <img src=\"https://snyk.io/test/npm/gavel/badge.svg\" alt=\"Known Vulnerabilities\" />\n  </a>\n</p>\n\n<br />\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/apiaryio/gavel/master/img/gavel.png?v=1\" alt=\"Gavel logo\" />\n</p>\n\n<h1 align=\"center\">Gavel</h1>\n\n<p align=\"center\">Gavel tells you whether an actual HTTP message is valid against an expected HTTP message.</p>\n\n## Install\n\n```bash\nnpm install gavel\n```\n\n## Usage\n\n### CLI\n\n```bash\n# (Optional) Record HTTP messages\ncurl -s --trace - http://httpbin.org/ip | curl-trace-parser > expected\ncurl -s --trace - http://httpbin.org/ip | curl-trace-parser > actual\n\n# Perform the validation\ncat actual | gavel expected\n```\n\n> **Gavel CLI is not supported on Windows**. Example above uses [`curl-trace-parser`](https://github.com/apiaryio/curl-trace-parser).\n\n### NodeJS\n\n```js\nconst gavel = require('gavel');\n\n// Define HTTP messages\nconst expected = {\n  statusCode: 200,\n  headers: {\n    'Content-Type': 'application/json'\n  }\n};\n\nconst actual = {\n  statusCode: 404,\n  headers: {\n    'Content-Type': 'application/json'\n  }\n};\n\n// Perform the validation\nconst result = gavel.validate(expected, actual);\n```\n\nThe code above would return the following validation `result`:\n\n```js\n{\n  valid: false,\n  fields: {\n    statusCode: {\n      valid: false,\n      kind: 'text',\n      values: {\n        expected: '200',\n        actual: '404'\n      },\n      errors: [\n        {\n          message: `Expected status code '200', but got '404'.`\n        }\n      ]\n    },\n    headers: {\n      valid: true,\n      kind: 'json',\n      values: {\n        expected: {\n          'Content-Type': 'application/json'\n        },\n        actual: {\n          'Content-Type': 'application/json'\n        }\n      },\n      errors: []\n    }\n  }\n}\n```\n\n### Usage with JSON Schema\n\n> When a parsable JSON body is expected without an explicit schema the [default schema](https://github.com/apiaryio/gavel-spec/blob/master/features/expectations/bodyJsonExample.feature) is inferred.\n\nYou can describe the body expectations using [JSON Schema](https://json-schema.org/) by providing a valid schema to the `bodySchema` property of the expected HTTP message:\n\n```js\nconst gavel = require('gavel');\n\nconst expected = {\n  bodySchema: {\n    type: 'object',\n    properties: {\n      fruits: {\n        type: 'array',\n        items: {\n          type: 'string'\n        }\n      }\n    }\n  }\n};\n\nconst actual = {\n  body: JSON.stringify({\n    fruits: ['apple', 'banana', 2]\n  })\n};\n\nconst result = gavel.validate(expected, actual);\n```\n\nThe validation `result` against the given JSON Schema will look as follows:\n\n```js\n{\n  valid: false,\n  fields: {\n    body: {\n      valid: false,\n      kind: 'json',\n      values: {\n        actual: \"{\\\"fruits\\\":[\\\"apple\\\",\\\"banana\\\",2]}\"\n      },\n      errors: [\n        {\n          message: `At '/fruits/2' Invalid type: number (expected string)`,\n          location: {\n            pointer: '/fruits/2'\n          }\n        }\n      ]\n    }\n  }\n}\n```\n\n### Supported JSON Schema versions\n\n- [JSON Schema Draft 7](https://json-schema.org/specification-links.html#draft-7)\n- [JSON Schema Draft 6](https://json-schema.org/specification-links.html#draft-6)\n- [JSON Schema Draft 4](https://json-schema.org/specification-links.html#draft-4)\n\n## Examples\n\nTake a look at the [Gherkin](https://cucumber.io/docs/gherkin/) specification, which describes on examples how validation of each field behaves:\n\n- [`method`](https://github.com/apiaryio/gavel-spec/blob/master/features/javascript/fields/method.feature)\n- [`uri`](https://github.com/apiaryio/gavel-spec/blob/master/features/javascript/fields/uri.feature)\n- [`statusCode`](https://github.com/apiaryio/gavel-spec/blob/master/features/javascript/fields/statusCode.feature)\n- [`headers`](https://github.com/apiaryio/gavel-spec/blob/master/features/javascript/fields/headers.feature)\n- [`body`](https://github.com/apiaryio/gavel-spec/blob/master/features/javascript/fields/body.feature)\n- [`bodySchema`](https://github.com/apiaryio/gavel-spec/blob/master/features/javascript/fields/bodySchema.feature)\n\n## Type definitions\n\nGavel ships with [TypeScript type definitions](./typings.d.ts). Please refer to the definitions file for more details.\n\n## API\n\n- `validate(expected: HttpMessage, actual: HttpMessage): ValidationResult`\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md","_rev":"1-d08dfc034f1c960275781f24b3b75090"}