@octokit/webhooks-schemas

Community contributed webhook payload schemas in JSON schema format

Usage no npm install needed!

<script type="module">
  import octokitWebhooksSchemas from 'https://cdn.skypack.dev/@octokit/webhooks-schemas';
</script>

README

Octokit Webhooks

machine-readable, always up-to-date GitHub Webhooks specifications

Update status

Download

Download the latest specification at unpkg.com/@octokit/webhooks-schemas/schema.json

Usage as Node module

To get the JSON schema for webhook payloads, require the @octokit/webhooks-schemas package.

// Use Node.js require:
const SCHEMA = require("@octokit/webhooks-schemas");

// Or ESM/TypeScript import:
import SCHEMA from "@octokit/webhooks-schemas";

Usage with ajv in strict mode

When running in strict mode, ajv will throw an "unknown keyword" error if it encounters any keywords that have not been defined.

This schema currently uses custom keywords provided by ajv-formats, along with the custom keyword tsAdditionalProperties.

Here is an example of how you can set this up:

import type { WebhookEvent } from "@octokit/webhooks-types";
import * as githubWebhookSchema from "@octokit/webhooks-schemas";
import Ajv from "ajv";
import addFormats from "ajv-formats";

const ajv = new Ajv({ strict: true });

addFormats(ajv);
ajv.addKeyword("tsAdditionalProperties");

const validate = ajv.compile<WebhookEvent>(githubWebhookSchema);

See also

LICENSE

MIT