Skip to content

Add JSON schema and validation for examples.json#641

Open
caugner wants to merge 8 commits into
mainfrom
640-validate-examples
Open

Add JSON schema and validation for examples.json#641
caugner wants to merge 8 commits into
mainfrom
640-validate-examples

Conversation

@caugner

@caugner caugner commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Description

Add a JSON schema for examples.json and validate it in CI.

  • Add examples.schema.json describing the top-level array of example entries (description, javascript_apis, name), including a directory-safe pattern for name and a Namespace.member pattern for javascript_apis entries.
  • Add ajv as a dev dependency and a validate script (node validate.js, run via npm run validate), also chained into npm test.
  • Add a validate job to the lint workflow.

Motivation

Ensure examples.json stays well-formed, since it is consumed downstream (e.g. by rari to link example extensions from MDN WebExtensions API pages).

Additional details

Related issues and pull requests

Fixes #640.

@caugner caugner marked this pull request as ready for review July 3, 2026 11:54
@caugner caugner requested a review from a team as a code owner July 3, 2026 11:54
@caugner caugner requested a review from LeoMcA July 3, 2026 11:54
@caugner caugner marked this pull request as draft July 3, 2026 11:54
caugner added 3 commits July 3, 2026 13:57
Reject values containing slashes, spaces, or other characters that
would produce a broken GitHub link for the example.
Enforce the `Namespace.member` shape (e.g. `tabs.query`) so malformed
entries fail validation.
Replace `ajv-cli` with a small `node validate.js` that compiles the
schema with `ajv` directly. Drops the `ajv-cli` transitive tree
(`glob@7`, `js-yaml@3`, `fast-json-patch`, `minimist`, ...) and prints
per-error paths on failure.
@caugner caugner marked this pull request as ready for review July 3, 2026 12:02

@LeoMcA LeoMcA left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice stuff

@LeoMcA LeoMcA requested a review from a team as a code owner July 10, 2026 14:13
@LeoMcA LeoMcA requested a review from bacharakis July 10, 2026 14:13
@LeoMcA

LeoMcA commented Jul 10, 2026

Copy link
Copy Markdown
Member

@caugner do we need a CODEOWNERS change? I suppose we should own these files?

@Rob--W Rob--W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code lgtm.

do we need a CODEOWNERS change? I suppose we should own these files?

The code owner was intentionally changed to the addons team, because we are the ones who can/should review extension examples.

This linter was introduced here to make sure that mdn/rari does not break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add required PR check ensuring examples.json doesn't break mdn/rari

4 participants